Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45332
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 25 Mar 2009 17:49:14 +0000 (17:49 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 25 Mar 2009 17:49:14 +0000 (17:49 +0000)
When reading tomcat-users.xml try to ensure the digester supports the java encoding names. The windows installer will often use these names. The JVM does this by default. If the endorsed mechanism is used, an alternative parser may not support the Java encodings. This fix will only work for xerces.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@758365 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/realm/LocalStrings.properties
java/org/apache/catalina/realm/MemoryRealm.java
java/org/apache/catalina/users/LocalStrings.properties
java/org/apache/catalina/users/MemoryUserDatabase.java

index 88b42e4..6c4c7cf 100644 (file)
@@ -64,6 +64,7 @@ memoryRealm.authenticateSuccess=Username {0} successfully authenticated
 memoryRealm.loadExist=Memory database file {0} cannot be read
 memoryRealm.loadPath=Loading users from memory database file {0}
 memoryRealm.readXml=Exception while reading memory database file
+memoryRealm.xmlFeatureEncoding=Exception configuring digester to permit java encoding names in XML files. Only IANA encoding names will be supported.
 realmBase.algorithm=Invalid message digest algorithm {0} specified
 realmBase.alreadyStarted=This Realm has already been started
 realmBase.digest=Error digesting user credentials
index 343a8d4..7a8bd0f 100644 (file)
@@ -215,6 +215,13 @@ public class MemoryRealm  extends RealmBase {
         if (digester == null) {
             digester = new Digester();
             digester.setValidating(false);
+            try {
+                digester.setFeature(
+                        "http://apache.org/xml/features/allow-java-encodings",
+                        true);
+            } catch (Exception e) {
+                log.warn(sm.getString("memoryRealm.xmlFeatureEncoding"), e);
+            }
             digester.addRuleSet(new MemoryRuleSet());
         }
         return (digester);
index 117f165..d13ba39 100644 (file)
@@ -19,3 +19,4 @@ memoryUserDatabase.renameNew=Cannot rename new file to {0}
 memoryUserDatabase.writeException=IOException writing to {0}
 memoryUserDatabase.notPersistable=User database is not persistable - no write permissions on directory
 memoryUserDatabase.readOnly=User database has been configured to be read only. Changes cannot be saved
+memoryUserDatabase.xmlFeatureEncoding=Exception configuring digester to permit java encoding names in XML files. Only IANA encoding names will be supported.
index b9199cb..c4c8077 100644 (file)
@@ -387,6 +387,13 @@ public class MemoryUserDatabase implements UserDatabase {
 
                 // Construct a digester to read the XML input file
                 Digester digester = new Digester();
+                try {
+                    digester.setFeature(
+                            "http://apache.org/xml/features/allow-java-encodings",
+                            true);
+                } catch (Exception e) {
+                    log.warn(sm.getString("memoryUserDatabase.xmlFeatureEncoding"), e);
+                }
                 digester.addFactoryCreate
                     ("tomcat-users/group",
                      new MemoryGroupCreationFactory(this));