71 String incomingTokenValue = tokenRequest.getRequestParameters().get(
"token");
75 Set<String> approvedScopes = incomingToken.
getScope();
76 Set<String> requestedScopes = tokenRequest.getScope();
78 if (requestedScopes == null) {
79 requestedScopes =
new HashSet<>();
83 if (client.getScope().equals(requestedScopes)) {
84 requestedScopes =
new HashSet<>();
88 if (approvedScopes.containsAll(requestedScopes)) {
90 if (requestedScopes.isEmpty()) {
92 tokenRequest.setScope(approvedScopes);
96 tokenRequest.setScope(Sets.intersection(requestedScopes, approvedScopes));
102 OAuth2Authentication authentication =
new OAuth2Authentication(getRequestFactory().createOAuth2Request(client, tokenRequest), incomingToken.getAuthenticationHolder().getAuthentication().getUserAuthentication());
104 return authentication;
107 throw new InvalidScopeException(
"Invalid scope requested in chained request", approvedScopes);
OAuth2TokenEntityService tokenServices
Definition: ChainedTokenGranter.java:52
Set< String > getScope()
Definition: OAuth2AccessTokenEntity.java:245
OAuth2AccessTokenEntity readAccessToken(String accessTokenValue)