Search in sources :

Example 1 with DOMMetadataResolver

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

the class AbstractMetadataResolverAdapter method buildSingleMetadataResolver.

/**
     * Build single metadata resolver.
     *
     * @param metadataFilterChain the metadata filters chained together
     * @param resource            the resource
     * @param document            the xml document to parse
     * @return list of resolved metadata from resources.
     * @throws IOException the iO exception
     */
private List<MetadataResolver> buildSingleMetadataResolver(final MetadataFilter metadataFilterChain, final Resource resource, final Document document) throws IOException {
    try {
        final Element metadataRoot = document.getDocumentElement();
        final DOMMetadataResolver metadataProvider = new DOMMetadataResolver(metadataRoot);
        metadataProvider.setParserPool(this.configBean.getParserPool());
        metadataProvider.setFailFastInitialization(true);
        metadataProvider.setRequireValidMetadata(this.requireValidMetadata);
        metadataProvider.setId(metadataProvider.getClass().getCanonicalName());
        if (metadataFilterChain != null) {
            metadataProvider.setMetadataFilter(metadataFilterChain);
        }
        LOGGER.debug("Initializing metadata resolver for [{}]", resource);
        metadataProvider.initialize();
        final List<MetadataResolver> resolvers = new ArrayList<>();
        resolvers.add(metadataProvider);
        return resolvers;
    } catch (final Exception ex) {
        LOGGER.warn("Could not initialize metadata resolver. Resource will be ignored", ex);
    }
    return new ArrayList<>();
}
Also used : DOMMetadataResolver(org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) ChainingMetadataResolver(org.opensaml.saml.metadata.resolver.ChainingMetadataResolver) DOMMetadataResolver(org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with DOMMetadataResolver

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

the class ChainingMetadataResolverCacheLoader method resolveClasspathBasedMetadataResource.

private void resolveClasspathBasedMetadataResource(final SamlRegisteredService service, final List<MetadataResolver> metadataResolvers, final String metadataLocation, final AbstractResource metadataResource) {
    try (InputStream in = metadataResource.getInputStream()) {
        LOGGER.debug("Parsing metadata from [{}]", metadataLocation);
        final Document document = this.configBean.getParserPool().parse(in);
        final Element metadataRoot = document.getDocumentElement();
        final DOMMetadataResolver metadataProvider = new DOMMetadataResolver(metadataRoot);
        buildSingleMetadataResolver(metadataProvider, service);
        metadataResolvers.add(metadataProvider);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : DOMMetadataResolver(org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) SamlException(org.apereo.cas.support.saml.SamlException)

Aggregations

DOMMetadataResolver (org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver)2 Element (org.w3c.dom.Element)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 SamlException (org.apereo.cas.support.saml.SamlException)1 ChainingMetadataResolver (org.opensaml.saml.metadata.resolver.ChainingMetadataResolver)1 MetadataResolver (org.opensaml.saml.metadata.resolver.MetadataResolver)1 Document (org.w3c.dom.Document)1