"{\"error\":\"Only basic authentication is supported by TokenAuthRealm\"}", e);
}
- // if the password is empty, this is an OAuth2 request, not a Basic HTTP Auth request
if (!Strings.isNullOrEmpty(password)) {
Map<String, List<String>> headers = HeaderUtils.formHeaders(username, password, domain);
// iterate over <code>TokenAuth</code> implementations and
}
}
- // extract the authentication token and attempt validation of the token
- final String token = TokenUtils.extractUsername(authenticationToken);
- try {
- final Authentication auth = validate(token);
- final ODLPrincipal odlPrincipal = ODLPrincipalImpl.createODLPrincipal(auth);
- return new SimpleAuthenticationInfo(odlPrincipal, "", getName());
- } catch (AuthenticationException e) {
- LOG.debug("Unknown OAuth2 Token Access Request", e);
- }
-
LOG.debug("Authentication failed: exhausted TokenAuth resources");
return null;
}
-
- private Authentication validate(final String token) {
- if (tokenStore == null) {
- throw new AuthenticationException("Token store not available, could not validate the token " + token);
- }
-
- final Authentication auth = tokenStore.get(token);
- if (auth == null) {
- throw new AuthenticationException("Could not validate the token " + token);
- }
- authService.set(auth);
- return auth;
- }
}