use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class HubEventLoggerTest method logIdpSelectedEvent_shouldLogEventWithIdpSelected.
@Test
public void logIdpSelectedEvent_shouldLogEventWithIdpSelected() {
final IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withLevelsOfAssurance(Arrays.asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2)).withSessionExpiryTimestamp(SESSION_EXPIRY_TIMESTAMP).withIdpEntityId(IDP_ENTITY_ID).withRequestIssuerEntityId(TRANSACTION_ENTITY_ID).withRequestId(REQUEST_ID).withSessionId(SESSION_ID).build();
eventLogger.logIdpSelectedEvent(state, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(session_event_type, IDP_SELECTED);
details.put(idp_entity_id, IDP_ENTITY_ID);
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(details);
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class SessionResourceIntegrationTest method shouldReturnOkWhenGeneratingIdpAuthnRequestFromHubIsSuccessfulOnSignIn.
@Test
public void shouldReturnOkWhenGeneratingIdpAuthnRequestFromHubIsSuccessfulOnSignIn() throws Exception {
// Given
final SamlRequestDto samlRequestDto = new SamlRequestDto("coffee-pasta", idpSsoUri);
samlEngineStub.setupStubForIdpAuthnRequestGenerate(samlRequestDto);
configStub.setupStubForEnabledIdps(rpEntityId, false, REQUESTED_LOA, singletonList(idpEntityId));
SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForSignIn(sessionId, idpEntityId);
final AuthnRequestFromHubContainerDto expectedResult = anAuthnRequestFromHubContainerDtoWithRegistering(samlRequestDto, false);
// When
AuthnRequestFromHubContainerDto result = getEntity(UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_REQUEST_RESOURCE).build(sessionId), AuthnRequestFromHubContainerDto.class);
// Then
assertThat(result).isEqualToComparingFieldByField(expectedResult);
IdpSelectedState sessionState = policy.getSessionState(sessionId, IdpSelectedState.class);
assertThat(sessionState.getMatchingServiceEntityId()).isEqualTo(msEntityId);
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class IdpSelector method buildIdpSelectedState.
public static IdpSelectedState buildIdpSelectedState(IdpSelectingState state, String idpEntityId, boolean registering, LevelOfAssurance requestedLoa, TransactionsConfigProxy transactionsConfigProxy, IdentityProvidersConfigProxy identityProvidersConfigProxy) {
List<LevelOfAssurance> levelsOfAssuranceForTransaction = transactionsConfigProxy.getLevelsOfAssurance(state.getRequestIssuerEntityId());
if (!levelsOfAssuranceForTransaction.contains(requestedLoa)) {
throw StateProcessingValidationException.requestedLevelOfAssuranceUnsupportedByTransactionEntity(state.getRequestIssuerEntityId(), levelsOfAssuranceForTransaction, requestedLoa);
}
List<String> availableIdentityProviderEntityIdsForLoa = identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), registering, requestedLoa);
checkValidIdentityProvider(idpEntityId, availableIdentityProviderEntityIdsForLoa, state);
IdpConfigDto idpConfig = identityProvidersConfigProxy.getIdpConfig(idpEntityId);
final List<LevelOfAssurance> idpLevelsOfAssurance = idpConfig.getSupportedLevelsOfAssurance();
List<LevelOfAssurance> levelsOfAssuranceForTransactionSupportedByIdp = levelsOfAssuranceForTransaction.stream().filter(idpLevelsOfAssurance::contains).collect(Collectors.toList());
String matchingServiceEntityId = transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId());
return new IdpSelectedState(state.getRequestId(), idpEntityId, matchingServiceEntityId, levelsOfAssuranceForTransactionSupportedByIdp, idpConfig.getUseExactComparisonType(), state.getForceAuthentication().orNull(), state.getAssertionConsumerServiceUri(), state.getRequestIssuerEntityId(), state.getRelayState().orNull(), state.getSessionExpiryTimestamp(), registering, requestedLoa, state.getSessionId(), availableIdentityProviderEntityIdsForLoa, state.getTransactionSupportsEidas());
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class SessionStartedStateController method handleIdpSelected.
@Override
public void handleIdpSelected(final String idpEntityId, final String principalIpAddress, boolean registering, LevelOfAssurance requestedLoa) {
IdpSelectedState idpSelectedState = IdpSelector.buildIdpSelectedState(state, idpEntityId, registering, requestedLoa, transactionsConfigProxy, identityProvidersConfigProxy);
stateTransitionAction.transitionTo(idpSelectedState);
hubEventLogger.logIdpSelectedEvent(idpSelectedState, principalIpAddress);
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class IdpSelectedStateControllerTest method idpSelectedStateBuilder.
private IdpSelectedStateController idpSelectedStateBuilder(boolean isRegistration) {
idpSelectedState = anIdpSelectedState().withSessionId(NEW_SESSION_ID).withIdpEntityId(IDP_ENTITY_ID).withRequestId(REQUEST_ID).withLevelsOfAssurance(LEVELS_OF_ASSURANCE).withSessionExpiryTimestamp(SESSION_EXPIRY_TIMESTAMP).withRegistration(isRegistration).withTransactionSupportsEidas(true).build();
IdpSelectedState state = idpSelectedState;
String matchingServiceEntityId = "matching-service-entity-id";
when(transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId())).thenReturn(matchingServiceEntityId);
when(matchingServiceConfigProxy.getMatchingService(matchingServiceEntityId)).thenReturn(aMatchingServiceConfigEntityDataDto().withUri(ATTRIBUTE_QUERY_URI).build());
return new IdpSelectedStateController(state, hubEventLogger, stateTransitionAction, identityProvidersConfigProxy, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionsFactory, matchingServiceConfigProxy);
}
Aggregations