@@ -61,9 +61,6 @@ public class UserInfoView extends AbstractView {
61
61
62
62
private static Logger logger = LoggerFactory .getLogger (UserInfoView .class );
63
63
64
- @ Autowired
65
- private JwtEncryptionAndDecryptionService encryptionService ;
66
-
67
64
private Gson gson = new GsonBuilder ()
68
65
.setExclusionStrategies (new ExclusionStrategy () {
69
66
@@ -117,29 +114,17 @@ protected void renderMergedOutputModel(Map<String, Object> model, HttpServletReq
117
114
118
115
out = response .getWriter ();
119
116
120
- if (model .get ("requestObject" ) != null ) {
121
-
122
- try {
123
- // FIXME: re-parse the request object
124
- String jwtString = (String )model .get ("requestObject" );
125
- JWT requestObject = JWTParser .parse (jwtString );
126
- if (requestObject instanceof EncryptedJWT ) {
127
- // we need to re-decrypt it :(
128
- encryptionService .decryptJwt ((EncryptedJWT ) requestObject );
129
- }
130
-
131
- // FIXME: move to GSON for easier processing
132
- JsonObject obj = (JsonObject ) jsonParser .parse (requestObject .getJWTClaimsSet ().toJSONObject ().toJSONString ());
133
-
134
- gson .toJson (toJsonFromRequestObj (userInfo , scope , obj , claimsRequest ), out );
135
- } catch (JsonSyntaxException e ) {
136
- logger .error ("JsonSyntaxException in UserInfoView.java: " , e );
137
- } catch (JsonIOException e ) {
138
- logger .error ("JsonIOException in UserInfoView.java: " , e );
139
- } catch (ParseException e ) {
140
- logger .error ("ParseException in UserInfoView.java: " , e );
141
- }
117
+ JsonObject authorizedClaims = null ;
118
+ JsonObject requestedClaims = null ;
119
+ if (model .get ("authorizedClaims" ) != null ) {
120
+ authorizedClaims = jsonParser .parse ((String ) model .get ("authorizedClaims" )).getAsJsonObject ();
121
+ }
122
+ if (model .get ("requestedClaims" ) != null ) {
123
+ requestedClaims = jsonParser .parse ((String ) model .get ("requestedClaims" )).getAsJsonObject ();
124
+ }
125
+ if (authorizedClaims != null || requestedClaims != null ) {
142
126
127
+ gson .toJson (toJsonFromRequestObj (userInfo , scope , authorizedClaims , requestedClaims ), out );
143
128
} else {
144
129
145
130
gson .toJson (toJson (userInfo , scope ), out );
@@ -214,22 +199,19 @@ private JsonObject toJson(UserInfo ui, Set<String> scope) {
214
199
*
215
200
* @param ui
216
201
* @param scope
217
- * @param requestObj
218
- * @param claimsRequest the claims request parameter object.
202
+ * @param authorizedClaims
203
+ * @param requestedClaims the claims request parameter object.
219
204
* @return
220
205
*/
221
- private JsonObject toJsonFromRequestObj (UserInfo ui , Set <String > scope , JsonObject requestObj , JsonObject claimsRequest ) {
206
+ private JsonObject toJsonFromRequestObj (UserInfo ui , Set <String > scope , JsonObject authorizedClaims , JsonObject requestedClaims ) {
222
207
208
+ // get the base object
223
209
JsonObject obj = toJson (ui , scope );
224
210
225
- //Process list of requested claims out of the request object
226
- JsonElement claims = requestObj .get ("claims" );
227
- if (claims == null || !claims .isJsonObject ()) {
228
- return obj ;
229
- }
230
-
231
- JsonElement userinfo = claims .getAsJsonObject ().get ("userinfo" );
232
- if (userinfo == null || !userinfo .isJsonObject ()) {
211
+ JsonObject userinfoAuthorized = authorizedClaims .getAsJsonObject ().get ("userinfo" ).getAsJsonObject ();
212
+ JsonObject userinfoRequested = requestedClaims .getAsJsonObject ().get ("userinfo" ).getAsJsonObject ();
213
+
214
+ if (userinfoAuthorized == null || !userinfoAuthorized .isJsonObject ()) {
233
215
return obj ;
234
216
}
235
217
@@ -240,10 +222,10 @@ private JsonObject toJsonFromRequestObj(UserInfo ui, Set<String> scope, JsonObje
240
222
// the same claim but have different 'individual claim values', causing the Entry<> to be unequal,
241
223
// which doesn't allow the use of the more compact Sets.intersection() type method.
242
224
Set <Entry <String , JsonElement >> requestClaimsSet = Sets .newHashSet ();
243
- if (claimsRequest != null ) {
225
+ if (requestedClaims != null ) {
244
226
245
- for (Entry <String , JsonElement > entry : userinfo .getAsJsonObject ().entrySet ()) {
246
- if (claimsRequest .has (entry .getKey ())) {
227
+ for (Entry <String , JsonElement > entry : userinfoAuthorized .getAsJsonObject ().entrySet ()) {
228
+ if (userinfoRequested .has (entry .getKey ())) {
247
229
requestClaimsSet .add (entry );
248
230
}
249
231
}
0 commit comments