mitreid-connect
公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.mitre.oauth2.token.ChainedTokenGranter クラス
org.mitre.oauth2.token.ChainedTokenGranter の継承関係図
Inheritance graph
org.mitre.oauth2.token.ChainedTokenGranter 連携図
Collaboration graph

公開メンバ関数

 ChainedTokenGranter (OAuth2TokenEntityService tokenServices, ClientDetailsEntityService clientDetailsService, OAuth2RequestFactory requestFactory)
 

静的公開変数類

static final String GRANT_TYPE = "urn:ietf:params:oauth:grant_type:redelegate"
 

限定公開メンバ関数

OAuth2Authentication getOAuth2Authentication (ClientDetails client, TokenRequest tokenRequest) throws AuthenticationException, InvalidTokenException
 

非公開変数類

OAuth2TokenEntityService tokenServices
 

詳解

著者
jricher

構築子と解体子

◆ ChainedTokenGranter()

org.mitre.oauth2.token.ChainedTokenGranter.ChainedTokenGranter ( OAuth2TokenEntityService  tokenServices,
ClientDetailsEntityService  clientDetailsService,
OAuth2RequestFactory  requestFactory 
)
inline
引数
tokenServices
clientDetailsService
GRANT_TYPE
60  {
61  super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
63  }
OAuth2TokenEntityService tokenServices
Definition: ChainedTokenGranter.java:52
static final String GRANT_TYPE
Definition: ChainedTokenGranter.java:49

関数詳解

◆ getOAuth2Authentication()

OAuth2Authentication org.mitre.oauth2.token.ChainedTokenGranter.getOAuth2Authentication ( ClientDetails  client,
TokenRequest  tokenRequest 
) throws AuthenticationException, InvalidTokenException
inlineprotected
69  {
70  // read and load up the existing token
71  String incomingTokenValue = tokenRequest.getRequestParameters().get("token");
72  OAuth2AccessTokenEntity incomingToken = tokenServices.readAccessToken(incomingTokenValue);
73 
74  // check for scoping in the request, can't up-scope with a chained request
75  Set<String> approvedScopes = incomingToken.getScope();
76  Set<String> requestedScopes = tokenRequest.getScope();
77 
78  if (requestedScopes == null) {
79  requestedScopes = new HashSet<>();
80  }
81 
82  // do a check on the requested scopes -- if they exactly match the client scopes, they were probably shadowed by the token granter
83  if (client.getScope().equals(requestedScopes)) {
84  requestedScopes = new HashSet<>();
85  }
86 
87  // if our scopes are a valid subset of what's allowed, we can continue
88  if (approvedScopes.containsAll(requestedScopes)) {
89 
90  if (requestedScopes.isEmpty()) {
91  // if there are no scopes, inherit the original scopes from the token
92  tokenRequest.setScope(approvedScopes);
93  } else {
94  // if scopes were asked for, give only the subset of scopes requested
95  // this allows safe downscoping
96  tokenRequest.setScope(Sets.intersection(requestedScopes, approvedScopes));
97  }
98 
99  // NOTE: don't revoke the existing access token
100 
101  // create a new access token
102  OAuth2Authentication authentication = new OAuth2Authentication(getRequestFactory().createOAuth2Request(client, tokenRequest), incomingToken.getAuthenticationHolder().getAuthentication().getUserAuthentication());
103 
104  return authentication;
105 
106  } else {
107  throw new InvalidScopeException("Invalid scope requested in chained request", approvedScopes);
108  }
109 
110  }
OAuth2TokenEntityService tokenServices
Definition: ChainedTokenGranter.java:52
Set< String > getScope()
Definition: OAuth2AccessTokenEntity.java:245
OAuth2AccessTokenEntity readAccessToken(String accessTokenValue)

メンバ詳解

◆ GRANT_TYPE

final String org.mitre.oauth2.token.ChainedTokenGranter.GRANT_TYPE = "urn:ietf:params:oauth:grant_type:redelegate"
static

◆ tokenServices

OAuth2TokenEntityService org.mitre.oauth2.token.ChainedTokenGranter.tokenServices
private

このクラス詳解は次のファイルから抽出されました: