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

静的公開変数類

static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code"
 

限定公開メンバ関数

 DeviceTokenGranter (AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory)
 
OAuth2Authentication getOAuth2Authentication (ClientDetails client, TokenRequest tokenRequest)
 

非公開変数類

DeviceCodeService deviceCodeService
 

詳解

Implements https://tools.ietf.org/html/draft-ietf-oauth-device-flow

参照
DeviceEndpoint
著者
jricher

構築子と解体子

◆ DeviceTokenGranter()

org.mitre.oauth2.token.DeviceTokenGranter.DeviceTokenGranter ( AuthorizationServerTokenServices  tokenServices,
ClientDetailsService  clientDetailsService,
OAuth2RequestFactory  requestFactory 
)
inlineprotected
引数
tokenServices
clientDetailsService
requestFactory
grantType
59  {
60  super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
61  }
static final String GRANT_TYPE
Definition: DeviceTokenGranter.java:48

関数詳解

◆ getOAuth2Authentication()

OAuth2Authentication org.mitre.oauth2.token.DeviceTokenGranter.getOAuth2Authentication ( ClientDetails  client,
TokenRequest  tokenRequest 
)
inlineprotected
67  {
68 
69  String deviceCode = tokenRequest.getRequestParameters().get("device_code");
70 
71  // look up the device code and consume it
72  DeviceCode dc = deviceCodeService.findDeviceCode(deviceCode, client);
73 
74  if (dc != null) {
75 
76  // make sure the code hasn't expired yet
77  if (dc.getExpiration() != null && dc.getExpiration().before(new Date())) {
78 
79  deviceCodeService.clearDeviceCode(deviceCode, client);
80 
81  throw new DeviceCodeExpiredException("Device code has expired " + deviceCode);
82 
83  } else if (!dc.isApproved()) {
84 
85  // still waiting for approval
86  throw new AuthorizationPendingException("Authorization pending for code " + deviceCode);
87 
88  } else {
89  // inherit the (approved) scopes from the original request
90  tokenRequest.setScope(dc.getScope());
91 
92  OAuth2Authentication auth = new OAuth2Authentication(getRequestFactory().createOAuth2Request(client, tokenRequest), dc.getAuthenticationHolder().getUserAuth());
93 
94  deviceCodeService.clearDeviceCode(deviceCode, client);
95 
96  return auth;
97  }
98  } else {
99  throw new InvalidGrantException("Invalid device code: " + deviceCode);
100  }
101 
102  }
void clearDeviceCode(String deviceCode, ClientDetails client)
DeviceCodeService deviceCodeService
Definition: DeviceTokenGranter.java:51
DeviceCode findDeviceCode(String deviceCode, ClientDetails client)

メンバ詳解

◆ deviceCodeService

DeviceCodeService org.mitre.oauth2.token.DeviceTokenGranter.deviceCodeService
private

◆ GRANT_TYPE

final String org.mitre.oauth2.token.DeviceTokenGranter.GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code"
static

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