Sort out Pluggable interface and delete the middlemen
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / metadata / provider / XMLMetadataProvider.java
index b154c64..e9b50dc 100644 (file)
@@ -53,11 +53,12 @@ import org.w3c.dom.NodeList;
 
 import edu.internet2.middleware.shibboleth.common.Constants;
 import edu.internet2.middleware.shibboleth.metadata.*;
+import edu.internet2.middleware.shibboleth.serviceprovider.PluggableConfigurationComponent;
 
 /**
  * @author Scott Cantor
  */
-public class XMLMetadataProvider implements Metadata {
+public class XMLMetadataProvider implements Metadata, PluggableConfigurationComponent {
 
        private static Logger log = Logger.getLogger(XMLMetadataProvider.class.getName());
        private Map     /* <String,ArrayList<EntityDescriptor> > */ sites = new HashMap();
@@ -66,7 +67,13 @@ public class XMLMetadataProvider implements Metadata {
     private XMLEntitiesDescriptor rootGroup = null;
 
        public XMLMetadataProvider(Element e) throws SAMLException {
-        if (XML.isElementNamed(e,edu.internet2.middleware.shibboleth.common.XML.SAML2META_NS,"EntitiesDescriptor"))
+        initialize(e);
+       }
+       
+       public XMLMetadataProvider() {} // Must call initialize
+
+       public void initialize(Element e) throws SAMLException {
+               if (XML.isElementNamed(e,edu.internet2.middleware.shibboleth.common.XML.SAML2META_NS,"EntitiesDescriptor"))
             rootGroup=new XMLEntitiesDescriptor(e,this, Long.MAX_VALUE, null);
         else if (XML.isElementNamed(e,edu.internet2.middleware.shibboleth.common.XML.SAML2META_NS,"EntityDescriptor"))
             rootProvider=new XMLEntityDescriptor(e,this, Long.MAX_VALUE, null);
@@ -337,13 +344,11 @@ public class XMLMetadataProvider implements Metadata {
     }
         
     class XMLOrganization implements Organization {
-        private Element root = null;
         private HashMap /* <String,String> */ names = new HashMap();
         private HashMap /* <String,String> */ displays = new HashMap();
         private HashMap /* <String,URL> */ urls = new HashMap();
 
         public XMLOrganization(Element e) throws MetadataException {
-            root = e;
             e=XML.getFirstChildElement(e);
             while (e != null) {
                 if (XML.isElementNamed(e,edu.internet2.middleware.shibboleth.common.XML.SAML2META_NS,"OrganizationName")) {
@@ -423,7 +428,6 @@ public class XMLMetadataProvider implements Metadata {
             }
             else {
                 rawType = root.getAttributeNS(null,"contactType");
-                Node n=null;
                 e=XML.getFirstChildElement(root);
                 while (e != null) {
                     if (XML.isElementNamed(e,edu.internet2.middleware.shibboleth.common.XML.SAML2META_NS,"Company")) {
@@ -522,7 +526,7 @@ public class XMLMetadataProvider implements Metadata {
                         formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                     formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
                     try {
-                        validUntil=Math.min(validUntil,formatter.parse(dateTime).getTime());
+                        this.validUntil=Math.min(validUntil,formatter.parse(dateTime).getTime());
                     }
                     catch (ParseException e1) {
                         log.warn("Role descriptor contains invalid expiration time");
@@ -724,6 +728,7 @@ public class XMLMetadataProvider implements Metadata {
                 }
             }
             else {
+               protocolEnum.add(edu.internet2.middleware.shibboleth.common.XML.SHIB_NS);
                 attrprofs.add(Constants.SHIB_ATTRIBUTE_NAMESPACE_URI);
                 int i;
                 domains = e.getElementsByTagNameNS(edu.internet2.middleware.shibboleth.common.XML.SHIB_NS,"Domain");
@@ -1092,7 +1097,7 @@ public class XMLMetadataProvider implements Metadata {
                         formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                     formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
                     try {
-                        validUntil=Math.min(validUntil,formatter.parse(dateTime).getTime());
+                        this.validUntil=Math.min(validUntil,formatter.parse(dateTime).getTime());
                     }
                     catch (ParseException e1) {
                         log.warn("Entity descriptor contains invalid expiration time");
@@ -1350,7 +1355,7 @@ public class XMLMetadataProvider implements Metadata {
                         formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                     formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
                     try {
-                        validUntil=Math.min(validUntil,formatter.parse(dateTime).getTime());
+                        this.validUntil=Math.min(validUntil,formatter.parse(dateTime).getTime());
                     }
                     catch (ParseException e1) {
                         log.warn("Entities descriptor contains invalid expiration time");