Search in sources :

Example 1 with ResponseFromHub

use of uk.gov.ida.hub.policy.domain.ResponseFromHub 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 ResponseFromHub

use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.

the class SessionService method getRpAuthnResponse.

public AuthnResponseFromHubContainerDto getRpAuthnResponse(SessionId sessionId) {
    getSessionIfItExists(sessionId);
    ResponseFromHub responseFromHub = authnRequestHandler.getResponseFromHub(sessionId);
    return samlEngineProxy.generateRpAuthnResponse(responseFromHub);
}
Also used : ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub)

Example 3 with ResponseFromHub

use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.

the class Cycle0And1MatchRequestSentStateControllerTest method shouldReturnErrorResponseWhenAskedAndInCycle0And1MatchRequestSentState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInCycle0And1MatchRequestSentState() {
    final ResponseFromHub responseFromHub = controller.getErrorResponse();
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 4 with ResponseFromHub

use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, responseFromHubFactory, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
    final ResponseFromHub responseFromHub = controller.getErrorResponse();
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 5 with ResponseFromHub

use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.

the class EidasAwaitingCycle3DataStateControllerTest method getErrorResponse.

@Test
public void getErrorResponse() throws Exception {
    when(idGenerator.getId()).thenReturn(RESPONSE_ID);
    ResponseFromHub expectedResponse = new ResponseFromHub(RESPONSE_ID, state.getRequestId(), state.getRequestIssuerEntityId(), Optional.absent(), Optional.of("relayState"), URI.create("assertionConsumerServiceUri"), TransactionIdaStatus.NoAuthenticationContext);
    ResponseFromHub actualResponse = controller.getErrorResponse();
    assertThat(actualResponse).isEqualTo(expectedResponse);
}
Also used : ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Aggregations

ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)27 Test (org.junit.Test)25 StateController (uk.gov.ida.hub.policy.domain.StateController)16 SessionId (uk.gov.ida.hub.policy.domain.SessionId)5 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto)3 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)3 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)3 Matchers.anyString (org.mockito.Matchers.anyString)2 AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.builder.AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto)2 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)2 SamlMessageDto (uk.gov.ida.hub.policy.contracts.SamlMessageDto)2 RequestForErrorResponseFromHubDto (uk.gov.ida.hub.policy.contracts.RequestForErrorResponseFromHubDto)1 EidasCountryDto (uk.gov.ida.hub.policy.domain.EidasCountryDto)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 AuthnFailedErrorState (uk.gov.ida.hub.policy.domain.state.AuthnFailedErrorState)1 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 Cycle3DataInputCancelledState (uk.gov.ida.hub.policy.domain.state.Cycle3DataInputCancelledState)1 FraudEventDetectedState (uk.gov.ida.hub.policy.domain.state.FraudEventDetectedState)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1