Search in sources :

Example 1 with ErrorStatusDto

use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.

the class SamlMessageReceiverApiResourceTest method assertError.

private void assertError(final Response response, final ExceptionType exceptionType) {
    assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
    ErrorStatusDto entity = response.readEntity(ErrorStatusDto.class);
    assertThat(entity.getErrorId()).isNotNull();
    assertThat(entity.getExceptionType()).isEqualTo(exceptionType);
}
Also used : ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto)

Example 2 with ErrorStatusDto

use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.

the class EidasNotSupportedExceptionMapper method handleException.

@Override
public Response handleException(EidasNotSupportedException exception) {
    UUID errorId = UUID.randomUUID();
    LOG.warn(LogFormatter.formatLog(errorId, exception.getMessage()), exception);
    eventLogger.logErrorEvent(errorId, getSessionId().or(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
    ErrorStatusDto entity = ErrorStatusDto.createAuditedErrorStatus(errorId, ExceptionType.EIDAS_DISABLED, exception.getMessage());
    return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
}
Also used : ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID)

Example 3 with ErrorStatusDto

use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.

the class EidasCountryNotSupportedExceptionMapper method handleException.

@Override
public Response handleException(EidasCountryNotSupportedException exception) {
    UUID errorId = UUID.randomUUID();
    LOG.warn(LogFormatter.formatLog(errorId, exception.getMessage()), exception);
    eventLogger.logErrorEvent(errorId, getSessionId().or(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
    ErrorStatusDto entity = ErrorStatusDto.createAuditedErrorStatus(errorId, ExceptionType.EIDAS_COUNTRY_NOT_SUPPORTED, exception.getMessage());
    return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
}
Also used : ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID)

Example 4 with ErrorStatusDto

use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.

the class StateProcessingValidationExceptionMapper method handleException.

@Override
public Response handleException(StateProcessingValidationException exception) {
    UUID errorId = UUID.randomUUID();
    LOG.log(exception.getLevel(), exception, errorId);
    eventLogger.logErrorEvent(errorId, getSessionId().orElse(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
    ErrorStatusDto entity = createUnauditedErrorStatus(errorId, STATE_PROCESSING_VALIDATION);
    return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE).entity(entity).build();
}
Also used : ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID)

Example 5 with ErrorStatusDto

use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.

the class InvalidSessionStateExceptionMapper method handleException.

@Override
public Response handleException(InvalidSessionStateException exception) {
    UUID errorId = UUID.randomUUID();
    LOG.warn(LogFormatter.formatLog(errorId, exception.getMessage()), exception);
    eventLogger.logErrorEvent(errorId, getSessionId().orElse(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
    ExceptionType type = getExceptionType(exception);
    ErrorStatusDto entity = ErrorStatusDto.createAuditedErrorStatus(errorId, type, exception.getMessage());
    return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
}
Also used : ExceptionType(uk.gov.ida.common.ExceptionType) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID)

Aggregations

ErrorStatusDto (uk.gov.ida.common.ErrorStatusDto)78 Response (javax.ws.rs.core.Response)69 Test (org.junit.jupiter.api.Test)66 SamlAuthnResponseTranslatorDto (uk.gov.ida.hub.samlengine.contracts.SamlAuthnResponseTranslatorDto)17 SamlAuthnResponseTranslatorDtoBuilder.aSamlAuthnResponseTranslatorDto (uk.gov.ida.integrationtest.hub.samlengine.builders.SamlAuthnResponseTranslatorDtoBuilder.aSamlAuthnResponseTranslatorDto)17 UUID (java.util.UUID)13 SamlTransformationErrorException (uk.gov.ida.saml.core.validation.SamlTransformationErrorException)7 ApplicationException (uk.gov.ida.exceptions.ApplicationException)6 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)6 SamlResponseContainerDto (uk.gov.ida.hub.samlengine.domain.SamlResponseContainerDto)5 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)3 Status (org.opensaml.saml.saml2.core.Status)3 SamlRequestWithAuthnRequestInformationDto (uk.gov.ida.hub.samlengine.contracts.SamlRequestWithAuthnRequestInformationDto)3 StatusBuilder.aStatus (uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus)3 SamlDuplicateRequestIdException (uk.gov.ida.saml.hub.exception.SamlDuplicateRequestIdException)3 MatchingServiceIdaStatus (uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 ExceptionType (uk.gov.ida.common.ExceptionType)2 IdpSelected (uk.gov.ida.hub.policy.domain.IdpSelected)2 SamlRequestTooOldException (uk.gov.ida.saml.hub.exception.SamlRequestTooOldException)2