Trim trailing whitespace from config properties, since this seems to cause hard to...
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / hs / HandleServlet.java
index 31309ed..00d68c4 100644 (file)
@@ -62,6 +62,7 @@ import java.security.cert.CertificateException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
+import java.util.Enumeration;
 import java.util.Properties;
 
 import javax.servlet.RequestDispatcher;
@@ -167,6 +168,19 @@ public class HandleServlet extends HttpServlet {
                                log.error("Encountered a problem cleaning up resources: could not close debug stream.");
                        }
                }
+               
+               //Be nice and trim "extra" whitespace from config properties
+               Enumeration propNames = properties.propertyNames();
+               while (propNames.hasMoreElements()) {
+                       String propName = (String) propNames.nextElement();
+                       if (properties.getProperty(propName, "").matches(".+\\s$")) {
+                               log.debug(
+                                       "The configuration property ("
+                                               + propName
+                                               + ") contains trailing whitespace.  Trimming... ");
+                               properties.setProperty(propName, properties.getProperty(propName).trim());
+                       }
+               }
 
                return properties;
        }