2 package edu.internet2.middleware.shibboleth.metadata;
4 import java.io.IOException;
6 import org.apache.log4j.Logger;
7 import org.opensaml.saml2.metadata.provider.MetadataProvider;
8 import org.opensaml.saml2.metadata.provider.MetadataProviderException;
9 import org.w3c.dom.Element;
11 import edu.internet2.middleware.shibboleth.common.ShibResource;
12 import edu.internet2.middleware.shibboleth.common.ShibResource.ResourceNotAvailableException;
15 * Loads metadata from a path specified in the IdP configuration.
17 * @author Walter Hoehn
19 public class FilesystemMetadataProvider extends ShibbolethConfigurableMetadataProvider implements MetadataProvider {
21 private static Logger log = Logger.getLogger(FilesystemMetadataProvider.class.getName());
23 public FilesystemMetadataProvider(Element configuration) throws MetadataProviderException {
27 // Grab the path from the config
28 String path = ((Element) configuration).getAttribute("path");
29 if (path == null || path.equals("")) {
30 log.error("Unable to load File System Metadata Provider. A (path) attribute is required. "
31 + "Add a (path) attribute to <MetadataProvider/>.");
32 throw new MetadataProviderException("Required configuration not specified.");
35 // Construct provider from config
37 provider = new org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider(new ShibResource(path)
40 } catch (MetadataProviderException e) {
41 log.error("Unable to load URL Metadata Provider: " + e);
43 } catch (ResourceNotAvailableException e) {
44 log.error("Unable to load File System Metadata Provider. Could not access file at (" + path + ").");
45 throw new MetadataProviderException("Supplied configuration is invalid.");
46 } catch (IOException e) {
47 log.error("Unable to load File System Metadata Provider. Error while reading file: " + e);
48 throw new MetadataProviderException("Supplied configuration is invalid.");