Exceptions should be bubbling up from the XML parser.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 1 Mar 2005 23:40:34 +0000 (23:40 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 1 Mar 2005 23:40:34 +0000 (23:40 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1256 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/arp/provider/FileSystemArpRepository.java
src/edu/internet2/middleware/shibboleth/aa/attrresolv/AttributeResolver.java
src/edu/internet2/middleware/shibboleth/common/NameMapper.java
src/edu/internet2/middleware/shibboleth/common/OriginConfig.java
src/edu/internet2/middleware/shibboleth/metadata/provider/XMLMetadataLoadWrapper.java
src/edu/internet2/middleware/shibboleth/serviceprovider/ServiceProviderConfig.java
src/edu/internet2/middleware/shibboleth/xml/SchemasDirectoryImpl.java

index 0ff9cef..bdf41b1 100755 (executable)
@@ -52,6 +52,7 @@ import java.io.IOException;
 import java.security.Principal;
 
 import org.apache.log4j.Logger;
+import org.opensaml.SAMLException;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -153,7 +154,11 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
                        }
 
                        Parser.DOMParser parser = new Parser.DOMParser(true);
-                       parser.parse(new InputSource(resource.getInputStream()));
+                       try {
+                               parser.parse(new InputSource(resource.getInputStream()));
+                       } catch (SAMLException e) {
+                               throw new SAXException(e);
+                       }
                        return parser.getDocument().getDocumentElement();
 
                } catch (ShibResource.ResourceNotAvailableException e) {
index fc1bd72..cb91fc8 100644 (file)
@@ -52,6 +52,7 @@ import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
 
 import org.apache.log4j.Logger;
+import org.opensaml.SAMLException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -111,6 +112,9 @@ public class AttributeResolver {
                } catch (IOException e) {
                        log.error("Error reading Attribute Resolver Configuration file: " + e);
                        throw new AttributeResolverException("Error reading Attribute Resolver Configuration file.");
+               } catch (SAMLException e) {
+                       log.error("Error parsing Attribute Resolver Configuration file: " + e);
+                       throw new AttributeResolverException("Error parsing Attribute Resolver Configuration file.");
                }
        }
 
index bcc5a43..92e439f 100644 (file)
@@ -89,7 +89,7 @@ public class NameMapper {
                        String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                        + "<NameMapping format=\"urn:mace:shibboleth:1.0:nameIdentifier\"" + "          handleTTL=\"1800\"/>";
                        Parser.DOMParser parser = new Parser.DOMParser(false);
-                       parser.parse(new InputSource(new StringReader(rawConfig)));
+                       parser.parse(new InputSource(new StringReader(rawConfig)));                     
                        defaultMapping = new SharedMemoryShibHandle(parser.getDocument().getDocumentElement());
 
                } catch (Exception e) {
index ad4579c..103ff44 100644 (file)
@@ -27,6 +27,7 @@
 package edu.internet2.middleware.shibboleth.common;
 
 import javax.servlet.ServletContext;
+
 import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 
@@ -64,20 +65,25 @@ public class OriginConfig {
         */
        public static synchronized Document getOriginConfig(String configFileLocation)
                        throws ShibbolethConfigurationException {
+
                if (configFileLocation.equals(originConfigFile)) {
                        return originConfig;
+                       
                } else if (originConfigFile == null) {
                        originConfigFile = configFileLocation;
+                       
                } else {
                        log.error("Previously read origin configuration from (" + originConfigFile + "), re-reading from ("
                                        + configFileLocation + "). This probably indicates a bug in shibboleth.");
                        originConfigFile = configFileLocation;
                }
-               
-               originConfig = Parser.loadDom(configFileLocation, true);
-               if (originConfig==null)
-                   throw new ShibbolethConfigurationException("Problem in "+XML.ORIGIN_SHEMA_ID+" see log");
 
+               try {
+                       originConfig = Parser.loadDom(configFileLocation, true);
+               } catch (Exception e) {
+                       log.error("Encountered an error while parsing Shibboleth Identity Provider configuration file: " + e);
+                       throw new ShibbolethConfigurationException("Unable to parse IdP configuration file.");
+               }
                return originConfig;
        }
 
index 2330864..210a9a6 100644 (file)
@@ -59,7 +59,7 @@ public class XMLMetadataLoadWrapper extends ResourceWatchdog implements Metadata
                try {
                        Document doc = Parser.loadDom(new InputSource(resource.getInputStream()),true);
                        currentMeta = new XMLMetadata(doc.getDocumentElement());
-               } catch (IOException e) {
+               } catch (Exception e) {
                        log.error("Encountered a problem reading federation metadata source: " + e);
                        throw new MetadataException("Unable to read federation metadata.");
                }
@@ -89,7 +89,7 @@ public class XMLMetadataLoadWrapper extends ResourceWatchdog implements Metadata
                //Load new, but keep the old in place
                try {
             newDoc = Parser.loadDom(new InputSource(resource.getInputStream()),true);
-        } catch (IOException e) {
+        } catch (Exception e) {
                        log.error("Encountered an error retrieving updated federation metadata, continuing to use stale copy.");
                        return;
                }
index 99a6ea2..c934cef 100644 (file)
 
 package edu.internet2.middleware.shibboleth.serviceprovider;
 
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -147,10 +148,12 @@ import org.apache.xmlbeans.XmlOptions;
 import org.opensaml.SAMLAssertion;
 import org.opensaml.SAMLAttribute;
 import org.opensaml.SAMLAttributeStatement;
+import org.opensaml.SAMLException;
 import org.opensaml.SAMLObject;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
 
 import x0.maceShibboleth1.AttributeAcceptancePolicyDocument;
 import x0.maceShibbolethTargetConfig1.ApplicationDocument;
@@ -320,8 +323,9 @@ public class ServiceProviderConfig {
                }
 
                Document configDoc;
-        configDoc = Parser.loadDom(configFilePath, true);
-        if (configDoc==null) {
+        try {
+                       configDoc = Parser.loadDom(configFilePath, true);
+               } catch (Exception e) {
             throw new ShibbolethConfigurationException("XML error in "+configFilePath);
         }
         loadConfigBean(configDoc);
index a0ebc81..de7af06 100644 (file)
@@ -8,6 +8,7 @@
 package edu.internet2.middleware.shibboleth.xml;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.HashMap;
@@ -20,6 +21,7 @@ import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
 import org.apache.log4j.Logger;
+import org.opensaml.SAMLException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
@@ -98,7 +100,13 @@ public class SchemasDirectoryImpl implements Schemas {
             InputSource insrc = new InputSource(inputStream);
            
             // Non-validating parse to DOM
-            Document xsddom = Parser.loadDom(insrc,false);
+            Document xsddom;
+                       try {
+                               xsddom = Parser.loadDom(insrc,false);
+                       } catch (Exception e) {
+                               log.error("Error parsing XML schema (" + filename + "): " + e);
+                               continue;
+                       }
             
             // Get the target namespace from the root element
             Element ele = xsddom.getDocumentElement();