Search in sources :

Example 1 with OAuth2RevokeTokenRequest

use of de.ids_mannheim.korap.oauth2.oltu.OAuth2RevokeTokenRequest in project Kustvakt by KorAP.

the class OAuth2Controller method revokeAccessToken.

/**
 * Revokes either an access token or a refresh token. Revoking a
 * refresh token also revokes all access token associated with the
 * refresh token.
 *
 * RFC 7009
 * Client authentication for confidential client
 *
 * @param request
 * @param form
 *            containing
 *            client_id,
 *            client_secret (required for confidential clients),
 *            token,
 *            token_type (optional)
 * @return 200 if token invalidation is successful or the given
 *         token is invalid
 */
@POST
@Path("revoke")
@ResourceFilters({ APIVersionFilter.class })
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response revokeAccessToken(@Context HttpServletRequest request, MultivaluedMap<String, String> form) {
    try {
        OAuth2RevokeTokenRequest revokeTokenRequest = new OAuth2RevokeTokenRequest(new FormRequestWrapper(request, form));
        tokenService.revokeToken(revokeTokenRequest);
        return Response.ok("SUCCESS").build();
    } catch (OAuthProblemException e) {
        throw responseHandler.throwit(e);
    } catch (OAuthSystemException e) {
        throw responseHandler.throwit(e);
    } catch (KustvaktException e) {
        throw responseHandler.throwit(e);
    }
}
Also used : OAuthProblemException(org.apache.oltu.oauth2.common.exception.OAuthProblemException) FormRequestWrapper(de.ids_mannheim.korap.web.utils.FormRequestWrapper) KustvaktException(de.ids_mannheim.korap.exceptions.KustvaktException) OAuthSystemException(org.apache.oltu.oauth2.common.exception.OAuthSystemException) OAuth2RevokeTokenRequest(de.ids_mannheim.korap.oauth2.oltu.OAuth2RevokeTokenRequest) Path(javax.ws.rs.Path) ResourceFilters(com.sun.jersey.spi.container.ResourceFilters) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

ResourceFilters (com.sun.jersey.spi.container.ResourceFilters)1 KustvaktException (de.ids_mannheim.korap.exceptions.KustvaktException)1 OAuth2RevokeTokenRequest (de.ids_mannheim.korap.oauth2.oltu.OAuth2RevokeTokenRequest)1 FormRequestWrapper (de.ids_mannheim.korap.web.utils.FormRequestWrapper)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)1 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)1