class ResponseAssertionsFromIdpValidator {

    public void validate(ValidatedResponse validatedResponse, ValidatedAssertions validatedAssertions) {
        validatedAssertions.getAssertions().forEach(
            assertion -> identityProviderAssertionValidator.validate(assertion, validatedResponse.getInResponseTo(), hubEntityId)
        );

        if (!validatedResponse.isSuccess()) return;

        Assertion matchingDatasetAssertion = getMatchingDatasetAssertion(validatedAssertions);
        Assertion authnStatementAssertion = getAuthnStatementAssertion(validatedAssertions);

        if (authnStatementAssertion.getAuthnStatements().size() > 1) {
            throw new SamlValidationException(multipleAuthnStatements());
        }

        matchingDatasetAssertionValidator.validate(matchingDatasetAssertion, validatedResponse.getIssuer().getValue());
        authnStatementAssertionValidator.validate(authnStatementAssertion);
        identityProviderAssertionValidator.validateConsistency(authnStatementAssertion, matchingDatasetAssertion);
        ipAddressValidator.validate(authnStatementAssertion);
    }

    public  ResponseAssertionsFromIdpValidator(IdentityProviderAssertionValidator assertionValidator,
                                              MatchingDatasetAssertionValidator matchingDatasetAssertionValidator,
                                              AuthnStatementAssertionValidator authnStatementAssertionValidator,
                                              IPAddressValidator ipAddressValidator,
                                              String hubEntityId);

}