added null check to confirmation controller, closes #684

pull/705/head
Justin Richer 2014-10-07 21:58:00 -04:00
parent dcee8a2311
commit f133bc9b24
1 changed files with 14 additions and 12 deletions

View File

@ -153,21 +153,23 @@ public class OAuthConfirmationController {
// get the userinfo claims for each scope // get the userinfo claims for each scope
UserInfo user = userInfoService.getByUsername(p.getName()); UserInfo user = userInfoService.getByUsername(p.getName());
JsonObject userJson = user.toJson();
Map<String, Map<String, String>> claimsForScopes = new HashMap<String, Map<String, String>>(); Map<String, Map<String, String>> claimsForScopes = new HashMap<String, Map<String, String>>();
if (user != null) {
for (SystemScope systemScope : sortedScopes) { JsonObject userJson = user.toJson();
Map<String, String> claimValues = new HashMap<String, String>();
for (SystemScope systemScope : sortedScopes) {
Set<String> claims = scopeClaimTranslationService.getClaimsForScope(systemScope.getValue()); Map<String, String> claimValues = new HashMap<String, String>();
for (String claim : claims) {
if (userJson.has(claim) && userJson.get(claim).isJsonPrimitive()) { Set<String> claims = scopeClaimTranslationService.getClaimsForScope(systemScope.getValue());
// TODO: this skips the address claim for (String claim : claims) {
claimValues.put(claim, userJson.get(claim).getAsString()); if (userJson.has(claim) && userJson.get(claim).isJsonPrimitive()) {
// TODO: this skips the address claim
claimValues.put(claim, userJson.get(claim).getAsString());
}
} }
claimsForScopes.put(systemScope.getValue(), claimValues);
} }
claimsForScopes.put(systemScope.getValue(), claimValues);
} }
model.put("claims", claimsForScopes); model.put("claims", claimsForScopes);