class AuthnRequestFromTransactionHandler {

    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.orElse(null),
                samlResponse.getIssuer(),
                assertionConsumerServiceUri,
                samlResponse.getForceAuthentication().orElse(null),
                sessionExpiryTimestamp,
                sessionId,
                transactionSupportsEidas);
        final List<LevelOfAssurance> transactionLevelsOfAssurance = transactionsConfigProxy.getLevelsOfAssurance(samlResponse.getIssuer());

        hubEventLogger.logSessionStartedEvent(
            samlResponse,
            ipAddress,
            sessionExpiryTimestamp,
            sessionId,
            Collections.min(transactionLevelsOfAssurance), // min LOA
            Collections.max(transactionLevelsOfAssurance), // max LOA
            transactionLevelsOfAssurance.get(0)); // preferred LOA

        return sessionRepository.createSession(sessionStartedState);
    }

    @Inject public  AuthnRequestFromTransactionHandler(
            SessionRepository sessionRepository,
            HubEventLogger hubEventLogger,
            PolicyConfiguration policyConfiguration,
            TransactionsConfigProxy transactionsConfigProxy,
            IdGenerator idGenerator);

}