if (resourceServer == null || !resourceServer.getSecret().equals(credentials.getPassword())) {
LOG.warn("For access token {}: Resource server not found for credentials {}. Responding with 401 in VerifyResource#verifyToken.", accessToken, credentials);
return unauthorized();
}
AccessToken token = accessTokenRepository.findByToken(accessToken);
if (token == null || !resourceServer.containsClient(token.getClient())) {
LOG.warn("Access token {} not found for resource server '{}'. Responding with 404 in VerifyResource#verifyToken for user {}", accessToken, resourceServer.getName(), credentials);
return Response.status(Status.NOT_FOUND).entity(new VerifyTokenResponse("not_found")).build();
}
if (tokenExpired(token)) {
LOG.warn("Token {} is expired. Responding with 410 in VerifyResource#verifyToken for user {}", accessToken, credentials);
return Response.status(Status.GONE).entity(new VerifyTokenResponse("token_expired")).build();
}
final VerifyTokenResponse verifyTokenResponse = new VerifyTokenResponse(token.getClient().getName(),
token.getScopes(), token.getPrincipal(), token.getExpires());
if (LOG.isDebugEnabled()) {
LOG.debug("Responding with 200 in VerifyResource#verifyToken for access token {} and user {}", accessToken, credentials);
}
return Response.ok(mapper.writeValueAsString(verifyTokenResponse)).build();