Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
fixing IDENTITY-2938
Browse files Browse the repository at this point in the history
  • Loading branch information
hpmtissera committed May 21, 2015
1 parent b80955c commit b150b8a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public IdentityMetadataDO loadMetadata(String userName, int tenantId, String met
prepStmt.setString(3, metadataType);
prepStmt.setString(4, metadata);
results = prepStmt.executeQuery();

connection.commit();
if (results.next()) {
return new IdentityMetadataDO(results.getString(1), results.getInt(2),
results.getString(3), results.getString(4),
Expand All @@ -184,7 +184,6 @@ public IdentityMetadataDO loadMetadata(String userName, int tenantId, String met
if (results.next()) {
throw new IdentityException("Duplicate entry found for " + metadataType);
}
connection.commit();
return null;
} catch (SQLException e) {
throw new IdentityException("Error while reading user identity data", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2360,10 +2360,10 @@ private int getIdentityProviderIdByName(Connection dbConnection, String idpName,
prepStmt.setInt(2, MultitenantConstants.SUPER_TENANT_ID);
prepStmt.setString(3, CharacterEncoder.getSafeText(idpName));
rs = prepStmt.executeQuery();
dbConnection.commit();
if (rs.next()) {
return rs.getInt(1);
}
dbConnection.commit();
} catch (IdentityException e) {
throw new IdentityApplicationManagementException("Error occurred while reading Identity Provider by name" +
".", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ public String getOAuthTokenSecret(String token, Boolean isAccessToken) throws Id
prepStmt = connection.prepareStatement(sqlStmt);
prepStmt.setString(1, token);
resultSet = prepStmt.executeQuery();
connection.commit();

if (resultSet.next()) {
tokenSecret = resultSet.getString(1);
} else {
log.error("Invalid token : " + token);
throw new IdentityException("Invalid token. No such token is issued");
}
connection.commit();
} catch (IdentityException e) {
String errorMsg = "Error when getting an Identity Persistence Store instance.";
log.error(errorMsg, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public AccessTokenDO retrieveLatestAccessToken(String consumerKey, String userNa
prepStmt.setString(3, scope);
}
ResultSet resultSet = prepStmt.executeQuery();
connection.commit();

if (resultSet.next()) {
boolean returnToken = false;
Expand Down Expand Up @@ -323,11 +324,9 @@ public AccessTokenDO retrieveLatestAccessToken(String consumerKey, String userNa
accessTokenDO.setAccessToken(accessToken);
accessTokenDO.setRefreshToken(refreshToken);
accessTokenDO.setTokenState(tokenState);
connection.commit();
return accessTokenDO;
}
}
connection.commit();
return null;
} catch (SQLException e) {
String errorMsg = "Error occurred while trying to retrieve latest 'ACTIVE' " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ private int getIdentityProviderIdByName(Connection dbConnection, String idpName,
prepStmt.setInt(1, tenantId);
prepStmt.setString(2, idpName);
rs = prepStmt.executeQuery();
dbConnection.commit();
if (rs.next()) {
return rs.getInt(1);
}
dbConnection.commit();
} catch (IdentityException e) {
throw new IdentityApplicationManagementException("Error while reading Identity Provider by name.", e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,14 @@ public String getNameAssociatedWith(String idpID, String associatedID) throws Us
prepStmt.setString(4, associatedID);

resultSet = prepStmt.executeQuery();
connection.commit();

if (resultSet.next()) {
String domainName = resultSet.getString(1);
username = resultSet.getString(2);
if(!"PRIMARY".equals(domainName)) {
username = domainName + CarbonConstants.DOMAIN_SEPARATOR + username;
}
connection.commit();
return username;
}

Expand Down

0 comments on commit b150b8a

Please sign in to comment.