gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService クラス
org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService 連携図
Collaboration graph

公開メンバ関数

Response introspectGet (@HeaderParam("Authorization") String p_authorization, @QueryParam("token") String p_token, @QueryParam("token_type_hint") String tokenTypeHint)
 
Response introspectPost (@HeaderParam("Authorization") String p_authorization, @FormParam("token") String p_token, @FormParam("token_type_hint") String tokenTypeHint)
 

非公開メンバ関数

Response introspect (String p_authorization, String p_token, String tokenTypeHint)
 
AuthorizationGrant getAuthorizationGrant (String authorization, String accessToken) throws UnsupportedEncodingException
 

非公開変数類

Logger log
 
AppConfiguration appConfiguration
 
TokenService tokenService
 
ErrorResponseFactory errorResponseFactory
 
AuthorizationGrantList authorizationGrantList
 
ClientService clientService
 

詳解

著者
Yuriy Zabrovarnyy
バージョン
June 30, 2018

関数詳解

◆ getAuthorizationGrant()

AuthorizationGrant org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.getAuthorizationGrant ( String  authorization,
String  accessToken 
) throws UnsupportedEncodingException
inlineprivate
152  {
153  AuthorizationGrant grant = tokenService.getAuthorizationGrantByPrefix(authorization, "Bearer ");
154  if (grant != null) {
155  final String authorizationAccessToken = authorization.substring("Bearer ".length());
156  final AbstractToken accessTokenObject = grant.getAccessToken(authorizationAccessToken);
157  if (accessTokenObject != null && accessTokenObject.isValid()) {
158  return grant;
159  } else {
160  log.error("Access token is not valid: " + authorizationAccessToken);
161  return null;
162  }
163  }
164 
165  grant = tokenService.getAuthorizationGrantByPrefix(authorization, "Basic ");
166  if (grant != null) {
167  return grant;
168  }
169  if (StringUtils.startsWithIgnoreCase(authorization, "Basic ")) {
170 
171  String encodedCredentials = authorization.substring("Basic ".length());
172 
173  String token = new String(Base64.decodeBase64(encodedCredentials), Util.UTF8_STRING_ENCODING);
174 
175  int delim = token.indexOf(":");
176 
177  if (delim != -1) {
178  String clientId = URLDecoder.decode(token.substring(0, delim), Util.UTF8_STRING_ENCODING);
179  String password = URLDecoder.decode(token.substring(delim + 1), Util.UTF8_STRING_ENCODING);
180  if (clientService.authenticate(clientId, password)) {
181  final AuthorizationGrant grantOfIntrospectionToken = authorizationGrantList.getAuthorizationGrantByAccessToken(accessToken);
182  if (grantOfIntrospectionToken != null) {
183  if (!grantOfIntrospectionToken.getClientId().equals(clientId)) {
184  log.trace("Failed to match grant object clientId and client id provided during authentication.");
185  return null;
186  }
188  }
189  } else {
190  log.trace("Failed to perform basic authentication for client: " + clientId);
191  }
192 
193  }
194  }
195  return grant;
196  }
AuthorizationGrantList authorizationGrantList
Definition: IntrospectionWebService.java:67
AuthorizationGrant getAuthorizationGrantByPrefix(String authorization, String prefix)
Definition: TokenService.java:47
Logger log
Definition: IntrospectionWebService.java:59
boolean authenticate(String clientId, String password)
Definition: ClientService.java:107
AbstractToken getAccessToken(String tokenCode)
Definition: AbstractAuthorizationGrant.java:445
ClientService clientService
Definition: IntrospectionWebService.java:69
TokenService tokenService
Definition: IntrospectionWebService.java:63
AuthorizationGrant getAuthorizationGrantByAccessToken(String accessToken)
Definition: AuthorizationGrantList.java:166

◆ introspect()

Response org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.introspect ( String  p_authorization,
String  p_token,
String  tokenTypeHint 
)
inlineprivate
93  {
94  try {
95  log.trace("Introspect token, authorization: {}, token to introsppect: {}, tokenTypeHint:", p_authorization, p_token, tokenTypeHint);
96  if (StringUtils.isNotBlank(p_authorization) && StringUtils.isNotBlank(p_token)) {
97  final AuthorizationGrant authorizationGrant = getAuthorizationGrant(p_authorization, p_token);
98  if (authorizationGrant != null) {
99  final AbstractToken authorizationAccessToken = authorizationGrant.getAccessToken(tokenService.getTokenFromAuthorizationParameter(p_authorization));
100 
101  if (authorizationAccessToken != null && authorizationAccessToken.isValid()) {
102  if (ServerUtil.isTrue(appConfiguration.getIntrospectionAccessTokenMustHaveUmaProtectionScope())) { // #562 - make uma_protection optional
103  if (!authorizationGrant.getScopesAsString().contains(UmaScopeType.PROTECTION.getValue())) {
104  log.trace("access_token used to access introspection endpoint does not has uma_protection scope, however in oxauth configuration `checkUmaProtectionScopePresenceDuringIntrospection` is true");
105  return Response.status(Response.Status.UNAUTHORIZED).entity(errorResponseFactory.getErrorAsJson(AuthorizeErrorResponseType.ACCESS_DENIED) + " access_token does not have uma_protection scope which is required by OP configuration.").build();
106  }
107  }
108  final IntrospectionResponse response = new IntrospectionResponse(false);
109 
110  final AuthorizationGrant grantOfIntrospectionToken = authorizationGrantList.getAuthorizationGrantByAccessToken(p_token);
111  if (grantOfIntrospectionToken != null) {
112  final AbstractToken tokenToIntrospect = grantOfIntrospectionToken.getAccessToken(p_token);
113  final User user = grantOfIntrospectionToken.getUser();
114 
115  response.setActive(tokenToIntrospect.isValid());
116  response.setExpiresAt(ServerUtil.dateToSeconds(tokenToIntrospect.getExpirationDate()));
117  response.setIssuedAt(ServerUtil.dateToSeconds(tokenToIntrospect.getCreationDate()));
118  response.setAcrValues(grantOfIntrospectionToken.getAcrValues());
119  response.setScope(grantOfIntrospectionToken.getScopes() != null ? grantOfIntrospectionToken.getScopes() : new ArrayList<String>()); // #433
120  response.setClientId(grantOfIntrospectionToken.getClientId());
121  response.setSub(grantOfIntrospectionToken.getSub());
122  response.setUsername(user != null ? user.getAttribute("displayName") : null);
123  response.setIssuer(appConfiguration.getIssuer());
124  response.setAudience(grantOfIntrospectionToken.getClientId());
125 
126  if (tokenToIntrospect instanceof AccessToken) {
127  AccessToken accessToken = (AccessToken) tokenToIntrospect;
128  response.setTokenType(accessToken.getTokenType() != null ? accessToken.getTokenType().getName() : TokenType.BEARER.getName());
129  }
130  } else {
131  log.error("Failed to find grant for access_token: " + p_token);
132  return Response.status(Response.Status.BAD_REQUEST).entity(errorResponseFactory.getErrorAsJson(AuthorizeErrorResponseType.INVALID_REQUEST)).build();
133  }
134  return Response.status(Response.Status.OK).entity(ServerUtil.asJson(response)).build();
135  } else {
136  log.error("Access token is not valid. Valid: " + (authorizationAccessToken != null && authorizationAccessToken.isValid()));
137  return Response.status(Response.Status.UNAUTHORIZED).entity(errorResponseFactory.getErrorAsJson(AuthorizeErrorResponseType.ACCESS_DENIED)).build();
138  }
139  } else {
140  log.error("Authorization grant is null.");
141  return Response.status(Response.Status.UNAUTHORIZED).entity(errorResponseFactory.getErrorAsJson(AuthorizeErrorResponseType.ACCESS_DENIED)).build();
142  }
143  }
144  } catch (Exception e) {
145  log.error(e.getMessage(), e);
146  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
147  }
148 
149  return Response.status(Response.Status.BAD_REQUEST).entity(errorResponseFactory.getErrorAsJson(AuthorizeErrorResponseType.INVALID_REQUEST)).build();
150  }
AppConfiguration appConfiguration
Definition: IntrospectionWebService.java:61
String getErrorAsJson(IErrorType p_type)
Definition: ErrorResponseFactory.java:86
AuthorizationGrant getAuthorizationGrant(String authorization, String accessToken)
Definition: IntrospectionWebService.java:152
AuthorizationGrantList authorizationGrantList
Definition: IntrospectionWebService.java:67
Logger log
Definition: IntrospectionWebService.java:59
String getTokenFromAuthorizationParameter(String authorizationParameter)
Definition: TokenService.java:30
AbstractToken getAccessToken(String tokenCode)
Definition: AbstractAuthorizationGrant.java:445
Boolean getIntrospectionAccessTokenMustHaveUmaProtectionScope()
Definition: AppConfiguration.java:213
String getIssuer()
Definition: AppConfiguration.java:274
TokenService tokenService
Definition: IntrospectionWebService.java:63
ErrorResponseFactory errorResponseFactory
Definition: IntrospectionWebService.java:65
AuthorizationGrant getAuthorizationGrantByAccessToken(String accessToken)
Definition: AuthorizationGrantList.java:166

◆ introspectGet()

Response org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.introspectGet ( @HeaderParam("Authorization") String  p_authorization,
@QueryParam("token") String  p_token,
@QueryParam("token_type_hint") String  tokenTypeHint 
)
inline
81  {
82  return introspect(p_authorization, p_token, tokenTypeHint);
83  }
Response introspect(String p_authorization, String p_token, String tokenTypeHint)
Definition: IntrospectionWebService.java:93

◆ introspectPost()

Response org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.introspectPost ( @HeaderParam("Authorization") String  p_authorization,
@FormParam("token") String  p_token,
@FormParam("token_type_hint") String  tokenTypeHint 
)
inline
89  {
90  return introspect(p_authorization, p_token, tokenTypeHint);
91  }
Response introspect(String p_authorization, String p_token, String tokenTypeHint)
Definition: IntrospectionWebService.java:93

メンバ詳解

◆ appConfiguration

AppConfiguration org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.appConfiguration
private

◆ authorizationGrantList

AuthorizationGrantList org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.authorizationGrantList
private

◆ clientService

ClientService org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.clientService
private

◆ errorResponseFactory

ErrorResponseFactory org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.errorResponseFactory
private

◆ log

Logger org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.log
private

◆ tokenService

TokenService org.xdi.oxauth.introspection.ws.rs.IntrospectionWebService.tokenService
private

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