class AuthnResponseFromIdpService {

    public ResponseAction receiveAuthnResponseFromIdp(SessionId sessionId,
                                                      SamlAuthnResponseContainerDto samlResponseDto) {

        IdpSelectedStateController idpSelectedController = (IdpSelectedStateController) sessionRepository.getStateController(sessionId, IdpSelectedState.class);

        boolean matchingJourney = idpSelectedController.isMatchingJourney();
        String entityToEncryptFor = matchingJourney ? idpSelectedController.getMatchingServiceEntityId() : idpSelectedController.getRequestIssuerId();
        final SamlAuthnResponseTranslatorDto samlAuthnResponseTranslatorDto = samlAuthnResponseTranslatorDtoFactory.fromSamlAuthnResponseContainerDto(samlResponseDto, entityToEncryptFor);
        final InboundResponseFromIdpDto idaResponseFromIdpDto = samlEngineProxy.translateAuthnResponseFromIdp(samlAuthnResponseTranslatorDto);
        final String principalIPAddressAsSeenByHub = samlResponseDto.getPrincipalIPAddressAsSeenByHub();

        ResponseAction responseAction;

        if (isFraudulent(idaResponseFromIdpDto)) {
            responseAction = handleFraudResponse(idaResponseFromIdpDto, sessionId, principalIPAddressAsSeenByHub, idpSelectedController, samlResponseDto.getAnalyticsSessionId(), samlResponseDto.getJourneyType());
        } else {
            responseAction = handleNonFraudResponse(idaResponseFromIdpDto, sessionId, principalIPAddressAsSeenByHub, matchingJourney, idpSelectedController, samlResponseDto.getAnalyticsSessionId(), samlResponseDto.getJourneyType());
        }
        return responseAction;
    }

    @Inject public  AuthnResponseFromIdpService(SamlEngineProxy samlEngineProxy,
                                       AttributeQueryService attributeQueryService,
                                       SessionRepository sessionRepository,
                                       SamlAuthnResponseTranslatorDtoFactory samlAuthnResponseTranslatorDtoFactory);

}