Search in sources :

Example 1 with AuthenticationErrorResponse

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

the class AuthnResponseFromIdpService method handleCancelResponse.

private ResponseAction handleCancelResponse(InboundResponseFromIdpDto idaResponseFromIdp, SessionId sessionId, String principalIPAddressAsSeenByHub, IdpSelectedStateController idpSelectedStateController) {
    AuthenticationErrorResponse noAuthenticationContextErrorResponse = new AuthenticationErrorResponse(idaResponseFromIdp.getIssuer(), principalIPAddressAsSeenByHub);
    idpSelectedStateController.handleNoAuthenticationContextResponseFromIdp(noAuthenticationContextErrorResponse);
    return cancel(sessionId, idpSelectedStateController.isRegistrationContext());
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse)

Example 2 with AuthenticationErrorResponse

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

the class AuthnResponseFromIdpService method handleNoAuthnContextResponse.

private ResponseAction handleNoAuthnContextResponse(InboundResponseFromIdpDto idaResponseFromIdp, SessionId sessionId, String principalIPAddressAsSeenByHub, IdpSelectedStateController idpSelectedStateController) {
    AuthenticationErrorResponse noAuthenticationContextErrorResponse = new AuthenticationErrorResponse(idaResponseFromIdp.getIssuer(), principalIPAddressAsSeenByHub);
    idpSelectedStateController.handleNoAuthenticationContextResponseFromIdp(noAuthenticationContextErrorResponse);
    return other(sessionId, idpSelectedStateController.isRegistrationContext());
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse)

Example 3 with AuthenticationErrorResponse

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

the class IdpSelectedStateControllerTest method handleAuthnFailedResponseFromIdp_shouldLogEvent.

@Test
public void handleAuthnFailedResponseFromIdp_shouldLogEvent() {
    AuthenticationErrorResponse authenticationErrorResponse = anAuthenticationErrorResponse().withIssuerId(IDP_ENTITY_ID).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    controller.handleAuthenticationFailedResponseFromIdp(authenticationErrorResponse);
    verify(hubEventLogger).logIdpAuthnFailedEvent(NEW_SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) Test(org.junit.Test)

Example 4 with AuthenticationErrorResponse

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

the class AuthnResponseFromIdpServiceTest method verifyIdpStateControllerIsCalledWithRightDataOnNonFraudAuthenticationFailed.

private void verifyIdpStateControllerIsCalledWithRightDataOnNonFraudAuthenticationFailed(InboundResponseFromIdpDto authenticationFailedResponse) {
    ArgumentCaptor<AuthenticationErrorResponse> captor = ArgumentCaptor.forClass(AuthenticationErrorResponse.class);
    AuthenticationErrorResponse expectedAuthenticationErrorResponse = anAuthenticationErrorResponse().withIssuerId(authenticationFailedResponse.getIssuer()).withPrincipalIpAddressAsSeenByHub(samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub()).build();
    verify(idpSelectedStateController).handleAuthenticationFailedResponseFromIdp(captor.capture());
    AuthenticationErrorResponse actualAuthenticationErrorResponse = captor.getValue();
    assertThat(actualAuthenticationErrorResponse).isEqualToIgnoringGivenFields(expectedAuthenticationErrorResponse);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse)

Example 5 with AuthenticationErrorResponse

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

the class AuthnResponseFromIdpServiceTest method verifyIdpStateControllerIsCalledWithRightDataOnNonFraudNoAuthenticationContext.

private void verifyIdpStateControllerIsCalledWithRightDataOnNonFraudNoAuthenticationContext(InboundResponseFromIdpDto noAuthenticationContext) {
    ArgumentCaptor<AuthenticationErrorResponse> captor = ArgumentCaptor.forClass(AuthenticationErrorResponse.class);
    AuthenticationErrorResponse expectedAuthenticationErrorResponse = anAuthenticationErrorResponse().withIssuerId(noAuthenticationContext.getIssuer()).withPrincipalIpAddressAsSeenByHub(samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub()).build();
    verify(idpSelectedStateController).handleNoAuthenticationContextResponseFromIdp(captor.capture());
    AuthenticationErrorResponse actualAuthenticationErrorResponse = captor.getValue();
    assertThat(actualAuthenticationErrorResponse).isEqualToIgnoringGivenFields(expectedAuthenticationErrorResponse);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse)

Aggregations

AuthenticationErrorResponse (uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse)13 AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse (uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse)9 Test (org.junit.Test)7 AuthnFailedErrorState (uk.gov.ida.hub.policy.domain.state.AuthnFailedErrorState)2 SessionStartedState (uk.gov.ida.hub.policy.domain.state.SessionStartedState)2 IdpSelectedStateBuilder.anIdpSelectedState (uk.gov.ida.hub.policy.builder.state.IdpSelectedStateBuilder.anIdpSelectedState)1 State (uk.gov.ida.hub.policy.domain.State)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 FraudEventDetectedState (uk.gov.ida.hub.policy.domain.state.FraudEventDetectedState)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1 PausedRegistrationState (uk.gov.ida.hub.policy.domain.state.PausedRegistrationState)1