From f133bc9b241d6f644b9f95d5c653c0bfad80578c Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Tue, 7 Oct 2014 21:58:00 -0400 Subject: [PATCH] added null check to confirmation controller, closes #684 --- .../web/OAuthConfirmationController.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuthConfirmationController.java b/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuthConfirmationController.java index c04acdd80..8c9451481 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuthConfirmationController.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuthConfirmationController.java @@ -153,21 +153,23 @@ public class OAuthConfirmationController { // get the userinfo claims for each scope UserInfo user = userInfoService.getByUsername(p.getName()); - JsonObject userJson = user.toJson(); Map> claimsForScopes = new HashMap>(); - - for (SystemScope systemScope : sortedScopes) { - Map claimValues = new HashMap(); - - Set claims = scopeClaimTranslationService.getClaimsForScope(systemScope.getValue()); - for (String claim : claims) { - if (userJson.has(claim) && userJson.get(claim).isJsonPrimitive()) { - // TODO: this skips the address claim - claimValues.put(claim, userJson.get(claim).getAsString()); + if (user != null) { + JsonObject userJson = user.toJson(); + + for (SystemScope systemScope : sortedScopes) { + Map claimValues = new HashMap(); + + Set claims = scopeClaimTranslationService.getClaimsForScope(systemScope.getValue()); + for (String claim : claims) { + 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);