mitreid-connect
公開メンバ関数 | 静的公開変数類 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.mitre.oauth2.web.RevocationEndpoint クラス
org.mitre.oauth2.web.RevocationEndpoint 連携図
Collaboration graph

公開メンバ関数

String revoke (@RequestParam("token") String tokenValue, @RequestParam(value="token_type_hint", required=false) String tokenType, Authentication auth, Model model)
 

静的公開変数類

static final String URL = "revoke"
 

非公開変数類

ClientDetailsEntityService clientService
 
OAuth2TokenEntityService tokenServices
 

静的非公開変数類

static final Logger logger = LoggerFactory.getLogger(RevocationEndpoint.class)
 

詳解

関数詳解

◆ revoke()

String org.mitre.oauth2.web.RevocationEndpoint.revoke ( @RequestParam("token") String  tokenValue,
@RequestParam(value="token_type_hint", required=false) String  tokenType,
Authentication  auth,
Model  model 
)
inline
59  {
60 
61  // This is the token as passed in from OAuth (in case we need it some day)
62  //OAuth2AccessTokenEntity tok = tokenServices.getAccessToken((OAuth2Authentication) principal);
63 
64  ClientDetailsEntity authClient = null;
65 
66  if (auth instanceof OAuth2Authentication) {
67  // the client authenticated with OAuth, do our UMA checks
68  ensureOAuthScope(auth, SystemScopeService.UMA_PROTECTION_SCOPE);
69  // get out the client that was issued the access token (not the token being revoked)
70  OAuth2Authentication o2a = (OAuth2Authentication) auth;
71 
72  String authClientId = o2a.getOAuth2Request().getClientId();
73  authClient = clientService.loadClientByClientId(authClientId);
74 
75  // the owner is the user who authorized the token in the first place
76  String ownerId = o2a.getUserAuthentication().getName();
77 
78  } else {
79  // the client authenticated directly, make sure it's got the right access
80 
81  String authClientId = auth.getName(); // direct authentication puts the client_id into the authentication's name field
82  authClient = clientService.loadClientByClientId(authClientId);
83 
84  }
85 
86  try {
87  // check and handle access tokens first
88 
89  OAuth2AccessTokenEntity accessToken = tokenServices.readAccessToken(tokenValue);
90 
91  // client acting on its own, make sure it owns the token
92  if (!accessToken.getClient().getClientId().equals(authClient.getClientId())) {
93  // trying to revoke a token we don't own, throw a 403
94 
95  logger.info("Client " + authClient.getClientId() + " tried to revoke a token owned by " + accessToken.getClient().getClientId());
96 
97  model.addAttribute(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
98  return HttpCodeView.VIEWNAME;
99  }
100 
101  // if we got this far, we're allowed to do this
102  tokenServices.revokeAccessToken(accessToken);
103 
104  logger.debug("Client " + authClient.getClientId() + " revoked access token " + tokenValue);
105 
106  model.addAttribute(HttpCodeView.CODE, HttpStatus.OK);
107  return HttpCodeView.VIEWNAME;
108 
109  } catch (InvalidTokenException e) {
110 
111  // access token wasn't found, check the refresh token
112 
113  try {
114  OAuth2RefreshTokenEntity refreshToken = tokenServices.getRefreshToken(tokenValue);
115  // client acting on its own, make sure it owns the token
116  if (!refreshToken.getClient().getClientId().equals(authClient.getClientId())) {
117  // trying to revoke a token we don't own, throw a 403
118 
119  logger.info("Client " + authClient.getClientId() + " tried to revoke a token owned by " + refreshToken.getClient().getClientId());
120 
121  model.addAttribute(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
122  return HttpCodeView.VIEWNAME;
123  }
124 
125  // if we got this far, we're allowed to do this
126  tokenServices.revokeRefreshToken(refreshToken);
127 
128  logger.debug("Client " + authClient.getClientId() + " revoked access token " + tokenValue);
129 
130  model.addAttribute(HttpCodeView.CODE, HttpStatus.OK);
131  return HttpCodeView.VIEWNAME;
132 
133  } catch (InvalidTokenException e1) {
134 
135  // neither token type was found, simply say "OK" and be on our way.
136 
137  logger.debug("Failed to revoke token " + tokenValue);
138 
139  model.addAttribute(HttpCodeView.CODE, HttpStatus.OK);
140  return HttpCodeView.VIEWNAME;
141  }
142  }
143  }
OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue)
OAuth2TokenEntityService tokenServices
Definition: RevocationEndpoint.java:48
ClientDetailsEntityService clientService
Definition: RevocationEndpoint.java:45
static final Logger logger
Definition: RevocationEndpoint.java:53
ClientDetailsEntity loadClientByClientId(String clientId)
void revokeRefreshToken(OAuth2RefreshTokenEntity refreshToken)
OAuth2AccessTokenEntity readAccessToken(String accessTokenValue)
void revokeAccessToken(OAuth2AccessTokenEntity accessToken)

メンバ詳解

◆ clientService

ClientDetailsEntityService org.mitre.oauth2.web.RevocationEndpoint.clientService
private

◆ logger

final Logger org.mitre.oauth2.web.RevocationEndpoint.logger = LoggerFactory.getLogger(RevocationEndpoint.class)
staticprivate

Logger for this class

◆ tokenServices

OAuth2TokenEntityService org.mitre.oauth2.web.RevocationEndpoint.tokenServices
private

◆ URL

final String org.mitre.oauth2.web.RevocationEndpoint.URL = "revoke"
static

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