use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionResourceIntegrationTest method shouldGetRpResponseGivenASessionExistsInPolicy.
@Test
public void shouldGetRpResponseGivenASessionExistsInPolicy() throws JsonProcessingException {
// Given
SessionId sessionId = SessionId.createNewSessionId();
configStub.setupStubForEnabledIdps(rpEntityId, SIGNING_IN, REQUESTED_LOA, singletonList(idpEntityId));
Response sessionCreatedResponse = TestSessionResourceHelper.createSessionInSuccessfulMatchState(sessionId, rpEntityId, idpEntityId, client, policy.uri(UriBuilder.fromPath(TEST_SESSION_RESOURCE_PATH + SUCCESSFUL_MATCH_STATE).build().toASCIIString()));
assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
AuthnResponseFromHubContainerDto expectedAuthnResponseFromHub = anAuthnResponseFromHubContainerDto().build();
samlEngineStub.setUpStubForAuthnResponseGenerate(expectedAuthnResponseFromHub);
// When
URI rpAuthResponseUri = UriBuilder.fromPath(Urls.PolicyUrls.RP_AUTHN_RESPONSE_RESOURCE).build(sessionId);
Response responseForRp = client.target(policy.uri(rpAuthResponseUri.toASCIIString())).request().get();
// Then
assertThat(responseForRp.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
AuthnResponseFromHubContainerDto authnResponseFromHub = responseForRp.readEntity(AuthnResponseFromHubContainerDto.class);
assertThat(authnResponseFromHub).isEqualToComparingFieldByField(expectedAuthnResponseFromHub);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionResourceIntegrationTest method shouldReturnOkWhenGeneratingIdpAuthnRequestFromHubIsSuccessfulOnRegistration.
@Test
public void shouldReturnOkWhenGeneratingIdpAuthnRequestFromHubIsSuccessfulOnRegistration() throws Exception {
// Given
SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForRegistration(sessionId, idpEntityId);
final SamlRequestDto samlRequestDto = new SamlRequestDto("coffee-pasta", idpSsoUri);
final AuthnRequestFromHubContainerDto expectedResult = anAuthnRequestFromHubContainerDtoWithRegistering(samlRequestDto, true);
samlEngineStub.setupStubForIdpAuthnRequestGenerate(samlRequestDto);
// When
AuthnRequestFromHubContainerDto result = getEntity(UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_REQUEST_RESOURCE).build(sessionId), AuthnRequestFromHubContainerDto.class);
// Then
assertThat(result).isEqualToComparingFieldByField(expectedResult);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionTimeoutIntegrationTests method selectIdpShouldReturnErrorWhenSessionHasTimedOut.
@Test
public void selectIdpShouldReturnErrorWhenSessionHasTimedOut() {
DateTimeFreezer.freezeTime(SOME_TIME);
SessionId sessionId = client.target(policy.uri(Urls.PolicyUrls.NEW_SESSION_RESOURCE)).request().post(Entity.entity(samlRequest, MediaType.APPLICATION_JSON_TYPE), SessionId.class);
DateTimeFreezer.freezeTime(SOME_TIME.plusMinutes(SOME_TIMEOUT + 1));
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).buildFromEncoded(sessionId);
confirmError(policy.uri(uri.getPath()), new IdpSelected(STUB_IDP_ONE, "some-ip-address", REGISTERING, REQUESTED_LOA), SESSION_TIMEOUT);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class AuthnRequestFromTransactionHandler method handleRequestFromTransaction.
public SessionId handleRequestFromTransaction(SamlResponseWithAuthnRequestInformationDto samlResponse, Optional<String> relayState, String ipAddress, URI assertionConsumerServiceUri, boolean transactionSupportsEidas) {
Duration sessionLength = policyConfiguration.getSessionLength();
DateTime sessionExpiryTimestamp = DateTime.now().plus(sessionLength);
SessionId sessionId = SessionId.createNewSessionId();
SessionStartedState sessionStartedState = new SessionStartedState(samlResponse.getId(), relayState.orNull(), samlResponse.getIssuer(), assertionConsumerServiceUri, samlResponse.getForceAuthentication().orNull(), sessionExpiryTimestamp, sessionId, transactionSupportsEidas);
final List<LevelOfAssurance> transactionLevelsOfAssurance = transactionsConfigProxy.getLevelsOfAssurance(samlResponse.getIssuer());
hubEventLogger.logSessionStartedEvent(samlResponse, ipAddress, sessionExpiryTimestamp, sessionId, transactionLevelsOfAssurance.get(0), transactionLevelsOfAssurance.get(transactionLevelsOfAssurance.size() - 1));
return sessionRepository.createSession(sessionStartedState);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class AbstractAwaitingCycle3DataStateController method handleCancellation.
public void handleCancellation() {
hubEventLogger.logCycle3DataInputCancelled(state.getSessionId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getRequestId());
Cycle3DataInputCancelledState cycle3DataInputCancelledState = new Cycle3DataInputCancelledState(state.getRequestId(), state.getSessionExpiryTimestamp(), state.getRelayState(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri(), new SessionId(state.getSessionId().getSessionId()), state.getTransactionSupportsEidas());
stateTransitionAction.transitionTo(cycle3DataInputCancelledState);
}
Aggregations