Added some rarely used methods to sync metadata API with C++
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / serviceprovider / ServiceProviderConfig.java
index a5f0a91..c607515 100644 (file)
@@ -178,13 +178,17 @@ import x0.maceShibbolethTargetConfig1.HostDocument.Host.Scheme.Enum;
 import x0.maceShibbolethTargetConfig1.PathDocument.Path;
 import edu.internet2.middleware.shibboleth.aap.AAP;
 import edu.internet2.middleware.shibboleth.aap.AttributeRule;
+import edu.internet2.middleware.shibboleth.aap.provider.XMLAAPProvider;
 import edu.internet2.middleware.shibboleth.common.Credentials;
+import edu.internet2.middleware.shibboleth.common.PluggableConfigurationComponent;
 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
 import edu.internet2.middleware.shibboleth.common.Trust;
 import edu.internet2.middleware.shibboleth.common.provider.ShibbolethTrust;
+import edu.internet2.middleware.shibboleth.metadata.EntitiesDescriptor;
 import edu.internet2.middleware.shibboleth.metadata.EntityDescriptor;
 import edu.internet2.middleware.shibboleth.metadata.Metadata;
 import edu.internet2.middleware.shibboleth.metadata.RoleDescriptor;
+import edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadataProvider;
 import edu.internet2.middleware.shibboleth.xml.Parser;
 
 /**
@@ -645,7 +649,7 @@ public class ServiceProviderConfig {
                try {
                        Node fragment = pluggable.newDomNode();        // XML-Fragment node
                        Node pluggableNode = fragment.getFirstChild(); // PluggableType 
-                       Node contentNode=pluggableNode.getFirstChild();// root element
+                       Element contentNode=(Element) pluggableNode.getFirstChild();// root element
                        impl.initialize(contentNode);
                } catch (Exception e) {
                        initlog.error("XML error " + e);
@@ -662,7 +666,7 @@ public class ServiceProviderConfig {
                        Document extdoc = Parser.loadDom(uri,true);
                        if (extdoc==null)
                            return null;
-                       impl.initialize(extdoc);
+                       impl.initialize(extdoc.getDocumentElement());
                } catch (Exception e) {
                        initlog.error("XML error " + e);
                        return null;
@@ -698,7 +702,7 @@ public class ServiceProviderConfig {
                }
                for (int i = 0;i<pluggable.length;i++) {
                    String uri = processPluggable(pluggable[i],
-                           XMLMetadataImpl.class,
+                           XMLMetadataProvider.class,
                            Metadata.class,
                            XMLFEDERATIONPROVIDERTYPE,
                            entityLocators);
@@ -724,8 +728,8 @@ public class ServiceProviderConfig {
                        Document sitedoc = Parser.loadDom(uri,true);
                        if (sitedoc==null)
                            return false;
-                       XMLMetadataImpl impl = new XMLMetadataImpl();
-                       impl.initialize(sitedoc);
+                       XMLMetadataProvider impl = new XMLMetadataProvider();
+                       impl.initialize(sitedoc.getDocumentElement());
                        addOrReplaceMetadataImplementor(uri,impl);
                } catch (Exception e) {
                        initlog.error("Error while parsing Metadata file "+uri);
@@ -745,7 +749,7 @@ public class ServiceProviderConfig {
                PluggableType[] pluggable = appinfo.getApplicationConfig().getAAPProviderArray();
                for (int i = 0;i<pluggable.length;i++) {
                    String uri = processPluggable(pluggable[i],
-                           XMLAAPImpl.class,
+                               XMLAAPProvider.class,
                            AAP.class,
                            XMLAAPPROVIDERTYPE,
                            attributePolicies);
@@ -772,8 +776,8 @@ public class ServiceProviderConfig {
                        if (aapdoc==null)
                            return false;
                        AttributeAcceptancePolicyDocument aap = AttributeAcceptancePolicyDocument.Factory.parse(aapdoc);
-                       XMLAAPImpl impl = new XMLAAPImpl();
-                       impl.initialize(aapdoc);
+                       XMLAAPProvider impl = new XMLAAPProvider();
+                       impl.initialize(aapdoc.getDocumentElement());
                        addOrReplaceAAPImplementor(uri,impl);
                } catch (Exception e) {
                        initlog.error("Error while parsing AAP file "+uri);
@@ -801,7 +805,7 @@ public class ServiceProviderConfig {
                PluggableType[] pluggable = appinfo.getApplicationConfig().getTrustProviderArray();
                for (int i = 0;i<pluggable.length;i++) {
                    String uri = processPluggable(pluggable[i],
-                           ShibbolethTrustPluggable.class,
+                           ShibbolethTrust.class,
                            Trust.class,
                            XMLTRUSTPROVIDERTYPE,
                            certificateValidators);
@@ -963,12 +967,12 @@ public class ServiceProviderConfig {
                 * @param id ID of the IdP entity
                 * @return EntityDescriptor metadata object for that site.
                 */
-        public EntityDescriptor lookup(String id) {
+        public EntityDescriptor lookup(String id, boolean strict) {
                        Iterator iuris = groupUris.iterator();
                        while (iuris.hasNext()) {
                                String uri =(String) iuris.next();
                                Metadata locator=getMetadataImplementor(uri);
-                               EntityDescriptor entity = locator.lookup(id);
+                               EntityDescriptor entity = locator.lookup(id, strict);
                                if (entity!=null) {
                                        reqlog.debug("Metadata.lookup resolved Entity "+ id);
                                        return entity;
@@ -978,12 +982,12 @@ public class ServiceProviderConfig {
                        return null;
                }
 
-        public EntityDescriptor lookup(Artifact artifact) {
+        public EntityDescriptor lookup(Artifact artifact, boolean strict) {
             Iterator iuris = groupUris.iterator();
             while (iuris.hasNext()) {
                 String uri =(String) iuris.next();
                 Metadata locator=getMetadataImplementor(uri);
-                EntityDescriptor entity = locator.lookup(artifact);
+                EntityDescriptor entity = locator.lookup(artifact, strict);
                 if (entity!=null) {
                                        reqlog.debug("Metadata.lookup resolved Artifact "+ artifact);
                     return entity;
@@ -992,6 +996,22 @@ public class ServiceProviderConfig {
                        reqlog.warn("Metadata.lookup failed to resolve Artifact "+ artifact);
             return null;
         }
+
+               public EntityDescriptor lookup(String id) {
+                       return lookup(id,true);
+               }
+
+               public EntityDescriptor lookup(Artifact artifact) {
+                       return lookup(artifact,true);
+               }
+
+               public EntityDescriptor getRootEntity() {
+                       return null;
+               }
+
+               public EntitiesDescriptor getRootEntities() {
+                       return null;
+               }
         
                /**
                 * Return the current array of objects that implement the Trust interface