Search in sources :

Example 1 with SamlMessageDto

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;
}
Also used : AuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto) SamlMessageDto(uk.gov.ida.hub.policy.contracts.SamlMessageDto) RequestForErrorResponseFromHubDto(uk.gov.ida.hub.policy.contracts.RequestForErrorResponseFromHubDto) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub)

Example 2 with SamlMessageDto

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());
}
Also used : AuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto) AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.builder.AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto) SamlMessageDto(uk.gov.ida.hub.policy.contracts.SamlMessageDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 3 with SamlMessageDto

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());
}
Also used : Response(javax.ws.rs.core.Response) AuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto) SamlMessageDto(uk.gov.ida.hub.policy.contracts.SamlMessageDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Aggregations

AuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto)3 SamlMessageDto (uk.gov.ida.hub.policy.contracts.SamlMessageDto)3 Test (org.junit.Test)2 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)2 SessionId (uk.gov.ida.hub.policy.domain.SessionId)2 URI (java.net.URI)1 Response (javax.ws.rs.core.Response)1 AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.builder.AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto)1 RequestForErrorResponseFromHubDto (uk.gov.ida.hub.policy.contracts.RequestForErrorResponseFromHubDto)1 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)1