Search in sources :

Example 1 with MetadataFilterChain

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

the class SamlMetadataUIConfiguration method configureAdapter.

private MetadataResolverAdapter configureAdapter(final AbstractMetadataResolverAdapter adapter) {
    final Map<Resource, MetadataFilterChain> resources = new HashMap<>();
    final MetadataFilterChain chain = new MetadataFilterChain();
    casProperties.getSamlMetadataUi().getResources().forEach(Unchecked.consumer(r -> configureResource(resources, chain, r)));
    adapter.setRequireValidMetadata(casProperties.getSamlMetadataUi().isRequireValidMetadata());
    adapter.setMetadataResources(resources);
    adapter.setConfigBean(openSamlConfigBean);
    return adapter;
}
Also used : CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) Arrays(java.util.Arrays) SignatureValidationFilter(org.opensaml.saml.metadata.resolver.filter.impl.SignatureValidationFilter) StaticMetadataResolverAdapter(org.apereo.cas.support.saml.mdui.StaticMetadataResolverAdapter) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) FlowBuilderServices(org.springframework.webflow.engine.builder.support.FlowBuilderServices) StringUtils(org.apache.commons.lang3.StringUtils) RequiredValidUntilFilter(org.opensaml.saml.metadata.resolver.filter.impl.RequiredValidUntilFilter) ArrayList(java.util.ArrayList) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) SamlUtils(org.apereo.cas.support.saml.SamlUtils) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Map(java.util.Map) CollectionUtils(org.apereo.cas.util.CollectionUtils) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Splitter(com.google.common.base.Splitter) ServiceFactory(org.apereo.cas.authentication.principal.ServiceFactory) MetadataFilter(org.opensaml.saml.metadata.resolver.filter.MetadataFilter) ServicesManager(org.apereo.cas.services.ServicesManager) Resource(org.springframework.core.io.Resource) MetadataFilterChain(org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain) AbstractMetadataResolverAdapter(org.apereo.cas.support.saml.mdui.AbstractMetadataResolverAdapter) MetadataResolverAdapter(org.apereo.cas.support.saml.mdui.MetadataResolverAdapter) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ResourceUtils(org.apereo.cas.util.ResourceUtils) Unchecked(org.jooq.lambda.Unchecked) ResourceLoader(org.springframework.core.io.ResourceLoader) FlowDefinitionRegistry(org.springframework.webflow.definition.registry.FlowDefinitionRegistry) ChainingMetadataResolverAdapter(org.apereo.cas.support.saml.mdui.ChainingMetadataResolverAdapter) ApplicationContext(org.springframework.context.ApplicationContext) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) DynamicMetadataResolverAdapter(org.apereo.cas.support.saml.mdui.DynamicMetadataResolverAdapter) Bean(org.springframework.context.annotation.Bean) HashMap(java.util.HashMap) Resource(org.springframework.core.io.Resource) MetadataFilterChain(org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain)

Example 2 with MetadataFilterChain

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

the class StaticMetadataResolverAdapterTests method verifyOperation.

@Test
public void verifyOperation() {
    val resources = (Map) Map.of(new ClassPathResource("metadata.xml"), new MetadataFilterChain());
    val adapter = new StaticMetadataResolverAdapter(resources);
    adapter.setConfigBean(configBean);
    adapter.setMetadataResources(resources);
    adapter.buildMetadataResolverAggregate();
    assertNotNull(adapter.getEntityDescriptorForEntityId("https://carmenwiki.osu.edu/shibboleth"));
}
Also used : lombok.val(lombok.val) MetadataFilterChain(org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain) Map(java.util.Map) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 3 with MetadataFilterChain

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

the class BaseSamlRegisteredServiceMetadataResolver method addMetadataFiltersToMetadataResolver.

/**
 * Add metadata filters to metadata resolver.
 *
 * @param metadataProvider   the metadata provider
 * @param metadataFilterList the metadata filter list
 */
protected void addMetadataFiltersToMetadataResolver(final AbstractMetadataResolver metadataProvider, final List<MetadataFilter> metadataFilterList) {
    val metadataFilterChain = new MetadataFilterChain();
    metadataFilterChain.setFilters(metadataFilterList);
    LOGGER.debug("Metadata filter chain initialized with [{}] filters", metadataFilterList.size());
    metadataProvider.setMetadataFilter(metadataFilterChain);
}
Also used : lombok.val(lombok.val) MetadataFilterChain(org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain)

Example 4 with MetadataFilterChain

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

the class ChainingMetadataResolverCacheLoader method buildMetadataFilters.

/**
     * Build metadata filters.
     *
     * @param service          the service
     * @param metadataProvider the metadata provider
     * @throws Exception the exception
     */
protected void buildMetadataFilters(final SamlRegisteredService service, final AbstractMetadataResolver metadataProvider) throws Exception {
    final List<MetadataFilter> metadataFilterList = new ArrayList<>();
    buildRequiredValidUntilFilterIfNeeded(service, metadataFilterList);
    buildSignatureValidationFilterIfNeeded(service, metadataFilterList);
    buildEntityRoleFilterIfNeeded(service, metadataFilterList);
    buildPredicateFilterIfNeeded(service, metadataFilterList);
    if (!metadataFilterList.isEmpty()) {
        final MetadataFilterChain metadataFilterChain = new MetadataFilterChain();
        metadataFilterChain.setFilters(metadataFilterList);
        LOGGER.debug("Metadata filter chain initialized with [{}] filters", metadataFilterList.size());
        metadataProvider.setMetadataFilter(metadataFilterChain);
    }
}
Also used : ArrayList(java.util.ArrayList) MetadataFilter(org.opensaml.saml.metadata.resolver.filter.MetadataFilter) MetadataFilterChain(org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain)

Example 5 with MetadataFilterChain

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

the class DynamicMetadataResolverAdapterTests method verifyOperation.

@Test
public void verifyOperation() throws Exception {
    val resource = new UrlResource(new URI("http://localhost:6622/entities/"));
    val adapter = new DynamicMetadataResolverAdapter(Map.of(resource, new MetadataFilterChain()));
    adapter.setConfigBean(configBean);
    val entity = IOUtils.toString(new ClassPathResource("metadata.xml").getInputStream(), StandardCharsets.UTF_8);
    try (val webServer = new MockWebServer(6622, new ByteArrayResource(entity.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
        webServer.start();
        assertNotNull(adapter.getEntityDescriptorForEntityId("https://carmenwiki.osu.edu/shibboleth"));
    }
}
Also used : lombok.val(lombok.val) UrlResource(org.springframework.core.io.UrlResource) MockWebServer(org.apereo.cas.util.MockWebServer) ByteArrayResource(org.springframework.core.io.ByteArrayResource) MetadataFilterChain(org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain) URI(java.net.URI) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataFilterChain (org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain)7 lombok.val (lombok.val)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 MetadataFilter (org.opensaml.saml.metadata.resolver.filter.MetadataFilter)4 Splitter (com.google.common.base.Splitter)3 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 Slf4j (lombok.extern.slf4j.Slf4j)3 StringUtils (org.apache.commons.lang3.StringUtils)3 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)3 OpenSamlConfigBean (org.apereo.cas.support.saml.OpenSamlConfigBean)3 SamlUtils (org.apereo.cas.support.saml.SamlUtils)3 AbstractMetadataResolverAdapter (org.apereo.cas.support.saml.mdui.AbstractMetadataResolverAdapter)3 ChainingMetadataResolverAdapter (org.apereo.cas.support.saml.mdui.ChainingMetadataResolverAdapter)3 DynamicMetadataResolverAdapter (org.apereo.cas.support.saml.mdui.DynamicMetadataResolverAdapter)3 MetadataResolverAdapter (org.apereo.cas.support.saml.mdui.MetadataResolverAdapter)3 StaticMetadataResolverAdapter (org.apereo.cas.support.saml.mdui.StaticMetadataResolverAdapter)3 CollectionUtils (org.apereo.cas.util.CollectionUtils)3 ResourceUtils (org.apereo.cas.util.ResourceUtils)3