use of uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto 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.contracts.AttributeQueryRequestDto in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateController method getNextStateForNoMatch.
@Override
protected State getNextStateForNoMatch() {
Optional<String> selfAssertedAttributeName = transactionsConfigProxy.getMatchingProcess(state.getRequestIssuerEntityId()).getAttributeName();
if (selfAssertedAttributeName.isPresent()) {
hubEventLogger.logWaitingForCycle3AttributesEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
return getAwaitingCycle3DataState();
}
List<UserAccountCreationAttribute> userAccountCreationAttributes = transactionsConfigProxy.getUserAccountCreationAttributes(state.getRequestIssuerEntityId());
if (!userAccountCreationAttributes.isEmpty()) {
AttributeQueryRequestDto attributeQueryRequestDto = createAttributeQuery(userAccountCreationAttributes);
return handleUserAccountCreationRequestAndGenerateState(attributeQueryRequestDto);
}
hubEventLogger.logCycle01NoMatchEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
return getNoMatchState();
}
use of uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateController method getNextStateForNoMatch.
@Override
protected State getNextStateForNoMatch() {
List<UserAccountCreationAttribute> userAccountCreationAttributes = transactionsConfigProxy.getUserAccountCreationAttributes(state.getRequestIssuerEntityId());
if (!userAccountCreationAttributes.isEmpty()) {
AttributeQueryRequestDto attributeQueryRequestDto = createAttributeQuery(userAccountCreationAttributes);
return handleUserAccountCreationRequestAndGenerateState(attributeQueryRequestDto);
}
hubEventLogger.logCycle3NoMatchEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getRequestId());
return getNoMatchState();
}
use of uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method shouldReturnUserAccountCreationRequestSentStateForNoMatchWhenAttributesArePresent.
@Test
public void shouldReturnUserAccountCreationRequestSentStateForNoMatchWhenAttributesArePresent() {
ArgumentCaptor<UserAccountCreationRequestSentState> capturedState = ArgumentCaptor.forClass(UserAccountCreationRequestSentState.class);
ArgumentCaptor<EventSinkHubEvent> eventSinkArgumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
URI userAccountCreationUri = URI.create("a-test-user-account-creation-uri");
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
List<UserAccountCreationAttribute> userAccountCreationAttributes = List.of(UserAccountCreationAttribute.DATE_OF_BIRTH);
String transactionEntityId = "request issuer id";
when(transactionsConfigProxy.getUserAccountCreationAttributes(transactionEntityId)).thenReturn(userAccountCreationAttributes);
when(matchingServiceConfigProxy.getMatchingService(anyString())).thenReturn(aMatchingServiceConfigEntityDataDto().withUserAccountCreationUri(userAccountCreationUri).build());
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
controller.transitionToNextStateForNoMatchResponse();
verify(eventSinkProxy, times(1)).logHubEvent(eventSinkArgumentCaptor.capture());
assertThat(eventSinkArgumentCaptor.getValue().getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
assertThat(eventSinkArgumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(USER_ACCOUNT_CREATION_REQUEST_SENT);
assertThat(eventSinkArgumentCaptor.getValue().getSessionId()).isEqualTo(state.getSessionId().toString());
assertThat(eventSinkArgumentCaptor.getValue().getDetails().get(EventDetailsKey.request_id)).isEqualTo(state.getRequestId());
assertThat(eventSinkArgumentCaptor.getValue().getOriginatingService()).isEqualTo(serviceInfo.getName());
verify(stateTransitionAction).transitionTo(capturedState.capture());
verify(attributeQueryService).sendAttributeQueryRequest(eq(capturedState.getValue().getSessionId()), attributeQueryRequestCaptor.capture());
AttributeQueryRequestDto actualAttributeQueryRequestDto = attributeQueryRequestCaptor.getValue();
assertThat(actualAttributeQueryRequestDto.getAttributeQueryUri()).isEqualTo(userAccountCreationUri);
assertThat(actualAttributeQueryRequestDto.getUserAccountCreationAttributes()).isEqualTo(Optional.ofNullable(userAccountCreationAttributes));
assertThat(actualAttributeQueryRequestDto.getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
assertThat(capturedState.getValue()).isInstanceOf(UserAccountCreationRequestSentState.class);
}
use of uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateControllerTest method shouldReturnUserAccountCreationRequestSentStateWhenNoMatchAndTransactionDoesNotSupportCycle3AndSupportsUserAccountCreation.
@Test
public void shouldReturnUserAccountCreationRequestSentStateWhenNoMatchAndTransactionDoesNotSupportCycle3AndSupportsUserAccountCreation() {
URI userAccountCreationUri = URI.create("a-test-user-account-creation-uri");
List<UserAccountCreationAttribute> userAccountCreationAttributes = singletonList(UserAccountCreationAttribute.DATE_OF_BIRTH);
final ArgumentCaptor<UserAccountCreationRequestSentState> capturedState = ArgumentCaptor.forClass(UserAccountCreationRequestSentState.class);
when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.empty()));
when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(userAccountCreationAttributes);
when(matchingServiceConfigProxy.getMatchingService(anyString())).thenReturn(aMatchingServiceConfigEntityDataDto().withUserAccountCreationUri(userAccountCreationUri).build());
controller.transitionToNextStateForNoMatchResponse();
verify(stateTransitionAction).transitionTo(capturedState.capture());
verify(hubEventLogger).logMatchingServiceUserAccountCreationRequestSentEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, state.getSessionExpiryTimestamp(), state.getRequestId());
verify(attributeQueryService).sendAttributeQueryRequest(eq(capturedState.getValue().getSessionId()), attributeQueryRequestCaptor.capture());
AttributeQueryRequestDto actualAttributeQueryRequestDto = attributeQueryRequestCaptor.getValue();
assertThat(actualAttributeQueryRequestDto.getAttributeQueryUri()).isEqualTo(userAccountCreationUri);
assertThat(actualAttributeQueryRequestDto.getUserAccountCreationAttributes()).isEqualTo(Optional.ofNullable(userAccountCreationAttributes));
assertThat(capturedState.getValue()).isInstanceOf(UserAccountCreationRequestSentState.class);
}
Aggregations