From 174964a0b06a61ce63d4fd8c83265c3c46c2176d Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 16 Dec 2009 11:04:24 +0000 Subject: [PATCH] Side issues from bug 47841 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 | 43 +++++++++++++++++++++++++++ webapps/docs/config/realm.xml | 6 ++++ 2 files changed, 49 insertions(+) diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java index c3dc967ad..bb32f71b0 100644 --- a/java/org/apache/catalina/realm/JNDIRealm.java +++ b/java/org/apache/catalina/realm/JNDIRealm.java @@ -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 + * <description>/<version>. + */ + @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; diff --git a/webapps/docs/config/realm.xml b/webapps/docs/config/realm.xml index 540a46504..de2aee7ce 100644 --- a/webapps/docs/config/realm.xml +++ b/webapps/docs/config/realm.xml @@ -336,6 +336,12 @@ property.

+ +

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.

+
+

The connection URL to be passed to the JNDI driver when establishing a connection to the directory.

-- 2.11.0