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);
}
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());
}
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));
}
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);
}
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);
}
Aggregations