Search in sources :

Example 1 with TokenRemoveResponse

use of io.getlime.security.powerauth.rest.api.model.response.v3.TokenRemoveResponse in project powerauth-restful-integration by lime-company.

the class TokenService method removeToken.

/**
 * Remove token.
 *
 * @param request        Remove token request.
 * @param authentication PowerAuth API authentication object.
 * @return Remove token response.
 * @throws PowerAuthAuthenticationException In case authentication fails.
 */
public TokenRemoveResponse removeToken(TokenRemoveRequest request, PowerAuthApiAuthentication authentication) throws PowerAuthAuthenticationException {
    try {
        // Fetch activation ID
        final String activationId = authentication.getActivationContext().getActivationId();
        // Fetch token ID from the request
        final String tokenId = request.getTokenId();
        // Remove a token, ignore response, since the endpoint should quietly return
        powerAuthClient.removeToken(tokenId, activationId);
        // Prepare a response
        final TokenRemoveResponse response = new TokenRemoveResponse();
        response.setTokenId(tokenId);
        return response;
    } catch (Exception ex) {
        logger.warn("Removing PowerAuth token failed, error: {}", ex.getMessage());
        logger.debug(ex.getMessage(), ex);
        throw new PowerAuthTokenErrorException();
    }
}
Also used : PowerAuthTokenErrorException(io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthTokenErrorException) PowerAuthTokenErrorException(io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthTokenErrorException) PowerAuthAuthenticationException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthAuthenticationException) PowerAuthSignatureTypeInvalidException(io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthSignatureTypeInvalidException) TokenRemoveResponse(io.getlime.security.powerauth.rest.api.model.response.v3.TokenRemoveResponse)

Aggregations

TokenRemoveResponse (io.getlime.security.powerauth.rest.api.model.response.v3.TokenRemoveResponse)1 PowerAuthAuthenticationException (io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthAuthenticationException)1 PowerAuthSignatureTypeInvalidException (io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthSignatureTypeInvalidException)1 PowerAuthTokenErrorException (io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthTokenErrorException)1