Search in sources :

Example 16 with MetadataResolver

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

the class SamlRegisteredServiceMetadataResolverCacheLoader method load.

@Override
@Synchronized
@SneakyThrows
public ChainingMetadataResolver load(final SamlRegisteredService service) {
    final ChainingMetadataResolver metadataResolver = new ChainingMetadataResolver();
    final List<MetadataResolver> metadataResolvers = new ArrayList<>();
    final Collection<SamlRegisteredServiceMetadataResolver> availableResolvers = this.metadataResolutionPlan.getRegisteredMetadataResolvers();
    availableResolvers.stream().filter(Objects::nonNull).filter(r -> r.supports(service)).map(r -> r.resolve(service)).forEach(metadataResolvers::addAll);
    if (metadataResolvers.isEmpty()) {
        throw new SamlException("No metadata resolvers could be configured for service " + service.getName() + " with metadata location " + service.getMetadataLocation());
    }
    metadataResolver.setId(ChainingMetadataResolver.class.getCanonicalName());
    metadataResolver.setResolvers(metadataResolvers);
    metadataResolver.initialize();
    LOGGER.debug("Metadata resolvers active for this request are [{}]", metadataResolver);
    return metadataResolver;
}
Also used : Synchronized(lombok.Synchronized) CacheLoader(com.github.benmanes.caffeine.cache.CacheLoader) SneakyThrows(lombok.SneakyThrows) HttpClient(org.apereo.cas.util.http.HttpClient) Collection(java.util.Collection) SamlRegisteredServiceMetadataResolutionPlan(org.apereo.cas.support.saml.services.idp.metadata.plan.SamlRegisteredServiceMetadataResolutionPlan) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) ArrayList(java.util.ArrayList) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) SamlRegisteredServiceMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.SamlRegisteredServiceMetadataResolver) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) SamlException(org.apereo.cas.support.saml.SamlException) ChainingMetadataResolver(org.opensaml.saml.metadata.resolver.ChainingMetadataResolver) AllArgsConstructor(lombok.AllArgsConstructor) ChainingMetadataResolver(org.opensaml.saml.metadata.resolver.ChainingMetadataResolver) SamlRegisteredServiceMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.SamlRegisteredServiceMetadataResolver) ArrayList(java.util.ArrayList) SamlException(org.apereo.cas.support.saml.SamlException) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) SamlRegisteredServiceMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.SamlRegisteredServiceMetadataResolver) ChainingMetadataResolver(org.opensaml.saml.metadata.resolver.ChainingMetadataResolver) Synchronized(lombok.Synchronized) SneakyThrows(lombok.SneakyThrows)

Example 17 with MetadataResolver

use of org.opensaml.saml.metadata.resolver.MetadataResolver in project verify-hub by alphagov.

the class IdpSingleSignOnServiceHelperTest method shouldThrowExceptionWhenMetadataProviderThrowsOne.

@Test(expected = RuntimeException.class)
public void shouldThrowExceptionWhenMetadataProviderThrowsOne() throws ResolverException {
    MetadataResolver metadataResolver = mock(MetadataResolver.class);
    when(metadataResolver.resolveSingle(any(CriteriaSet.class))).thenThrow(new ResolverException());
    idpSingleSignOnServiceHelper = new IdpSingleSignOnServiceHelper(metadataResolver);
    idpSingleSignOnServiceHelper.getSingleSignOn(idpEntityId);
}
Also used : ResolverException(net.shibboleth.utilities.java.support.resolver.ResolverException) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) Test(org.junit.Test)

Aggregations

MetadataResolver (org.opensaml.saml.metadata.resolver.MetadataResolver)17 ChainingMetadataResolver (org.opensaml.saml.metadata.resolver.ChainingMetadataResolver)7 ArrayList (java.util.ArrayList)6 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)6 SneakyThrows (lombok.SneakyThrows)5 SamlRegisteredServiceCachingMetadataResolver (org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver)4 SamlRegisteredServiceMetadataResolver (org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.SamlRegisteredServiceMetadataResolver)4 Test (org.junit.Test)4 EntityDescriptor (org.opensaml.saml.saml2.metadata.EntityDescriptor)4 List (java.util.List)3 Slf4j (lombok.extern.slf4j.Slf4j)3 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)3 EntityIdCriterion (org.opensaml.core.criterion.EntityIdCriterion)3 SPSSODescriptor (org.opensaml.saml.saml2.metadata.SPSSODescriptor)3 Provides (com.google.inject.Provides)2 Collection (java.util.Collection)2 Optional (java.util.Optional)2 Named (javax.inject.Named)2 Singleton (javax.inject.Singleton)2 Synchronized (lombok.Synchronized)2