Shut down gracefully when the config file can't be found.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 20 May 2005 00:51:02 +0000 (00:51 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 20 May 2005 00:51:02 +0000 (00:51 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1554 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/idp/IdPConfigLoader.java
src/edu/internet2/middleware/shibboleth/idp/IdPResponder.java

index 1a26aa7..713c3dd 100644 (file)
@@ -90,12 +90,16 @@ public class IdPConfigLoader {
 
                try {
                        idpConfig = Parser.loadDom(configFileLocation, true);
+
+                       if (idpConfig == null) { throw new Exception("IdP configuration could not be loaded from (" + idpConfigFile
+                                       + ")."); }
+
                        if (log.isDebugEnabled()) {
                                log.debug("IdP configuration file " + configFileLocation + " successfully read and cached.");
                        }
                } 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.");
+                       throw new ShibbolethConfigurationException(
+                                       "Encountered an error while parsing Shibboleth Identity Provider configuration file: " + e);
                }
                return idpConfig;
        }
index 818de45..fe641c5 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Iterator;
 import java.util.Random;
 
 import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.UnavailableException;
 import javax.servlet.http.HttpServlet;
@@ -89,9 +90,9 @@ public class IdPResponder extends HttpServlet {
        /*
         * @see javax.servlet.GenericServlet#init()
         */
-       public void init() throws ServletException {
+       public void init(ServletConfig servletConfig) throws ServletException {
 
-               super.init();
+               super.init(servletConfig);
 
                try {
                        binding = SAMLBindingFactory.getInstance(SAMLBinding.SOAP);
@@ -103,8 +104,8 @@ public class IdPResponder extends HttpServlet {
                                        "Logging");
                        if (itemElements.getLength() > 0) {
                                if (itemElements.getLength() > 1) {
-                                       System.err
-                                                       .println("WARNING: More than one Logging element in IdP configuration, using the first one.");
+                                       System.err.println("WARNING: More than one Logging element in IdP configuration, "
+                                                       + "using the first one.");
                                } else {
                                        Element loggingConfig = (Element) itemElements.item(0);
                                        LoggingInitializer.initializeLogging(loggingConfig);
@@ -239,7 +240,10 @@ public class IdPResponder extends HttpServlet {
                        log.info("Identity Provider initialization complete.");
 
                } catch (ShibbolethConfigurationException ae) {
-                       log.fatal("The Identity Provider could not be initialized: " + ae);
+                       servletConfig.getServletContext().log("The Identity Provider could not be initialized: " + ae);
+                       if (log != null) {
+                               log.fatal("The Identity Provider could not be initialized: " + ae);
+                       }
                        throw new UnavailableException("Identity Provider failed to initialize.");
                } catch (SAMLException se) {
                        log.fatal("SAML SOAP binding could not be loaded: " + se);