+++ /dev/null
-
-package edu.internet2.middleware.shibboleth.metadata;
-
-import org.opensaml.saml2.metadata.provider.MetadataProvider;
-import org.opensaml.saml2.metadata.provider.MetadataProviderException;
-import org.w3c.dom.Element;
-
-/**
- * Loads metadata directly from the IdP configuration.
- *
- * @author Walter Hoehn
- */
-/*
- * We could do without this class, I guess, since the OpenSAML version has the right constructor; but it seems prudent
- * to put it in the same hierarchy with its peers.
- */
-public class DOMMetadataProvider extends ShibbolethConfigurableMetadataProvider implements MetadataProvider {
-
- public DOMMetadataProvider(Element configuration) throws MetadataProviderException {
-
- super(configuration);
-
- provider = new org.opensaml.saml2.metadata.provider.DOMMetadataProvider(configuration);
-
- }
-
-}
+++ /dev/null
-
-package edu.internet2.middleware.shibboleth.metadata;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-import org.opensaml.saml2.metadata.provider.MetadataProvider;
-import org.opensaml.saml2.metadata.provider.MetadataProviderException;
-import org.w3c.dom.Element;
-
-import edu.internet2.middleware.shibboleth.common.ShibResource;
-import edu.internet2.middleware.shibboleth.common.ShibResource.ResourceNotAvailableException;
-
-/**
- * Loads metadata from a path specified in the IdP configuration.
- *
- * @author Walter Hoehn
- */
-public class FilesystemMetadataProvider extends ShibbolethConfigurableMetadataProvider implements MetadataProvider {
-
- private static Logger log = Logger.getLogger(FilesystemMetadataProvider.class.getName());
-
- public FilesystemMetadataProvider(Element configuration) throws MetadataProviderException {
-
- super(configuration);
-
- // Grab the path from the config
- String path = ((Element) configuration).getAttribute("path");
- if (path == null || path.equals("")) {
- log.error("Unable to load File System Metadata Provider. A (path) attribute is required. "
- + "Add a (path) attribute to <MetadataProvider/>.");
- throw new MetadataProviderException("Required configuration not specified.");
- }
-
- // Construct provider from config
- try {
- provider = new org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider(new ShibResource(path)
- .getFile());
-
- } catch (MetadataProviderException e) {
- log.error("Unable to load URL Metadata Provider: " + e);
- throw e;
- } catch (ResourceNotAvailableException e) {
- log.error("Unable to load File System Metadata Provider. Could not access file at (" + path + ").");
- throw new MetadataProviderException("Supplied configuration is invalid.");
- } catch (IOException e) {
- log.error("Unable to load File System Metadata Provider. Error while reading file: " + e);
- throw new MetadataProviderException("Supplied configuration is invalid.");
- }
- }
-}
+++ /dev/null
-
-package edu.internet2.middleware.shibboleth.metadata;
-
-/*
- * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.log4j.Logger;
-import org.opensaml.saml2.metadata.provider.MetadataProvider;
-import org.opensaml.saml2.metadata.provider.MetadataProviderException;
-import org.w3c.dom.Element;
-
-public class MetadataProviderFactory {
-
- private static Logger log = Logger.getLogger(MetadataProviderFactory.class.getName());
-
- public static MetadataProvider loadProvider(Element e) throws MetadataProviderException {
-
- String className = e.getAttribute("type");
- if (className == null || className.equals("")) {
- log.error("Metadata Provider requires specification of the attribute \"type\".");
- throw new MetadataProviderException("Failed to initialize Metadata Provider.");
- } else {
- try {
- Class[] params = {Class.forName("org.w3c.dom.Element"),};
- return (MetadataProvider) Class.forName(className).getConstructor(params).newInstance(new Object[]{e});
-
- } catch (Exception loaderException) {
- log.error("Failed to load Metadata Provider implementation class: " + loaderException);
- Throwable cause = loaderException.getCause();
- while (cause != null) {
- log.error("caused by: " + cause);
- cause = cause.getCause();
- }
- throw new MetadataProviderException("Failed to initialize Metadata Provider.");
- }
- }
- }
-}
+++ /dev/null
-
-package edu.internet2.middleware.shibboleth.metadata;
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.opensaml.saml2.metadata.EntitiesDescriptor;
-import org.opensaml.saml2.metadata.EntityDescriptor;
-import org.opensaml.saml2.metadata.RoleDescriptor;
-import org.opensaml.saml2.metadata.provider.MetadataFilter;
-import org.opensaml.saml2.metadata.provider.MetadataProvider;
-import org.opensaml.saml2.metadata.provider.MetadataProviderException;
-import org.opensaml.xml.XMLObject;
-import org.w3c.dom.Element;
-
-/**
- * Base class for <code>MetadataProvider</code> implementations that can be loaded based on the IdP runtime
- * configuration. Implementors should create a constructor that accepts a configuration <code>Element</code> and sets
- * the provider field.
- *
- * @author Walter Hoehn
- */
-public abstract class ShibbolethConfigurableMetadataProvider implements MetadataProvider {
-
- protected org.opensaml.saml2.metadata.provider.MetadataProvider provider;
-
- public ShibbolethConfigurableMetadataProvider(Element configuration) {
-
- }
-
- public boolean requireValidMetadata() {
-
- return provider.requireValidMetadata();
- }
-
- public void setRequireValidMetadata(boolean requireValidMetadata) {
-
- provider.setRequireValidMetadata(requireValidMetadata);
-
- }
-
- public MetadataFilter getMetadataFilter() {
-
- return provider.getMetadataFilter();
- }
-
- public void setMetadataFilter(MetadataFilter newFilter) throws MetadataProviderException {
-
- provider.setMetadataFilter(newFilter);
-
- }
-
- public EntityDescriptor getEntityDescriptor(String entityID) throws MetadataProviderException {
-
- return provider.getEntityDescriptor(entityID);
- }
-
- public List<RoleDescriptor> getRole(String entityID, QName roleName) throws MetadataProviderException {
-
- return provider.getRole(entityID, roleName);
- }
-
- public XMLObject getMetadata() throws MetadataProviderException {
-
- return provider.getMetadata();
- }
-
- public EntitiesDescriptor getEntitiesDescriptor(String name) throws MetadataProviderException {
-
- return provider.getEntitiesDescriptor(name);
- }
-
- public RoleDescriptor getRole(String entityID, QName roleName, String supportedProtocol)
- throws MetadataProviderException {
-
- return provider.getRole(entityID, roleName, supportedProtocol);
- }
-}
+++ /dev/null
-
-package edu.internet2.middleware.shibboleth.metadata;
-
-import org.apache.log4j.Logger;
-import org.opensaml.saml2.metadata.provider.MetadataProvider;
-import org.opensaml.saml2.metadata.provider.MetadataProviderException;
-import org.w3c.dom.Element;
-
-/**
- * Loads metadata from a URL specified in the IdP configuration.
- *
- * @author Walter Hoehn
- */
-public class URLMetadataProvider extends ShibbolethConfigurableMetadataProvider implements MetadataProvider {
-
- private static Logger log = Logger.getLogger(URLMetadataProvider.class.getName());
-
- public URLMetadataProvider(Element configuration) throws MetadataProviderException {
-
- super(configuration);
-
- // Grab the URL from the config
- String url = ((Element) configuration).getAttribute("url");
- if (url == null || url.equals("")) {
- log.error("Unable to load URL Metadata Provider. A (url) attribute is required. "
- + "Add a (url) attribute to <MetadataProvider/>.");
- throw new MetadataProviderException("Required configuration not specified.");
- }
-
- // Grab the request timeout, if there is one. If not, use a reasonable default
- int requestTimeout = 1000 * 1 * 60; // 1 minute
- String rawRequestTimeout = ((Element) configuration).getAttribute("requestTimeout");
- if (rawRequestTimeout != null && !rawRequestTimeout.equals("")) {
- try {
- requestTimeout = Integer.valueOf(rawRequestTimeout);
- } catch (NumberFormatException nfe) {
- log.error("Unable to load URL Metadata Provider. The (requestTimeout) attribute must be an integer. "
- + "Modify the (requestTimeout) attribute on <MetadataProvider/>.");
- throw new MetadataProviderException("Configuration is invalid.");
- }
- }
-
- // Construct provider from config
- try {
- provider = new org.opensaml.saml2.metadata.provider.URLMetadataProvider(url, requestTimeout);
-
- // If there is a cache duration, set it
- String rawMaxCacheDuration = ((Element) configuration).getAttribute("maxCacheDuration");
- if (rawMaxCacheDuration != null && !rawMaxCacheDuration.equals("")) {
- try {
- ((org.opensaml.saml2.metadata.provider.URLMetadataProvider) provider).setMaxDuration(Integer
- .valueOf(rawMaxCacheDuration));
- } catch (NumberFormatException nfe) {
- log.error("Unable to load URL Metadata Provider. The (maxCacheDuration) attribute must be "
- + "an integer. Modify the (maxCacheDuration) attribute on <MetadataProvider/>.");
- throw new MetadataProviderException("Configuration is invalid.");
- }
- }
-
- } catch (MetadataProviderException e) {
- log.error("Unable to load URL Metadata Provider: " + e);
- throw e;
- }
- }
-}