@POST
public Response revokeAccessToken(@HeaderParam("Authorization") String authorization,
final MultivaluedMap<String, String> formParameters) {
String accessToken;
Client client;
AccessTokenRequest accessTokenRequest = AccessTokenRequest.fromMultiValuedFormParameters(formParameters);
BasicAuthCredentials credentials = getClientCredentials(authorization, accessTokenRequest);
try {
client = validateClient(credentials);
List<String> params = formParameters.get("token");
accessToken = CollectionUtils.isEmpty(params) ? null : params.get(0);
} catch (ValidationResponseException e) {
ValidationResponse validationResponse = e.v;
return Response.status(Status.BAD_REQUEST).entity(new ErrorResponse(validationResponse.getValue(), validationResponse.getDescription())).build();
}
AccessToken token = accessTokenRepository.findByTokenAndClient(accessToken, client);
if (token == null) {
LOG.info("Access token {} not found for client '{}'. Will return OK however.", accessToken, client.getClientId());
return Response.ok().build();
}
accessTokenRepository.delete(token);
return Response.ok().build();
}