patches for new XML interface in OpenSAML
authorcantor <cantor@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 31 Oct 2002 20:25:04 +0000 (20:25 +0000)
committercantor <cantor@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 31 Oct 2002 20:25:04 +0000 (20:25 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@337 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/eduPerson/Init.java
src/edu/internet2/middleware/shibboleth/common/Init.java
src/edu/internet2/middleware/shibboleth/common/ShibPOSTProfile.java
src/edu/internet2/middleware/shibboleth/common/SiteSigner.java
src/edu/internet2/middleware/shibboleth/shire/XMLOriginSiteMapper.java

index 043490a..c4141d9 100755 (executable)
@@ -49,8 +49,6 @@
 
 package edu.internet2.middleware.eduPerson;
 
-import javax.xml.parsers.ParserConfigurationException;
-
 /**
  *  Handles one-time library initialization
  *
@@ -70,14 +68,7 @@ public class Init
         initialized = true;
         
         edu.internet2.middleware.shibboleth.common.Init.init();
-        try
-        {
-            org.opensaml.XML.parserPool.registerExtension(XML.EDUPERSON_NS, XML.EDUPERSON_SCHEMA_ID, new XML.SchemaResolver());
-        }
-        catch (ParserConfigurationException e)
-        {
-            throw new RuntimeException("Init.init() unable to register extension schema");
-        }
+        org.opensaml.XML.parserPool.registerSchema(XML.EDUPERSON_NS, XML.EDUPERSON_SCHEMA_ID, new XML.SchemaResolver());
     }
 
     static
index 5740996..56e3aa1 100755 (executable)
@@ -49,8 +49,6 @@
 
 package edu.internet2.middleware.shibboleth.common;
 
-import javax.xml.parsers.ParserConfigurationException;
-
 import edu.internet2.middleware.shibboleth.common.XML.SchemaResolver;
 
 /**
@@ -72,14 +70,7 @@ public class Init
         initialized = true;
         
         org.opensaml.Init.init();
-        try
-        {
-            org.opensaml.XML.parserPool.registerExtension(XML.SHIB_NS, XML.SHIB_SCHEMA_ID, new XML.SchemaResolver());
-        }
-        catch (ParserConfigurationException e)
-        {
-            throw new RuntimeException("Init.init() unable to register extension schema");
-        }
+        org.opensaml.XML.parserPool.registerSchema(XML.SHIB_NS, XML.SHIB_SCHEMA_ID, new XML.SchemaResolver());
     }
 
     static
index 5e7b9e1..4840bcb 100755 (executable)
@@ -59,8 +59,6 @@ import java.util.Date;
 import java.util.Enumeration;
 import java.util.Iterator;
 import javax.crypto.SecretKey;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.log4j.Logger;
 import org.apache.xml.security.exceptions.XMLSecurityException;
@@ -278,11 +276,9 @@ public class ShibPOSTProfile
         if (assertionKey != null && !(assertionKey instanceof PrivateKey) && !(assertionKey instanceof SecretKey))
             throw new InvalidCryptoException(SAMLException.RESPONDER, "ShibPOSTProfile.prepare() detected an invalid type of assertion key");
 
-        DocumentBuilder builder = null;
         try
         {
-            builder = org.opensaml.XML.parserPool.get();
-            Document doc = builder.newDocument();
+            Document doc = org.opensaml.XML.parserPool.newDocument();
 
             XMLSignature rsig = new XMLSignature(doc, null, algorithm);
             XMLSignature asig = null;
@@ -320,19 +316,10 @@ public class ShibPOSTProfile
                 rsig.sign((SecretKey)responseKey);
             return r;
         }
-        catch (ParserConfigurationException pce)
-        {
-            throw new SAMLException(SAMLException.RESPONDER, "ShibPOSTProfile.prepare() unable to obtain XML parser instance: " + pce.getMessage(), pce);
-        }
         catch (XMLSecurityException e)
         {
             throw new InvalidCryptoException(SAMLException.RESPONDER, "ShibPOSTProfile.prepare() detected an XML security problem during signature creation", e);
         }
-        finally
-        {
-            if (builder != null)
-                org.opensaml.XML.parserPool.put(builder);
-        }
     }
 
     /**
index 577be4a..3502b24 100644 (file)
@@ -52,7 +52,6 @@ package edu.internet2.middleware.shibboleth.common;
 import java.io.*;
 import java.security.*;
 import java.security.cert.*;
-import javax.xml.parsers.*;
 import org.apache.xml.security.c14n.*;
 import org.apache.xml.security.signature.*;
 import org.apache.xml.security.transforms.*;
@@ -162,8 +161,7 @@ public class SiteSigner
             System.exit(1);
         }
 
-        DocumentBuilder builder = org.opensaml.XML.parserPool.get();
-        Document doc = builder.parse(arg);
+        Document doc = org.opensaml.XML.parserPool.parse(arg);
         Element e = doc.getDocumentElement();
         if (!XML.SHIB_NS.equals(e.getNamespaceURI()) || !"Sites".equals(e.getLocalName()))
         {
index e8ccd41..1aeac74 100755 (executable)
@@ -57,9 +57,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Vector;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-
 import org.apache.log4j.Logger;
 import org.apache.xml.security.c14n.Canonicalizer;
 import org.apache.xml.security.exceptions.XMLSecurityException;
@@ -110,11 +107,8 @@ public class XMLOriginSiteMapper implements OriginSiteMapper {
                originSites = new HashMap();
                hsKeys = new HashMap();
 
-               DocumentBuilder builder = null;
                try {
-                       builder = org.opensaml.XML.parserPool.get();
-                       Document doc;
-                       doc = builder.parse(registryURI);
+                       Document doc=org.opensaml.XML.parserPool.parse(registryURI);
                        log.info("Located site file (" +registryURI +").");
                        Element e = doc.getDocumentElement();
                        if (!XML.SHIB_NS.equals(e.getNamespaceURI()) || !"Sites".equals(e.getLocalName())) {
@@ -186,13 +180,10 @@ public class XMLOriginSiteMapper implements OriginSiteMapper {
                } catch (IOException e) {
                        log.error("Problem accessing site configuration" + e);
                        throw new OriginSiteMapperException("Problem accessing site configuration" + e);
-               } catch (ParserConfigurationException pce) {
-                       log.error("Parser configuration error" + pce);
-                       throw new OriginSiteMapperException("Parser configuration error" + pce);
-               } finally {
-                       if (builder != null)
-                               org.opensaml.XML.parserPool.put(builder);
-               }
+               } catch (org.opensaml.SAMLException e) {
+                        log.error("Problem configuring parser: " + e);
+                        throw new OriginSiteMapperException("Problem configuring parser: " + e);
+                }
        }
 
        private void validateSignature(Key verifyKey, Element e) throws OriginSiteMapperException {