Search in sources :

Example 6 with EvaluableEntityRoleEntityDescriptorCriterion

use of org.opensaml.saml.metadata.criteria.entity.impl.EvaluableEntityRoleEntityDescriptorCriterion in project cas by apereo.

the class SamlIdPUtils method determineNameIdNameQualifier.

/**
 * Determine name id name qualifier string.
 *
 * @param samlRegisteredService   the saml registered service
 * @param samlIdPMetadataResolver the saml id p metadata resolver
 * @return the string
 */
public static String determineNameIdNameQualifier(final SamlRegisteredService samlRegisteredService, final MetadataResolver samlIdPMetadataResolver) {
    if (StringUtils.isNotBlank(samlRegisteredService.getNameIdQualifier())) {
        return samlRegisteredService.getNameIdQualifier();
    }
    val nameQualifier = FunctionUtils.doIf(StringUtils.isNotBlank(samlRegisteredService.getIssuerEntityId()), samlRegisteredService::getIssuerEntityId, Unchecked.supplier(() -> {
        val criteriaSet = new CriteriaSet(new EvaluableEntityRoleEntityDescriptorCriterion(IDPSSODescriptor.DEFAULT_ELEMENT_NAME), new SamlIdPSamlRegisteredServiceCriterion(samlRegisteredService));
        LOGGER.trace("Resolving entity id from SAML2 IdP metadata to determine issuer for [{}]", samlRegisteredService.getName());
        val entityDescriptor = Objects.requireNonNull(samlIdPMetadataResolver.resolveSingle(criteriaSet));
        return entityDescriptor.getEntityID();
    })).get();
    LOGGER.debug("Using name qualifier [{}] for the Name ID", nameQualifier);
    return nameQualifier;
}
Also used : lombok.val(lombok.val) EvaluableEntityRoleEntityDescriptorCriterion(org.opensaml.saml.metadata.criteria.entity.impl.EvaluableEntityRoleEntityDescriptorCriterion) SamlIdPSamlRegisteredServiceCriterion(org.apereo.cas.support.saml.idp.metadata.locator.SamlIdPSamlRegisteredServiceCriterion) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet)

Aggregations

lombok.val (lombok.val)6 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)6 EvaluableEntityRoleEntityDescriptorCriterion (org.opensaml.saml.metadata.criteria.entity.impl.EvaluableEntityRoleEntityDescriptorCriterion)6 SamlIdPSamlRegisteredServiceCriterion (org.apereo.cas.support.saml.idp.metadata.locator.SamlIdPSamlRegisteredServiceCriterion)4 ArrayList (java.util.ArrayList)2 EntityIdCriterion (org.opensaml.core.criterion.EntityIdCriterion)2 Sets (com.google.common.collect.Sets)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 PrivateKey (java.security.PrivateKey)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Pattern (java.util.regex.Pattern)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Getter (lombok.Getter)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 SneakyThrows (lombok.SneakyThrows)1 Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1