use of uk.gov.ida.hub.policy.contracts.SamlMessageDto in project verify-hub by alphagov.
the class SessionService method getRpErrorResponse.
public AuthnResponseFromHubContainerDto getRpErrorResponse(SessionId sessionId) {
getSessionIfItExists(sessionId);
final ResponseFromHub errorResponseFromHub = authnRequestHandler.getErrorResponseFromHub(sessionId);
final RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto = new RequestForErrorResponseFromHubDto(errorResponseFromHub.getAuthnRequestIssuerEntityId(), errorResponseFromHub.getResponseId(), errorResponseFromHub.getInResponseTo(), errorResponseFromHub.getAssertionConsumerServiceUri(), errorResponseFromHub.getStatus());
final SamlMessageDto samlMessageDto = samlEngineProxy.generateErrorResponseFromHub(requestForErrorResponseFromHubDto);
final AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = new AuthnResponseFromHubContainerDto(samlMessageDto.getSamlMessage(), errorResponseFromHub.getAssertionConsumerServiceUri(), errorResponseFromHub.getRelayState(), errorResponseFromHub.getResponseId());
return authnResponseFromHubContainerDto;
}
use of uk.gov.ida.hub.policy.contracts.SamlMessageDto in project verify-hub by alphagov.
the class SessionServiceTest method sendErrorResponseFromHub_shouldReturnDtoWithSamlRequestPostLocationAndRelayState.
@Test
public void sendErrorResponseFromHub_shouldReturnDtoWithSamlRequestPostLocationAndRelayState() throws Exception {
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
ResponseFromHub responseFromHub = aResponseFromHubDto().withRelayState("relayState").build();
when(authnRequestHandler.getErrorResponseFromHub(sessionId)).thenReturn(responseFromHub);
final SamlMessageDto samlMessageDto = new SamlMessageDto("saml");
when(samlEngineProxy.generateErrorResponseFromHub(any())).thenReturn(samlMessageDto);
AuthnResponseFromHubContainerDto dto = service.getRpErrorResponse(sessionId);
assertThat(dto.getSamlResponse()).isEqualTo(samlMessageDto.getSamlMessage());
assertThat(dto.getPostEndpoint()).isEqualTo(responseFromHub.getAssertionConsumerServiceUri());
assertThat(dto.getRelayState()).isEqualTo(responseFromHub.getRelayState());
assertThat(dto.getResponseId()).isEqualTo(responseFromHub.getResponseId());
}
use of uk.gov.ida.hub.policy.contracts.SamlMessageDto in project verify-hub by alphagov.
the class RpErrorResponseFromHubIntegrationTest method shouldGenerateAnErrorAuthnResponseFromHub.
@Test
public void shouldGenerateAnErrorAuthnResponseFromHub() throws Exception {
final SessionId sessionId = aSessionIsCreated();
SamlMessageDto samlMessageDto = new SamlMessageDto("saml");
samlEngineStub.setUpStubForErrorResponseGenerate(samlMessageDto);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RP_ERROR_RESPONSE_RESOURCE).build(sessionId.getSessionId());
Response response = get(uri);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = response.readEntity(AuthnResponseFromHubContainerDto.class);
assertThat(authnResponseFromHubContainerDto.getSamlResponse()).isEqualTo(samlMessageDto.getSamlMessage());
}
Aggregations