Search in sources :

Example 1 with AbstractBatchMetadataResolver

use of org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver in project cas by apereo.

the class SamlSPUtils method determineEntityIdList.

private static List<String> determineEntityIdList(final AbstractSamlSPProperties sp, final SamlRegisteredServiceCachingMetadataResolver resolver, final SamlRegisteredService service) {
    val entityIDList = sp.getEntityIds();
    if (entityIDList.isEmpty()) {
        val criteriaSet = new CriteriaSet();
        criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
        criteriaSet.add(new SatisfyAnyCriterion());
        val metadataResolver = resolver.resolve(service, criteriaSet);
        val resolvers = new ArrayList<MetadataResolver>();
        if (metadataResolver instanceof ChainingMetadataResolver) {
            resolvers.addAll(((ChainingMetadataResolver) metadataResolver).getResolvers());
        } else {
            resolvers.add(metadataResolver);
        }
        resolvers.forEach(r -> {
            if (r instanceof AbstractBatchMetadataResolver) {
                val it = ((AbstractBatchMetadataResolver) r).iterator();
                val descriptor = StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED), false).filter(e -> e.getSPSSODescriptor(SAMLConstants.SAML20P_NS) != null).findFirst();
                if (descriptor.isPresent()) {
                    entityIDList.add(descriptor.get().getEntityID());
                } else {
                    LOGGER.warn("Skipped registration of [{}] since no entity id could be found", sp.getName());
                }
            }
        });
    }
    return entityIDList;
}
Also used : lombok.val(lombok.val) SatisfyAnyCriterion(org.opensaml.core.criterion.SatisfyAnyCriterion) AbstractBatchMetadataResolver(org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver) Ordered(org.springframework.core.Ordered) PrincipalAttributeRegisteredServiceUsernameProvider(org.apereo.cas.services.PrincipalAttributeRegisteredServiceUsernameProvider) SneakyThrows(lombok.SneakyThrows) Spliterators(java.util.Spliterators) SamlRegisteredServiceCachingMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver) StringUtils(org.apache.commons.lang3.StringUtils) AbstractBatchMetadataResolver(org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver) ArrayList(java.util.ArrayList) UtilityClass(lombok.experimental.UtilityClass) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) SatisfyAnyCriterion(org.opensaml.core.criterion.SatisfyAnyCriterion) StreamSupport(java.util.stream.StreamSupport) SAMLConstants(org.opensaml.saml.common.xml.SAMLConstants) ChainingAttributeReleasePolicy(org.apereo.cas.services.ChainingAttributeReleasePolicy) ServicesManager(org.apereo.cas.services.ServicesManager) lombok.val(lombok.val) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) RegisteredService(org.apereo.cas.services.RegisteredService) SPSSODescriptor(org.opensaml.saml.saml2.metadata.SPSSODescriptor) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) AbstractSamlSPProperties(org.apereo.cas.configuration.model.support.saml.sps.AbstractSamlSPProperties) ReturnMappedAttributeReleasePolicy(org.apereo.cas.services.ReturnMappedAttributeReleasePolicy) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) ChainingMetadataResolver(org.opensaml.saml.metadata.resolver.ChainingMetadataResolver) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) CoreAuthenticationUtils(org.apereo.cas.authentication.CoreAuthenticationUtils) PredicateFilter(org.opensaml.saml.metadata.resolver.filter.impl.PredicateFilter) Spliterator(java.util.Spliterator) ChainingMetadataResolver(org.opensaml.saml.metadata.resolver.ChainingMetadataResolver) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Spliterator (java.util.Spliterator)1 Spliterators (java.util.Spliterators)1 StreamSupport (java.util.stream.StreamSupport)1 SneakyThrows (lombok.SneakyThrows)1 UtilityClass (lombok.experimental.UtilityClass)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)1 StringUtils (org.apache.commons.lang3.StringUtils)1 CoreAuthenticationUtils (org.apereo.cas.authentication.CoreAuthenticationUtils)1 AbstractSamlSPProperties (org.apereo.cas.configuration.model.support.saml.sps.AbstractSamlSPProperties)1 ChainingAttributeReleasePolicy (org.apereo.cas.services.ChainingAttributeReleasePolicy)1 PrincipalAttributeRegisteredServiceUsernameProvider (org.apereo.cas.services.PrincipalAttributeRegisteredServiceUsernameProvider)1 RegisteredService (org.apereo.cas.services.RegisteredService)1 ReturnMappedAttributeReleasePolicy (org.apereo.cas.services.ReturnMappedAttributeReleasePolicy)1 ServicesManager (org.apereo.cas.services.ServicesManager)1 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)1 SamlRegisteredServiceCachingMetadataResolver (org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver)1