Search in sources :

Example 1 with ErrorResponse

use of io.getlime.core.rest.model.base.response.ErrorResponse in project powerauth-restful-integration by lime-company.

the class PowerAuthApiAuthenticationEntryPoint method commence.

@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
    ErrorResponse errorResponse = new ErrorResponse(Error.Code.ERROR_GENERIC, "POWER_AUTH_SIGNATURE_INVALID");
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    response.getOutputStream().println(new ObjectMapper().writeValueAsString(errorResponse));
    response.getOutputStream().flush();
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ErrorResponse(io.getlime.core.rest.model.base.response.ErrorResponse)

Example 2 with ErrorResponse

use of io.getlime.core.rest.model.base.response.ErrorResponse in project powerauth-restful-integration by lime-company.

the class PowerAuthExceptionHandler method handleUnauthorizedException.

/**
 * Handle PowerAuthAuthenticationException exceptions.
 * @param ex Exception instance.
 * @return Error response.
 */
@ExceptionHandler(value = PowerAuthAuthenticationException.class)
@ResponseStatus(value = HttpStatus.UNAUTHORIZED)
@ResponseBody
public ErrorResponse handleUnauthorizedException(Exception ex) {
    PowerAuthAuthenticationException paex = (PowerAuthAuthenticationException) ex;
    Logger.getLogger(PowerAuthExceptionHandler.class.getName()).log(Level.SEVERE, paex.getMessage(), paex);
    return new ErrorResponse(paex.getDefaultCode(), paex);
}
Also used : PowerAuthAuthenticationException(io.getlime.security.powerauth.rest.api.base.exception.PowerAuthAuthenticationException) ErrorResponse(io.getlime.core.rest.model.base.response.ErrorResponse) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with ErrorResponse

use of io.getlime.core.rest.model.base.response.ErrorResponse in project powerauth-restful-integration by lime-company.

the class PowerAuthExceptionHandler method handleActivationException.

/**
 * Handle PowerAuthActivationException exceptions.
 * @param ex Exception instance.
 * @return Error response.
 */
@ExceptionHandler(value = PowerAuthActivationException.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorResponse handleActivationException(Exception ex) {
    PowerAuthActivationException paex = (PowerAuthActivationException) ex;
    Logger.getLogger(PowerAuthExceptionHandler.class.getName()).log(Level.SEVERE, paex.getMessage(), paex);
    return new ErrorResponse(paex.getDefaultCode(), paex);
}
Also used : PowerAuthActivationException(io.getlime.security.powerauth.rest.api.base.exception.PowerAuthActivationException) ErrorResponse(io.getlime.core.rest.model.base.response.ErrorResponse) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with ErrorResponse

use of io.getlime.core.rest.model.base.response.ErrorResponse in project powerauth-restful-integration by lime-company.

the class PowerAuthExceptionHandler method handleSecureVaultException.

/**
 * Handle PowerAuthSecureVaultException exceptions.
 * @param ex Exception instance.
 * @return Error response.
 */
@ExceptionHandler(value = PowerAuthSecureVaultException.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorResponse handleSecureVaultException(Exception ex) {
    PowerAuthSecureVaultException paex = (PowerAuthSecureVaultException) ex;
    Logger.getLogger(PowerAuthExceptionHandler.class.getName()).log(Level.SEVERE, paex.getMessage(), paex);
    return new ErrorResponse(paex.getDefaultCode(), paex);
}
Also used : PowerAuthSecureVaultException(io.getlime.security.powerauth.rest.api.base.exception.PowerAuthSecureVaultException) ErrorResponse(io.getlime.core.rest.model.base.response.ErrorResponse) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ErrorResponse (io.getlime.core.rest.model.base.response.ErrorResponse)4 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 PowerAuthActivationException (io.getlime.security.powerauth.rest.api.base.exception.PowerAuthActivationException)1 PowerAuthAuthenticationException (io.getlime.security.powerauth.rest.api.base.exception.PowerAuthAuthenticationException)1 PowerAuthSecureVaultException (io.getlime.security.powerauth.rest.api.base.exception.PowerAuthSecureVaultException)1