use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class PolicyExceptionMapper method getSessionId.
protected Optional<SessionId> getSessionId() {
// Are there any uris in Policy that contain the session id as a query string rather than as part of the path or is this just here coz it was copied from shared-rest ?
String parameter = httpServletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM);
if (Strings.isNullOrEmpty(parameter)) {
parameter = httpServletRequest.getParameter(Urls.SharedUrls.RELAY_STATE_PARAM);
}
if (Strings.isNullOrEmpty(parameter)) {
MultivaluedMap<String, String> pathParameters = uriInfo.getPathParameters();
parameter = pathParameters.getFirst(Urls.SharedUrls.SESSION_ID_PARAM);
}
if (Strings.isNullOrEmpty(parameter)) {
return Optional.absent();
} else {
return Optional.fromNullable(new SessionId(parameter));
}
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class CountriesService method setSelectedCountry.
public void setSelectedCountry(SessionId sessionId, String countryCode) {
ensureTransactionSupportsEidas(sessionId);
List<EidasCountryDto> supportedCountries = getCountries(sessionId);
Optional<EidasCountryDto> selectedCountry = supportedCountries.stream().filter(country -> country.getSimpleId().equals(countryCode)).findFirst();
if (!selectedCountry.isPresent()) {
throw new EidasCountryNotSupportedException(sessionId, countryCode);
}
Class<? extends State> expectedStateClass = SessionStartedState.class;
if (sessionRepository.isSessionInState(sessionId, CountrySelectedState.class)) {
expectedStateClass = CountrySelectedState.class;
}
CountrySelectingStateController countrySelectingStateController = (CountrySelectingStateController) sessionRepository.getStateController(sessionId, expectedStateClass);
countrySelectingStateController.selectCountry(selectedCountry.get().getEntityId());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class AuthnRequestFromTransactionHandlerTest method stateControllerInvokedFromSessionRepositoryForselectedIdp.
@Test
public void stateControllerInvokedFromSessionRepositoryForselectedIdp() {
SessionId sessionId = new SessionId("aSessionId");
IdpSelected idpSelected = new IdpSelected(IDP_ENTITY_ID, PRINCIPAL_IP_ADDRESS, REGISTERING, REQUESTED_LOA);
IdpSelectingStateControllerSpy idpSelectingStateController = new IdpSelectingStateControllerSpy();
when(sessionRepository.getStateController(sessionId, IdpSelectingState.class)).thenReturn((idpSelectingStateController));
authnRequestFromTransactionHandler.selectIdpForGivenSessionId(sessionId, idpSelected);
assertThat(idpSelectingStateController.idpEntityId()).isEqualTo(IDP_ENTITY_ID);
assertThat(idpSelectingStateController.principalIpAddress()).isEqualTo(PRINCIPAL_IP_ADDRESS);
assertThat(idpSelectingStateController.registering()).isEqualTo(REGISTERING);
assertThat(idpSelectingStateController.getRequestedLoa()).isEqualTo(REQUESTED_LOA);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class AwaitingCycle3DataStateControllerTest method cycle3dataInputCancelledFromFrontEnd_shouldLogCancellation.
@Test
public void cycle3dataInputCancelledFromFrontEnd_shouldLogCancellation() throws Exception {
final String requestId = "requestId";
final SessionId sessionId = aSessionId().build();
final AwaitingCycle3DataStateController awaitingCycle3DataStateController = setUpAwaitingCycle3DataStateController(requestId, sessionId);
awaitingCycle3DataStateController.handleCancellation();
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy, atLeastOnce()).logHubEvent(argumentCaptor.capture());
Condition<EventSinkHubEvent> combinedConditions = AllOf.allOf(hasSessionId(sessionId), hasDetail(EventDetailsKey.session_event_type, CYCLE3_CANCEL), hasDetail(EventDetailsKey.request_id, requestId));
assertThat(argumentCaptor.getAllValues()).haveAtLeast(1, combinedConditions);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class CountrySelectedStateControllerTest method shouldTransitionToEidasCycle0And1MatchRequestSentState.
@Test
public void shouldTransitionToEidasCycle0And1MatchRequestSentState() {
final String ipAddress = "ip-address";
when(transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId())).thenReturn(MSA_ID);
EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = anEidasAttributeQueryRequestDto().build();
EidasCycle0And1MatchRequestSentState eidasCycle0And1MatchRequestSentState = new EidasCycle0And1MatchRequestSentState(state.getRequestId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getAssertionConsumerServiceUri(), new SessionId(state.getSessionId().getSessionId()), state.getTransactionSupportsEidas(), COUNTRY_ENTITY_ID, state.getRelayState().orNull(), eidasAttributeQueryRequestDto.getLevelOfAssurance(), MSA_ID, eidasAttributeQueryRequestDto.getEncryptedIdentityAssertion(), eidasAttributeQueryRequestDto.getPersistentId());
controller.transitionToEidasCycle0And1MatchRequestSentState(eidasAttributeQueryRequestDto, ipAddress, COUNTRY_ENTITY_ID);
verify(hubEventLogger).logIdpAuthnSucceededEvent(state.getSessionId(), state.getSessionExpiryTimestamp(), state.getCountryEntityId(), state.getRequestIssuerEntityId(), eidasAttributeQueryRequestDto.getPersistentId(), state.getRequestId(), state.getLevelsOfAssurance().get(0), state.getLevelsOfAssurance().get(state.getLevelsOfAssurance().size() - 1), eidasAttributeQueryRequestDto.getLevelOfAssurance(), com.google.common.base.Optional.absent(), ipAddress);
verify(stateTransitionAction).transitionTo(eidasCycle0And1MatchRequestSentState);
}
Aggregations