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

公開メンバ関数

String getAllAccessTokens (ModelMap m, Principal p)
 
String getAccessTokenById (@PathVariable("id") Long id, ModelMap m, Principal p)
 
String deleteAccessTokenById (@PathVariable("id") Long id, ModelMap m, Principal p)
 
String getAccessTokensByClientId (@PathVariable("clientId") String clientId, ModelMap m, Principal p)
 
String getRegistrationTokenByClientId (@PathVariable("clientId") String clientId, ModelMap m, Principal p)
 
String rotateRegistrationTokenByClientId (@PathVariable("clientId") String clientId, ModelMap m, Principal p)
 
String getAllRefreshTokens (ModelMap m, Principal p)
 
String getRefreshTokenById (@PathVariable("id") Long id, ModelMap m, Principal p)
 
String deleteRefreshTokenById (@PathVariable("id") Long id, ModelMap m, Principal p)
 

静的公開変数類

static final String URL = RootController.API_URL + "/tokens"
 

非公開変数類

OAuth2TokenEntityService tokenService
 
ClientDetailsEntityService clientService
 
OIDCTokenService oidcTokenService
 

静的非公開変数類

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

詳解

REST-ish API for managing access tokens (GET/DELETE only)

著者
Amanda Anganes

関数詳解

◆ deleteAccessTokenById()

String org.mitre.oauth2.web.TokenAPI.deleteAccessTokenById ( @PathVariable("id") Long  id,
ModelMap  m,
Principal  p 
)
inline
103  {
104 
105  OAuth2AccessTokenEntity token = tokenService.getAccessTokenById(id);
106 
107  if (token == null) {
108  logger.error("getToken failed; token not found: " + id);
109  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
110  m.put(JsonErrorView.ERROR_MESSAGE, "The requested token with id " + id + " could not be found.");
111  return JsonErrorView.VIEWNAME;
112  } else if (!token.getAuthenticationHolder().getAuthentication().getName().equals(p.getName())) {
113  logger.error("getToken failed; token does not belong to principal " + p.getName());
114  m.put(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
115  m.put(JsonErrorView.ERROR_MESSAGE, "You do not have permission to view this token");
116  return JsonErrorView.VIEWNAME;
117  } else {
119 
120  return HttpCodeView.VIEWNAME;
121  }
122  }
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
OAuth2AccessTokenEntity getAccessTokenById(Long id)
static final Logger logger
Definition: TokenAPI.java:71
void revokeAccessToken(OAuth2AccessTokenEntity accessToken)

◆ deleteRefreshTokenById()

String org.mitre.oauth2.web.TokenAPI.deleteRefreshTokenById ( @PathVariable("id") Long  id,
ModelMap  m,
Principal  p 
)
inline
226  {
227 
228  OAuth2RefreshTokenEntity token = tokenService.getRefreshTokenById(id);
229 
230  if (token == null) {
231  logger.error("refresh token not found: " + id);
232  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
233  m.put(JsonErrorView.ERROR_MESSAGE, "The requested token with id " + id + " could not be found.");
234  return JsonErrorView.VIEWNAME;
235  } else if (!token.getAuthenticationHolder().getAuthentication().getName().equals(p.getName())) {
236  logger.error("refresh token " + id + " does not belong to principal " + p.getName());
237  m.put(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
238  m.put(JsonErrorView.ERROR_MESSAGE, "You do not have permission to view this token");
239  return JsonErrorView.VIEWNAME;
240  } else {
242 
243  return HttpCodeView.VIEWNAME;
244  }
245  }
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
OAuth2RefreshTokenEntity getRefreshTokenById(Long id)
void revokeRefreshToken(OAuth2RefreshTokenEntity refreshToken)
static final Logger logger
Definition: TokenAPI.java:71

◆ getAccessTokenById()

String org.mitre.oauth2.web.TokenAPI.getAccessTokenById ( @PathVariable("id") Long  id,
ModelMap  m,
Principal  p 
)
inline
82  {
83 
84  OAuth2AccessTokenEntity token = tokenService.getAccessTokenById(id);
85 
86  if (token == null) {
87  logger.error("getToken failed; token not found: " + id);
88  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
89  m.put(JsonErrorView.ERROR_MESSAGE, "The requested token with id " + id + " could not be found.");
90  return JsonErrorView.VIEWNAME;
91  } else if (!token.getAuthenticationHolder().getAuthentication().getName().equals(p.getName())) {
92  logger.error("getToken failed; token does not belong to principal " + p.getName());
93  m.put(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
94  m.put(JsonErrorView.ERROR_MESSAGE, "You do not have permission to view this token");
95  return JsonErrorView.VIEWNAME;
96  } else {
97  m.put(JsonEntityView.ENTITY, token);
98  return TokenApiView.VIEWNAME;
99  }
100  }
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
OAuth2AccessTokenEntity getAccessTokenById(Long id)
static final Logger logger
Definition: TokenAPI.java:71

◆ getAccessTokensByClientId()

String org.mitre.oauth2.web.TokenAPI.getAccessTokensByClientId ( @PathVariable("clientId") String  clientId,
ModelMap  m,
Principal  p 
)
inline
126  {
127 
128  ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
129 
130  if (client != null) {
131  List<OAuth2AccessTokenEntity> tokens = tokenService.getAccessTokensForClient(client);
132  m.put(JsonEntityView.ENTITY, tokens);
133  return TokenApiView.VIEWNAME;
134  } else {
135  // client not found
136  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
137  m.put(JsonErrorView.ERROR_MESSAGE, "The requested client with id " + clientId + " could not be found.");
138  return JsonErrorView.VIEWNAME;
139  }
140 
141  }
List< OAuth2AccessTokenEntity > getAccessTokensForClient(ClientDetailsEntity client)
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
ClientDetailsEntity loadClientByClientId(String clientId)
ClientDetailsEntityService clientService
Definition: TokenAPI.java:63

◆ getAllAccessTokens()

String org.mitre.oauth2.web.TokenAPI.getAllAccessTokens ( ModelMap  m,
Principal  p 
)
inline
74  {
75 
76  Set<OAuth2AccessTokenEntity> allTokens = tokenService.getAllAccessTokensForUser(p.getName());
77  m.put(JsonEntityView.ENTITY, allTokens);
78  return TokenApiView.VIEWNAME;
79  }
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
Set< OAuth2AccessTokenEntity > getAllAccessTokensForUser(String name)

◆ getAllRefreshTokens()

String org.mitre.oauth2.web.TokenAPI.getAllRefreshTokens ( ModelMap  m,
Principal  p 
)
inline
195  {
196 
197  Set<OAuth2RefreshTokenEntity> allTokens = tokenService.getAllRefreshTokensForUser(p.getName());
198  m.put(JsonEntityView.ENTITY, allTokens);
199  return TokenApiView.VIEWNAME;
200 
201 
202  }
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
Set< OAuth2RefreshTokenEntity > getAllRefreshTokensForUser(String name)

◆ getRefreshTokenById()

String org.mitre.oauth2.web.TokenAPI.getRefreshTokenById ( @PathVariable("id") Long  id,
ModelMap  m,
Principal  p 
)
inline
205  {
206 
207  OAuth2RefreshTokenEntity token = tokenService.getRefreshTokenById(id);
208 
209  if (token == null) {
210  logger.error("refresh token not found: " + id);
211  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
212  m.put(JsonErrorView.ERROR_MESSAGE, "The requested token with id " + id + " could not be found.");
213  return JsonErrorView.VIEWNAME;
214  } else if (!token.getAuthenticationHolder().getAuthentication().getName().equals(p.getName())) {
215  logger.error("refresh token " + id + " does not belong to principal " + p.getName());
216  m.put(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
217  m.put(JsonErrorView.ERROR_MESSAGE, "You do not have permission to view this token");
218  return JsonErrorView.VIEWNAME;
219  } else {
220  m.put(JsonEntityView.ENTITY, token);
221  return TokenApiView.VIEWNAME;
222  }
223  }
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
OAuth2RefreshTokenEntity getRefreshTokenById(Long id)
static final Logger logger
Definition: TokenAPI.java:71

◆ getRegistrationTokenByClientId()

String org.mitre.oauth2.web.TokenAPI.getRegistrationTokenByClientId ( @PathVariable("clientId") String  clientId,
ModelMap  m,
Principal  p 
)
inline
145  {
146 
147  ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
148 
149  if (client != null) {
150  OAuth2AccessTokenEntity token = tokenService.getRegistrationAccessTokenForClient(client);
151  if (token != null) {
152  m.put(JsonEntityView.ENTITY, token);
153  return TokenApiView.VIEWNAME;
154  } else {
155  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
156  m.put(JsonErrorView.ERROR_MESSAGE, "No registration token could be found.");
157  return JsonErrorView.VIEWNAME;
158  }
159  } else {
160  // client not found
161  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
162  m.put(JsonErrorView.ERROR_MESSAGE, "The requested client with id " + clientId + " could not be found.");
163  return JsonErrorView.VIEWNAME;
164  }
165 
166  }
OAuth2AccessTokenEntity getRegistrationAccessTokenForClient(ClientDetailsEntity client)
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
ClientDetailsEntity loadClientByClientId(String clientId)
ClientDetailsEntityService clientService
Definition: TokenAPI.java:63

◆ rotateRegistrationTokenByClientId()

String org.mitre.oauth2.web.TokenAPI.rotateRegistrationTokenByClientId ( @PathVariable("clientId") String  clientId,
ModelMap  m,
Principal  p 
)
inline
170  {
171  ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
172 
173  if (client != null) {
174  OAuth2AccessTokenEntity token = oidcTokenService.rotateRegistrationAccessTokenForClient(client);
175  token = tokenService.saveAccessToken(token);
176 
177  if (token != null) {
178  m.put(JsonEntityView.ENTITY, token);
179  return TokenApiView.VIEWNAME;
180  } else {
181  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
182  m.put(JsonErrorView.ERROR_MESSAGE, "No registration token could be found.");
183  return JsonErrorView.VIEWNAME;
184  }
185  } else {
186  // client not found
187  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
188  m.put(JsonErrorView.ERROR_MESSAGE, "The requested client with id " + clientId + " could not be found.");
189  return JsonErrorView.VIEWNAME;
190  }
191 
192  }
OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity accessToken)
OAuth2TokenEntityService tokenService
Definition: TokenAPI.java:60
OAuth2AccessTokenEntity rotateRegistrationAccessTokenForClient(ClientDetailsEntity client)
ClientDetailsEntity loadClientByClientId(String clientId)
ClientDetailsEntityService clientService
Definition: TokenAPI.java:63
OIDCTokenService oidcTokenService
Definition: TokenAPI.java:66

メンバ詳解

◆ clientService

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

◆ logger

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

Logger for this class

◆ oidcTokenService

OIDCTokenService org.mitre.oauth2.web.TokenAPI.oidcTokenService
private

◆ tokenService

OAuth2TokenEntityService org.mitre.oauth2.web.TokenAPI.tokenService
private

◆ URL

final String org.mitre.oauth2.web.TokenAPI.URL = RootController.API_URL + "/tokens"
static

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