Added stand-alone query role.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / xml / Parser.java
index 5c679b0..8ae7d5b 100644 (file)
@@ -46,6 +46,9 @@ import javax.xml.transform.stream.StreamResult;
 import javax.xml.validation.Schema;
 
 import org.apache.log4j.Logger;
+import org.apache.xml.security.c14n.CanonicalizationException;
+import org.apache.xml.security.c14n.Canonicalizer;
+import org.apache.xml.security.c14n.InvalidCanonicalizerException;
 import org.opensaml.SAMLException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -82,6 +85,7 @@ public class Parser {
             "urn:mace:shibboleth:arp:1.0",
             "urn:mace:shibboleth:resolver:1.0",
             "urn:oasis:names:tc:SAML:2.0:metadata",
+            "urn:oasis:names:tc:SAML:metadata:extension",
             "urn:mace:shibboleth:target:config:1.0",
             "urn:mace:shibboleth:trust:1.0",
             "urn:mace:shibboleth:metadata:1.0",
@@ -96,6 +100,7 @@ public class Parser {
             "namemapper.xsd",
             "saml-schema-assertion-2.0.xsd",
             "saml-schema-metadata-2.0.xsd",
+            "saml-schema-metadata-ext.xsd",
             "shibboleth-arp-1.0.xsd",
             "shibboleth-idpconfig-1.0.xsd",
             "shibboleth-metadata-1.0.xsd",
@@ -220,6 +225,32 @@ public class Parser {
     }
     
     /**
+     *  Serializes the XML representation of the SAML object to a stream
+     *
+     * @param  out                      Stream to use for output
+     * @exception  java.io.IOException  Raised if an I/O problem is detected
+     * @exception  SAMLException Raised if the object is incompletely defined 
+     */
+    public static String serializeC14N(Node root){
+       byte[] bs = null;
+        try
+        {
+            Canonicalizer c = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
+            bs = c.canonicalizeSubtree(root, "#default saml samlp ds xsd xsi code kind rw typens");
+        }
+        catch (InvalidCanonicalizerException e)
+        {
+            return null;
+        }
+        catch (CanonicalizationException e)
+        {
+            return null;
+        }
+        return new String(bs);
+    }
+
+    
+    /**
      * Version of loadDom where the file is specified as a resource name
      * 
      * @param configFilePath input resource