@@ -148,18 +148,8 @@ private JsonObject toJsonFromRequestObj(UserInfo ui, Set<String> scope, JsonObje
148
148
Set <String > authorizedByClaims = new HashSet <>();
149
149
Set <String > requestedByClaims = new HashSet <>();
150
150
151
- if (authorizedClaims != null ) {
152
- JsonObject userinfoAuthorized = authorizedClaims .getAsJsonObject ().get ("userinfo" ).getAsJsonObject ();
153
- for (Entry <String , JsonElement > entry : userinfoAuthorized .getAsJsonObject ().entrySet ()) {
154
- authorizedByClaims .add (entry .getKey ());
155
- }
156
- }
157
- if (requestedClaims != null ) {
158
- JsonObject userinfoRequested = requestedClaims .getAsJsonObject ().get ("userinfo" ).getAsJsonObject ();
159
- for (Entry <String , JsonElement > entry : userinfoRequested .getAsJsonObject ().entrySet ()) {
160
- requestedByClaims .add (entry .getKey ());
161
- }
162
- }
151
+ extractUserInfoClaimsIntoSet (authorizedClaims , authorizedByClaims );
152
+ extractUserInfoClaimsIntoSet (requestedClaims , requestedByClaims );
163
153
164
154
// Filter claims by performing a manual intersection of claims that are allowed by the given scope, requested, and authorized.
165
155
// We cannot use Sets.intersection() or similar because Entry<> objects will evaluate to being unequal if their values are
@@ -180,4 +170,15 @@ private JsonObject toJsonFromRequestObj(UserInfo ui, Set<String> scope, JsonObje
180
170
181
171
return result ;
182
172
}
173
+
174
+ private void extractUserInfoClaimsIntoSet (JsonObject claims , Set <String > target ) {
175
+ if (claims != null ) {
176
+ JsonObject userinfoAuthorized = claims .getAsJsonObject ("userinfo" );
177
+ if (userinfoAuthorized != null ) {
178
+ for (Entry <String , JsonElement > entry : userinfoAuthorized .entrySet ()) {
179
+ target .add (entry .getKey ());
180
+ }
181
+ }
182
+ }
183
+ }
183
184
}
0 commit comments