jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r731934 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config: BeanConfig.java LoginModuleConfig.java RepositoryConfigurationParser.java SearchConfig.java
Date Tue, 06 Jan 2009 13:12:16 GMT
Author: jukka
Date: Tue Jan  6 05:12:14 2009
New Revision: 731934

URL: http://svn.apache.org/viewvc?rev=731934&view=rev
Log:
JCR-1920: Upgrade from 1.4.5 to 1.5 creates exception for LDAP authentication 

Disable validation of bean properties for LoginModule, AccessControlProvider, and SearchIndex
configuration elements where the parameters are used not only as bean properties.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SearchConfig.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java?rev=731934&r1=731933&r2=731934&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
Tue Jan  6 05:12:14 2009
@@ -53,6 +53,18 @@
     private final Properties properties;
 
     /**
+     * Flag to validate the configured bean property names against
+     * the configured bean class. By default this is <code>true</code>
+     * to prevent incorrect property names. However, in some cases this
+     * validation should not be performed as client classes may access
+     * the configuration parameters directly through the
+     * {@link #getParameters()} method.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-1920">JCR-1920</a>
+     */
+    private boolean validate = true;
+
+    /**
      * Creates a bean configuration. Note that a copy of the given
      * bean properties is stored as a part of the created configuration
      * object. Thus the caller is free to modify the given properties
@@ -76,6 +88,16 @@
     }
 
     /**
+     * Allows subclasses to control whether the configured bean property
+     * names should be validated.
+     *
+     * @param validate flag to validate the configured property names
+     */
+    protected void setValidate(boolean validate) {
+        this.validate = validate;
+    }
+
+    /**
      * Returns the class name of the configured bean.
      *
      * @return class name of the bean
@@ -101,9 +123,12 @@
      */
     public Object newInstance() throws ConfigurationException {
         try {
+            // Instantiate the object using the default constructor
             Class objectClass =
                 Class.forName(getClassName(), true, getClassLoader());
             Object object = objectClass.newInstance();
+
+            // Set all configured bean properties
             BeanMap map = new BeanMap(object);
             Iterator iterator = map.keyIterator();
             while (iterator.hasNext()) {
@@ -113,15 +138,23 @@
                     map.put(name, properties.getProperty(name));
                 }
             }
-            Iterator it = properties.keySet().iterator();
-            while (it.hasNext()) {
-                String key = (String) it.next();
-                if (!map.containsKey(key) && properties.getProperty(key) != null)
{
-                    String msg = object.getClass().getName() + " does not support '" + key;
-                    log.error(msg);
-                    throw new ConfigurationException(msg);
+
+            if (validate) {
+                // Check that no invalid property names were configured
+                Iterator it = properties.keySet().iterator();
+                while (it.hasNext()) {
+                    String key = (String) it.next();
+                    if (!map.containsKey(key) && properties.getProperty(key) != null)
{
+                        String msg =
+                            "Configured class " + object.getClass().getName()
+                            + " does not contain the property " + key
+                            + ". Please fix the repository configuration.";
+                        log.error(msg);
+                        throw new ConfigurationException(msg);
+                    }
                 }
             }
+
             return object;
         } catch (ClassNotFoundException e) {
             throw new ConfigurationException(

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java?rev=731934&r1=731933&r2=731934&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
Tue Jan  6 05:12:14 2009
@@ -56,6 +56,7 @@
      */
     public LoginModuleConfig(BeanConfig config) {
         super(config);
+        setValidate(false); // JCR-1920
     }
 
     public LoginModule getLoginModule() throws ConfigurationException {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=731934&r1=731933&r2=731934&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
Tue Jan  6 05:12:14 2009
@@ -522,6 +522,7 @@
             Element provFact = getElement(element, AC_PROVIDER_ELEMENT, false);
             if (provFact !=null ) {
                 factConf = parseBeanConfig(element, AC_PROVIDER_ELEMENT);
+                factConf.setValidate(false); // JCR-1920
             }
         }
         return new WorkspaceSecurityConfig(factConf);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SearchConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SearchConfig.java?rev=731934&r1=731933&r2=731934&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SearchConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SearchConfig.java
Tue Jan  6 05:12:14 2009
@@ -50,6 +50,7 @@
     public SearchConfig(
             String className, Properties properties, FileSystemFactory fsf) {
         super(className, properties);
+        setValidate(false); // JCR-1920: SearchManager uses getParameters()
         this.fsf = fsf;
     }
 



Mime
View raw message