All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.gov.ida.saml.security.validators.ValidatedAssertions Maven / Gradle / Ivy

There is a newer version: 3.4.6-277
Show newest version
package uk.gov.ida.saml.security.validators;


import org.opensaml.saml.saml2.core.Assertion;

import java.util.List;
import java.util.Optional;

public class ValidatedAssertions {
    private List assertions;

    public ValidatedAssertions(List assertions) {
        this.assertions = assertions;
    }

    public List getAssertions() {
        return assertions;
    }

    public Optional getMatchingDatasetAssertion() {
        return assertions.stream()
                .filter(this::isMatchingDatasetAssertion)
                .findFirst();
    }

    public Optional getAuthnStatementAssertion() {
        return assertions.stream()
                .filter(assertion -> !this.isMatchingDatasetAssertion(assertion))
                .findFirst();
    }

    private boolean isMatchingDatasetAssertion(Assertion assertion) {
        return !assertion.getAttributeStatements().isEmpty() && assertion.getAuthnStatements().isEmpty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy