Search in sources :

Example 1 with PersistentId

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

the class AuthnResponseFromIdpService method handleSuccessResponse.

private ResponseAction handleSuccessResponse(InboundResponseFromIdpDto inboundResponseFromIdpDto, SessionId sessionId, String principalIPAddressAsSeenByHub, IdpSelectedStateController idpSelectedStateController) {
    LevelOfAssurance loaAchieved = inboundResponseFromIdpDto.getLevelOfAssurance().get();
    SuccessFromIdp successFromIdp = new SuccessFromIdp(inboundResponseFromIdpDto.getIssuer(), inboundResponseFromIdpDto.getEncryptedMatchingDatasetAssertion().get(), inboundResponseFromIdpDto.getAuthnStatementAssertionBlob().get(), new PersistentId(inboundResponseFromIdpDto.getPersistentId().get()), loaAchieved, principalIPAddressAsSeenByHub, inboundResponseFromIdpDto.getPrincipalIpAddressAsSeenByIdp());
    AttributeQueryRequestDto attributeQuery = idpSelectedStateController.createAttributeQuery(successFromIdp);
    idpSelectedStateController.handleSuccessResponseFromIdp(successFromIdp);
    attributeQueryService.sendAttributeQueryRequest(sessionId, attributeQuery);
    return success(sessionId, idpSelectedStateController.isRegistrationContext(), loaAchieved);
}
Also used : LevelOfAssurance(uk.gov.ida.hub.policy.domain.LevelOfAssurance) SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) AttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId)

Example 2 with PersistentId

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

the class AuthnResponseFromIdpService method handleFraudResponse.

private ResponseAction handleFraudResponse(InboundResponseFromIdpDto inboundResponseFromIdpDto, SessionId sessionId, String principalIPAddressAsSeenByHub, IdpSelectedStateController idpSelectedStateController) {
    FraudFromIdp fraudFromIdp = new FraudFromIdp(inboundResponseFromIdpDto.getIssuer(), principalIPAddressAsSeenByHub, new PersistentId(inboundResponseFromIdpDto.getPersistentId().get()), new FraudDetectedDetails(inboundResponseFromIdpDto.getIdpFraudEventId().get(), inboundResponseFromIdpDto.getFraudIndicator().get()), inboundResponseFromIdpDto.getPrincipalIpAddressAsSeenByIdp());
    idpSelectedStateController.handleFraudResponseFromIdp(fraudFromIdp);
    return other(sessionId, idpSelectedStateController.isRegistrationContext());
}
Also used : FraudFromIdp(uk.gov.ida.hub.policy.domain.FraudFromIdp) FraudDetectedDetails(uk.gov.ida.hub.policy.domain.FraudDetectedDetails) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId)

Example 3 with PersistentId

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

the class EidasAttributeQueryRequestDtoBuilderTest method build.

@Test
public void build() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("attribute", "attributeValue");
    EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto().build();
    assertThat(eidasAttributeQueryRequestDto.getRequestId()).isEqualTo("requestId");
    assertThat(eidasAttributeQueryRequestDto.getPersistentId()).isEqualTo(new PersistentId("nameId"));
    assertThat(eidasAttributeQueryRequestDto.getEncryptedIdentityAssertion()).isEqualTo("encryptedIdentityAssertion");
    assertThat(eidasAttributeQueryRequestDto.getAssertionConsumerServiceUri()).isEqualTo(URI.create("assertionConsumerServiceUri"));
    assertThat(eidasAttributeQueryRequestDto.getAuthnRequestIssuerEntityId()).isEqualTo("authnRequestIssuesEntityId");
    assertThat(eidasAttributeQueryRequestDto.getLevelOfAssurance()).isEqualTo(LevelOfAssurance.LEVEL_2);
    assertThat(eidasAttributeQueryRequestDto.getAttributeQueryUri()).isEqualTo(URI.create("matchingServiceAdapterUri"));
    assertThat(eidasAttributeQueryRequestDto.getMatchingServiceEntityId()).isEqualTo("matchingServiceAdapterEntityId");
    assertThat(eidasAttributeQueryRequestDto.getMatchingServiceRequestTimeOut()).isEqualTo(DateTime.now().plusHours(1));
    assertThat(eidasAttributeQueryRequestDto.isOnboarding()).isTrue();
    assertThat(eidasAttributeQueryRequestDto.getCycle3Dataset()).isEqualTo(Optional.of(new Cycle3Dataset(map)));
    assertThat(eidasAttributeQueryRequestDto.getUserAccountCreationAttributes()).isEqualTo(Optional.absent());
    assertThat(eidasAttributeQueryRequestDto.getAssertionExpiry()).isEqualTo(DateTime.now().plusHours(2));
}
Also used : Cycle3Dataset(uk.gov.ida.hub.policy.domain.Cycle3Dataset) HashMap(java.util.HashMap) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) Test(org.junit.Test)

Example 4 with PersistentId

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

the class IdpSelectedStateControllerTest method shouldThrowUnauditedErrorExceptionIfTheResponseIsFromADifferentIssuer.

@Test(expected = StateProcessingValidationException.class)
public void shouldThrowUnauditedErrorExceptionIfTheResponseIsFromADifferentIssuer() {
    PersistentId persistentId = aPersistentId().withNameId("idname").build();
    SuccessFromIdp successFromIdp = aSuccessFromIdp().withIssuerId("differentIDP").withPersistentId(persistentId).withPrincipalIpAddressSeenByIdp(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).withLevelOfAssurance(PROVIDED_LOA).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(asList(IDP_ENTITY_ID, "differentIDP"));
    controller.handleSuccessResponseFromIdp(successFromIdp);
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) SuccessFromIdpBuilder.aSuccessFromIdp(uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) PersistentIdBuilder.aPersistentId(uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId) Test(org.junit.Test)

Example 5 with PersistentId

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

the class IdpSelectedStateControllerTest method handleSuccessResponseFromIdp_shouldTransitionToCycle0And1MatchRequestSentState.

@Test
public void handleSuccessResponseFromIdp_shouldTransitionToCycle0And1MatchRequestSentState() {
    ArgumentCaptor<Cycle0And1MatchRequestSentState> stateArgumentCaptor = ArgumentCaptor.forClass(Cycle0And1MatchRequestSentState.class);
    PersistentId persistentId = aPersistentId().withNameId("idname").build();
    final String encryptedMatchingDatasetAssertion = "blah";
    SuccessFromIdp successFromIdp = aSuccessFromIdp().withIssuerId(IDP_ENTITY_ID).withPersistentId(persistentId).withPrincipalIpAddressSeenByIdp(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).withLevelOfAssurance(PROVIDED_LOA).withEncryptedMatchingDatasetAssertion(encryptedMatchingDatasetAssertion).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new org.joda.time.Duration(600L));
    when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(anIdpConfigDto().withLevelsOfAssurance(LEVELS_OF_ASSURANCE).build());
    controller.handleSuccessResponseFromIdp(successFromIdp);
    verify(stateTransitionAction).transitionTo(stateArgumentCaptor.capture());
    assertThat(stateArgumentCaptor.getValue()).isInstanceOf(Cycle0And1MatchRequestSentState.class);
    assertThat(stateArgumentCaptor.getValue().getEncryptedMatchingDatasetAssertion()).isEqualTo(encryptedMatchingDatasetAssertion);
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) SuccessFromIdpBuilder.aSuccessFromIdp(uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) PersistentIdBuilder.aPersistentId(uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId) Test(org.junit.Test)

Aggregations

PersistentId (uk.gov.ida.hub.policy.domain.PersistentId)13 Test (org.junit.Test)8 SuccessFromIdp (uk.gov.ida.hub.policy.domain.SuccessFromIdp)6 PersistentIdBuilder.aPersistentId (uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId)4 SuccessFromIdpBuilder.aSuccessFromIdp (uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp)4 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 EidasAttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto)2 FraudDetectedDetails (uk.gov.ida.hub.policy.domain.FraudDetectedDetails)2 FraudFromIdp (uk.gov.ida.hub.policy.domain.FraudFromIdp)2 HashMap (java.util.HashMap)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 MatchingServiceConfigEntityDataDto (uk.gov.ida.hub.policy.contracts.MatchingServiceConfigEntityDataDto)1 Cycle3Dataset (uk.gov.ida.hub.policy.domain.Cycle3Dataset)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 EidasAwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState)1 EidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState)1 EidasCycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle3MatchRequestSentState)1