use of de.ids_mannheim.korap.oauth2.oltu.OAuth2RevokeTokenSuperRequest in project Kustvakt by KorAP.
the class OAuth2Controller method revokeTokenViaSuperClient.
@POST
@Path("revoke/super")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response revokeTokenViaSuperClient(@Context SecurityContext context, @Context HttpServletRequest request, MultivaluedMap<String, String> form) {
TokenContext tokenContext = (TokenContext) context.getUserPrincipal();
String username = tokenContext.getUsername();
try {
OAuth2RevokeTokenSuperRequest revokeTokenRequest = new OAuth2RevokeTokenSuperRequest(new FormRequestWrapper(request, form));
tokenService.revokeTokensViaSuperClient(username, revokeTokenRequest);
return Response.ok("SUCCESS").build();
} catch (OAuthSystemException e) {
throw responseHandler.throwit(e);
} catch (OAuthProblemException e) {
throw responseHandler.throwit(e);
} catch (KustvaktException e) {
throw responseHandler.throwit(e);
}
}
use of de.ids_mannheim.korap.oauth2.oltu.OAuth2RevokeTokenSuperRequest in project Kustvakt by KorAP.
the class OltuTokenService method revokeTokensViaSuperClient.
public void revokeTokensViaSuperClient(String username, OAuth2RevokeTokenSuperRequest revokeTokenRequest) throws KustvaktException {
String superClientId = revokeTokenRequest.getSuperClientId();
String superClientSecret = revokeTokenRequest.getSuperClientSecret();
OAuth2Client superClient = clientService.authenticateClient(superClientId, superClientSecret);
if (!superClient.isSuper()) {
throw new KustvaktException(StatusCodes.CLIENT_AUTHENTICATION_FAILED);
}
String token = revokeTokenRequest.getToken();
RefreshToken refreshToken = refreshDao.retrieveRefreshToken(token, username);
if (!revokeRefreshToken(refreshToken)) {
AccessToken accessToken = tokenDao.retrieveAccessToken(token, username);
revokeAccessToken(accessToken);
}
}
Aggregations