use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class MatchingServiceHealthChecker method performHealthCheck.
public MatchingServiceHealthCheckResult performHealthCheck(final MatchingServiceConfigEntityDataDto configEntity) {
MatchingServiceHealthCheckerRequestDto matchingServiceHealthCheckerRequestDto = new MatchingServiceHealthCheckerRequestDto(configEntity.getTransactionEntityId(), configEntity.getEntityId());
MatchingServiceHealthCheckResponseDto responseDto;
try {
SamlMessageDto samlMessageDto = samlEngineProxy.generateHealthcheckAttributeQuery(matchingServiceHealthCheckerRequestDto);
final Element matchingServiceHealthCheckRequest = XmlUtils.convertToElement(samlMessageDto.getSamlMessage());
validateRequestSignature(matchingServiceHealthCheckRequest);
responseDto = matchingServiceHealthCheckClient.sendHealthCheckRequest(matchingServiceHealthCheckRequest, configEntity.getUri());
return buildMatchingServiceHealthCheckResult(configEntity, responseDto.getResponse());
} catch (ApplicationException e) {
final String message = format("Saml-engine was unable to generate saml to send to MSA: {0}", e);
eventLogger.logException(e, message);
return logAndCreateUnhealthyResponse(configEntity, message);
} catch (ParserConfigurationException | SAXException | IOException e) {
final String message = format("Unable to convert saml request to XML element: {0}", e);
return logAndCreateUnhealthyResponse(configEntity, message);
}
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class MatchingServiceResponseService method handleSuccessResponse.
public void handleSuccessResponse(SessionId sessionId, SamlResponseDto samlResponse) {
getSessionIfItExists(sessionId);
SamlResponseContainerDto samlResponseContainer = new SamlResponseContainerDto(samlResponse.getSamlResponse(), sessionRepository.getRequestIssuerEntityId(sessionId));
try {
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = samlEngineProxy.translateMatchingServiceResponse(samlResponseContainer);
updateSessionState(sessionId, inboundResponseFromMatchingServiceDto);
} catch (ApplicationException e) {
// this is not ideal but if the call to saml-proxy fails we want to log the failure
// in the state and then process the exception
logExceptionAndUpdateState("Error translating matching service response", sessionId, e);
}
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class PolicyApplicationExceptionMapperTest method toResponse_shouldNotAuditIfEventIsAlreadyAudited.
@Test
public void toResponse_shouldNotAuditIfEventIsAlreadyAudited() {
ApplicationException exception = createAuditedException(ExceptionType.IDP_DISABLED, UUID.randomUUID());
mapper.toResponse(exception);
verifyNoInteractions(eventLogger);
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method toResponse_shouldReturnAuditedErrorResponseWhenExceptionHasBeenAuditedAlready.
@Test
public void toResponse_shouldReturnAuditedErrorResponseWhenExceptionHasBeenAuditedAlready() throws Exception {
ApplicationException applicationException = createAuditedException(ExceptionType.INVALID_SAML, UUID.randomUUID());
final Response response = samlEngineExceptionMapper.toResponse(applicationException);
final ErrorStatusDto entity = (ErrorStatusDto) response.getEntity();
assertThat(entity.isAudited()).isTrue();
checkLogLevel(applicationException.getExceptionType().getLevel());
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method toResponse_shouldReturnUnauditedErrorResponseWhenExceptionHasNotBeenAudited.
@Test
public void toResponse_shouldReturnUnauditedErrorResponseWhenExceptionHasNotBeenAudited() throws Exception {
ApplicationException applicationException = createUnauditedExceptionThatShouldNotBeAudited();
final Response response = samlEngineExceptionMapper.toResponse(applicationException);
final ErrorStatusDto entity = (ErrorStatusDto) response.getEntity();
assertThat(entity.isAudited()).isEqualTo(false);
checkLogLevel(applicationException.getExceptionType().getLevel());
}
Aggregations