Search in sources :

Example 1 with InMemoryResourceMetadataResolver

use of org.apereo.cas.support.saml.InMemoryResourceMetadataResolver in project cas by apereo.

the class BaseSamlRegisteredServiceMetadataResolver method buildMetadataResolverFrom.

/**
 * Build metadata resolver from document.
 *
 * @param service          the service
 * @param metadataDocument the metadata document
 * @return the metadata resolver
 */
protected AbstractMetadataResolver buildMetadataResolverFrom(final SamlRegisteredService service, final SamlMetadataDocument metadataDocument) {
    try {
        final String desc = StringUtils.defaultString(service.getDescription(), service.getName());
        final InputStreamResource metadataResource = ResourceUtils.buildInputStreamResourceFrom(metadataDocument.getValue(), desc);
        final AbstractMetadataResolver metadataResolver = new InMemoryResourceMetadataResolver(ResourceHelper.of(metadataResource));
        final List<MetadataFilter> metadataFilterList = new ArrayList<>();
        if (StringUtils.isNotBlank(metadataDocument.getSignature())) {
            final InputStreamResource signatureResource = ResourceUtils.buildInputStreamResourceFrom(metadataDocument.getSignature(), desc);
            buildSignatureValidationFilterIfNeeded(service, metadataFilterList, signatureResource);
        }
        configureAndInitializeSingleMetadataResolver(metadataResolver, service, metadataFilterList);
        return metadataResolver;
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return null;
}
Also used : AbstractMetadataResolver(org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver) ArrayList(java.util.ArrayList) MetadataFilter(org.opensaml.saml.metadata.resolver.filter.MetadataFilter) InMemoryResourceMetadataResolver(org.apereo.cas.support.saml.InMemoryResourceMetadataResolver) InputStreamResource(org.springframework.core.io.InputStreamResource)

Aggregations

ArrayList (java.util.ArrayList)1 InMemoryResourceMetadataResolver (org.apereo.cas.support.saml.InMemoryResourceMetadataResolver)1 MetadataFilter (org.opensaml.saml.metadata.resolver.filter.MetadataFilter)1 AbstractMetadataResolver (org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1