Search in sources :

Example 1 with SamlIdPMetadataProperties

use of org.apereo.cas.configuration.model.support.saml.idp.metadata.SamlIdPMetadataProperties in project cas by apereo.

the class SamlIdPJpaMetadataConfiguration method samlMetadataEntityManagerFactory.

@Lazy
@Bean
public LocalContainerEntityManagerFactoryBean samlMetadataEntityManagerFactory() {
    final SamlIdPMetadataProperties idp = casProperties.getAuthn().getSamlIdp().getMetadata();
    final LocalContainerEntityManagerFactoryBean bean = JpaBeans.newHibernateEntityManagerFactoryBean(new JpaConfigDataHolder(jpaSamlMetadataVendorAdapter(), "jpaSamlMetadataContext", jpaSamlMetadataPackagesToScan(), dataSourceSamlMetadata()), idp.getJpa());
    return bean;
}
Also used : JpaConfigDataHolder(org.apereo.cas.configuration.model.support.jpa.JpaConfigDataHolder) SamlIdPMetadataProperties(org.apereo.cas.configuration.model.support.saml.idp.metadata.SamlIdPMetadataProperties) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Lazy(org.springframework.context.annotation.Lazy) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 2 with SamlIdPMetadataProperties

use of org.apereo.cas.configuration.model.support.saml.idp.metadata.SamlIdPMetadataProperties in project cas by apereo.

the class DynamicMetadataResolver method resolve.

@Override
public List<MetadataResolver> resolve(final SamlRegisteredService service) {
    LOGGER.info("Loading metadata dynamically for [{}]", service.getName());
    final SamlIdPMetadataProperties md = samlIdPProperties.getMetadata();
    final FunctionDrivenDynamicHTTPMetadataResolver resolver = new FunctionDrivenDynamicHTTPMetadataResolver(this.httpClient.getWrappedHttpClient());
    resolver.setMinCacheDuration(TimeUnit.MILLISECONDS.convert(md.getCacheExpirationMinutes(), TimeUnit.MINUTES));
    resolver.setRequireValidMetadata(md.isRequireValidMetadata());
    if (StringUtils.isNotBlank(md.getBasicAuthnPassword()) && StringUtils.isNotBlank(md.getBasicAuthnUsername())) {
        resolver.setBasicCredentials(new UsernamePasswordCredentials(md.getBasicAuthnUsername(), md.getBasicAuthnPassword()));
    }
    if (!md.getSupportedContentTypes().isEmpty()) {
        resolver.setSupportedContentTypes(md.getSupportedContentTypes());
    }
    resolver.setRequestURLBuilder(new Function<String, String>() {

        @Nullable
        @Override
        public String apply(@Nullable final String input) {
            if (StringUtils.isNotBlank(input)) {
                final String metadataLocation = service.getMetadataLocation().replace("{0}", EncodingUtils.urlEncode(input));
                LOGGER.info("Constructed dynamic metadata query [{}] for [{}]", metadataLocation, service.getName());
                return metadataLocation;
            }
            return null;
        }
    });
    try {
        configureAndInitializeSingleMetadataResolver(resolver, service);
        return CollectionUtils.wrap(resolver);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return new ArrayList<>(0);
}
Also used : FunctionDrivenDynamicHTTPMetadataResolver(org.opensaml.saml.metadata.resolver.impl.FunctionDrivenDynamicHTTPMetadataResolver) SamlIdPMetadataProperties(org.apereo.cas.configuration.model.support.saml.idp.metadata.SamlIdPMetadataProperties) ArrayList(java.util.ArrayList) Nullable(javax.annotation.Nullable) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

SamlIdPMetadataProperties (org.apereo.cas.configuration.model.support.saml.idp.metadata.SamlIdPMetadataProperties)2 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1 JpaConfigDataHolder (org.apereo.cas.configuration.model.support.jpa.JpaConfigDataHolder)1 OpenSamlConfigBean (org.apereo.cas.support.saml.OpenSamlConfigBean)1 FunctionDrivenDynamicHTTPMetadataResolver (org.opensaml.saml.metadata.resolver.impl.FunctionDrivenDynamicHTTPMetadataResolver)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)1