@@ -72,14 +72,11 @@ public class UserInfoEndpoint {
72
72
*/
73
73
private static final Logger logger = LoggerFactory .getLogger (UserInfoEndpoint .class );
74
74
75
- private static final MediaType JOSE_MEDIA_TYPE = new MediaType ("application" , "jwt" );
76
- private static final String JOSE_MEDIA_TYPE_VALUE = "application/jwt" ;
77
-
78
75
/**
79
76
* Get information about the user as specified in the accessToken included in this request
80
77
*/
81
78
@ PreAuthorize ("hasRole('ROLE_USER') and #oauth2.hasScope('" + SystemScopeService .OPENID_SCOPE + "')" )
82
- @ RequestMapping (method = {RequestMethod .GET , RequestMethod .POST }, produces = {MediaType .APPLICATION_JSON_VALUE , JOSE_MEDIA_TYPE_VALUE })
79
+ @ RequestMapping (method = {RequestMethod .GET , RequestMethod .POST }, produces = {MediaType .APPLICATION_JSON_VALUE , UserInfoJWTView . JOSE_MEDIA_TYPE_VALUE })
83
80
public String getInfo (@ RequestParam (value ="claims" , required =false ) String claimsRequestJsonString ,
84
81
@ RequestHeader (value ="Accept" , required =false ) String acceptHeader ,
85
82
OAuth2Authentication auth , Model model ) {
@@ -99,21 +96,21 @@ public String getInfo(@RequestParam(value="claims", required=false) String claim
99
96
return HttpCodeView .VIEWNAME ;
100
97
}
101
98
102
- model .addAttribute ("scope" , auth .getOAuth2Request ().getScope ());
99
+ model .addAttribute (UserInfoView . SCOPE , auth .getOAuth2Request ().getScope ());
103
100
104
- model .addAttribute ("authorizedClaims" , auth .getOAuth2Request ().getExtensions ().get ("claims" ));
101
+ model .addAttribute (UserInfoView . AUTHORIZED_CLAIMS , auth .getOAuth2Request ().getExtensions ().get ("claims" ));
105
102
106
103
if (!Strings .isNullOrEmpty (claimsRequestJsonString )) {
107
- model .addAttribute ("requestedClaims" , claimsRequestJsonString );
104
+ model .addAttribute (UserInfoView . REQUESTED_CLAIMS , claimsRequestJsonString );
108
105
}
109
106
110
- model .addAttribute ("userInfo" , userInfo );
107
+ model .addAttribute (UserInfoView . USER_INFO , userInfo );
111
108
112
109
// content negotiation
113
110
114
111
// start off by seeing if the client has registered for a signed/encrypted JWT from here
115
112
ClientDetailsEntity client = clientService .loadClientByClientId (auth .getOAuth2Request ().getClientId ());
116
- model .addAttribute ("client" , client );
113
+ model .addAttribute (UserInfoJWTView . CLIENT , client );
117
114
118
115
List <MediaType > mediaTypes = MediaType .parseMediaTypes (acceptHeader );
119
116
MediaType .sortBySpecificityAndQuality (mediaTypes );
@@ -123,7 +120,7 @@ public String getInfo(@RequestParam(value="claims", required=false) String claim
123
120
|| client .getUserInfoEncryptedResponseEnc () != null ) {
124
121
// client has a preference, see if they ask for plain JSON specifically on this request
125
122
for (MediaType m : mediaTypes ) {
126
- if (!m .isWildcardType () && m .isCompatibleWith (JOSE_MEDIA_TYPE )) {
123
+ if (!m .isWildcardType () && m .isCompatibleWith (UserInfoJWTView . JOSE_MEDIA_TYPE )) {
127
124
return UserInfoJWTView .VIEWNAME ;
128
125
} else if (!m .isWildcardType () && m .isCompatibleWith (MediaType .APPLICATION_JSON )) {
129
126
return UserInfoView .VIEWNAME ;
@@ -137,7 +134,7 @@ public String getInfo(@RequestParam(value="claims", required=false) String claim
137
134
for (MediaType m : mediaTypes ) {
138
135
if (!m .isWildcardType () && m .isCompatibleWith (MediaType .APPLICATION_JSON )) {
139
136
return UserInfoView .VIEWNAME ;
140
- } else if (!m .isWildcardType () && m .isCompatibleWith (JOSE_MEDIA_TYPE )) {
137
+ } else if (!m .isWildcardType () && m .isCompatibleWith (UserInfoJWTView . JOSE_MEDIA_TYPE )) {
141
138
return UserInfoJWTView .VIEWNAME ;
142
139
}
143
140
}
0 commit comments