Side issues from bug 47841
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 16 Dec 2009 11:04:24 +0000 (11:04 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 16 Dec 2009 11:04:24 +0000 (11:04 +0000)
Override getInfo() log messages that use it have useful info
Add support for a connectionTimeout attribute

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

java/org/apache/catalina/realm/JNDIRealm.java
webapps/docs/config/realm.xml

index c3dc967..bb32f71 100644 (file)
@@ -380,6 +380,12 @@ public class JNDIRealm extends RealmBase {
     protected String commonRole = null;
 
 
+    /**
+     * The timeout, in milliseconds, to use when trying to create a connection
+     * to the directory. The default is 5000 (5 seconds).
+     */
+    protected String connectionTimeout = "5000";
+    
     // ------------------------------------------------------------- Properties
 
     /**
@@ -870,6 +876,41 @@ public class JNDIRealm extends RealmBase {
     }
 
 
+    /**
+     * Return the connection timeout.
+     */
+    public String getConnectionTimeout() {
+
+        return connectionTimeout;
+
+    }
+
+
+    /**
+     * Set the connection timeout.
+     *
+     * @param timeout The new connection timeout
+     */
+    public void setConnectionTimeout(String timeout) {
+
+        this.connectionTimeout = timeout;
+
+    }
+
+
+    /**
+     * Return descriptive information about this Realm implementation and
+     * the corresponding version number, in the format
+     * <code>&lt;description&gt;/&lt;version&gt;</code>.
+     */
+    @Override
+       public String getInfo() {
+
+        return info;
+
+    }
+
+
     // ---------------------------------------------------------- Realm Methods
 
 
@@ -1962,6 +2003,8 @@ public class JNDIRealm extends RealmBase {
             env.put(Context.REFERRAL, referrals);
         if (derefAliases != null)
             env.put(JNDIRealm.DEREF_ALIASES, derefAliases);
+        if (connectionTimeout != null)
+               env.put("com.sun.jndi.ldap.connect.timeout", connectionTimeout);
 
         return env;
 
index 540a465..de2aee7 100644 (file)
         property.</p>
       </attribute>
 
+      <attribute name="connectionTimeout" required="false">
+        <p>The timeout in milliseconds to use when establishing the connection
+        to the LDAP directory. If not specified, a value of 5000 (5 seconds) is
+        used.</p>
+      </attribute>
+
       <attribute name="connectionURL" required="true">
         <p>The connection URL to be passed to the JNDI driver when
         establishing a connection to the directory.</p>