use of uk.gov.ida.hub.samlengine.domain.SamlMessageDto in project verify-hub by alphagov.
the class RpErrorResponseGeneratorService method generate.
public SamlMessageDto generate(RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto) {
try {
final OutboundResponseFromHub response = new OutboundResponseFromHub(requestForErrorResponseFromHubDto.getResponseId(), requestForErrorResponseFromHubDto.getInResponseTo(), hubEntityId, DateTime.now(), TransactionIdaStatus.valueOf(requestForErrorResponseFromHubDto.getStatus().name()), empty(), requestForErrorResponseFromHubDto.getAssertionConsumerServiceUri());
final String errorResponse = outboundResponseFromHubToResponseTransformerFactory.get(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId()).apply(response);
return new SamlMessageDto(errorResponse);
} catch (Exception e) {
throw new UnableToGenerateSamlException("Unable to generate RP error response", e, Level.ERROR);
}
}
use of uk.gov.ida.hub.samlengine.domain.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthcheckResponseTranslatorResourceTest method should_shouldReturnErrorStatusDtoWhenThereIsAProblem.
@Test
public void should_shouldReturnErrorStatusDtoWhenThereIsAProblem() throws Exception {
Response response = postResponseForTranslation(new SamlMessageDto(Base64.encodeAsString("<saml/>")));
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto entity = response.readEntity(ErrorStatusDto.class);
assertThat(entity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.hub.samlengine.domain.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthcheckRequestGeneratorResourceTest method should_createHealthcheckAttributeQueryRequest.
@Test
public void should_createHealthcheckAttributeQueryRequest() throws Exception {
configStub.setupCertificatesForEntity(TEST_RP_MS);
Response response = getAttributeQuery(new MatchingServiceHealthCheckerRequestDto(TEST_RP, TEST_RP_MS));
SamlMessageDto entity = response.readEntity(SamlMessageDto.class);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(entity.getSamlMessage()).isNotNull();
}
use of uk.gov.ida.hub.samlengine.domain.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthcheckResponseTranslatorResourceTest method should_translateHealthcheckAttributeQueryResponse.
@Test
public void should_translateHealthcheckAttributeQueryResponse() throws Exception {
final String msaStatusCode = SamlStatusCode.HEALTHY;
final Status status = aStatus().withStatusCode(aStatusCode().withSubStatusCode(aStatusCode().withValue(msaStatusCode).build()).withValue(StatusCode.SUCCESS).build()).build();
final String requestId = "requestId";
final String saml = aValidMatchResponseFromMatchingService(requestId, status, DateTime.now().plusHours(1));
Response response = postResponseForTranslation(new SamlMessageDto(Base64.encodeAsString(saml)));
MatchingServiceHealthCheckerResponseDto entity = response.readEntity(MatchingServiceHealthCheckerResponseDto.class);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(entity.getStatus()).isEqualTo(MatchingServiceIdaStatus.Healthy);
assertThat(entity.getInResponseTo()).isEqualTo(requestId);
assertThat(entity.getIssuer()).isEqualTo(TEST_RP_MS);
}
use of uk.gov.ida.hub.samlengine.domain.SamlMessageDto in project verify-hub by alphagov.
the class RpErrorResponseGeneratorResourceTest method shouldGenerateAnErrorResponseForAnRp.
@Test
public void shouldGenerateAnErrorResponseForAnRp() throws JsonProcessingException {
RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto = aRequestForErrorResponseFromHubDto().build();
configStub.signResponsesAndUseSamlStandard(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId());
final URI uri = samlEngineAppRule.getUri(Urls.SamlEngineUrls.GENERATE_RP_ERROR_RESPONSE_RESOURCE);
Response rpAuthnResponse = post(requestForErrorResponseFromHubDto, uri);
assertThat(rpAuthnResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
SamlMessageDto samlMessageDto = rpAuthnResponse.readEntity(SamlMessageDto.class);
assertThat(samlMessageDto.getSamlMessage()).isNotNull();
}
Aggregations