96 ClientDetailsEntity authClient = null;
97 Set<String> authScopes =
new HashSet<>();
99 if (auth instanceof OAuth2Authentication) {
101 ensureOAuthScope(auth, SystemScopeService.UMA_PROTECTION_SCOPE);
104 OAuth2Authentication o2a = (OAuth2Authentication) auth;
106 String authClientId = o2a.getOAuth2Request().getClientId();
110 String ownerId = o2a.getUserAuthentication().getName();
112 authScopes.addAll(authClient.getScope());
118 for (ResourceSet rs : resourceSets) {
119 authScopes.addAll(rs.getScopes());
125 String authClientId = auth.getName();
129 authScopes.addAll(authClient.getScope());
131 if (!AuthenticationUtilities.hasRole(auth,
"ROLE_CLIENT")
132 || !authClient.isAllowIntrospection()) {
136 logger.error(
"Client " + authClient.getClientId() +
" is not allowed to call introspection endpoint");
137 model.addAttribute(
"code", HttpStatus.FORBIDDEN);
138 return HttpCodeView.VIEWNAME;
147 if (Strings.isNullOrEmpty(tokenValue)) {
148 logger.error(
"Verify failed; token value is null");
149 Map<String,Boolean> entity = ImmutableMap.of(
"active", Boolean.FALSE);
150 model.addAttribute(JsonEntityView.ENTITY, entity);
151 return JsonEntityView.VIEWNAME;
154 OAuth2AccessTokenEntity accessToken = null;
155 OAuth2RefreshTokenEntity refreshToken = null;
156 ClientDetailsEntity tokenClient;
167 String userName = accessToken.getAuthenticationHolder().getAuthentication().getName();
170 }
catch (InvalidTokenException e) {
171 logger.info(
"Invalid access token. Checking refresh token.");
180 String userName = refreshToken.getAuthenticationHolder().getAuthentication().getName();
183 }
catch (InvalidTokenException e2) {
184 logger.error(
"Invalid refresh token");
185 Map<String,Boolean> entity = ImmutableMap.of(IntrospectionResultAssembler.ACTIVE, Boolean.FALSE);
186 model.addAttribute(JsonEntityView.ENTITY, entity);
187 return JsonEntityView.VIEWNAME;
193 if (accessToken != null) {
195 model.addAttribute(JsonEntityView.ENTITY, entity);
196 }
else if (refreshToken != null) {
198 model.addAttribute(JsonEntityView.ENTITY, entity);
201 logger.error(
"Verify failed; Invalid access/refresh token");
202 Map<String,Boolean> entity = ImmutableMap.of(IntrospectionResultAssembler.ACTIVE, Boolean.FALSE);
203 model.addAttribute(JsonEntityView.ENTITY, entity);
204 return JsonEntityView.VIEWNAME;
207 return JsonEntityView.VIEWNAME;
static final Logger logger
Definition: IntrospectionEndpoint.java:81
OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue)
UserInfo getByUsernameAndClientId(String username, String clientId)
UserInfoService userInfoService
Definition: IntrospectionEndpoint.java:73
Collection< ResourceSet > getAllForOwnerAndClient(String owner, String authClientId)
ResourceSetService resourceSetService
Definition: IntrospectionEndpoint.java:76
ClientDetailsEntity getClient()
Definition: OAuth2AccessTokenEntity.java:177
IntrospectionResultAssembler introspectionResultAssembler
Definition: IntrospectionEndpoint.java:70
OAuth2TokenEntityService tokenServices
Definition: IntrospectionEndpoint.java:64
ClientDetailsEntity getClient()
Definition: OAuth2RefreshTokenEntity.java:162
ClientDetailsEntity loadClientByClientId(String clientId)
OAuth2AccessTokenEntity readAccessToken(String accessTokenValue)
Map< String, Object > assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
ClientDetailsEntityService clientService
Definition: IntrospectionEndpoint.java:67