Commit fb5dec24 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added support for setting LDAP read timeout. JM-941

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6748 b35dd754-fafc-0310-a699-88a17e54d16e
parent d02a8865
...@@ -118,6 +118,12 @@ ...@@ -118,6 +118,12 @@
To specify many LDAP servers use the comma or the white space character as delimiter.</li> To specify many LDAP servers use the comma or the white space character as delimiter.</li>
<li>ldap.port -- LDAP server port number. If this property is not set, the default value is <li>ldap.port -- LDAP server port number. If this property is not set, the default value is
389.</li> 389.</li>
<li>ldap.readTimeout -- The value of this property is the string representation of an integer
representing the read timeout in milliseconds for LDAP operations. If the LDAP provider doesn't
get an LDAP response within the specified period, it aborts the read attempt. The integer should
be greater than zero. An integer less than or equal to zero means no read timeout is specified which
is equivalent to waiting for the response infinitely until it is received which defaults
to the original behavior. <i>Requires Java 1.6 or later.</i></li>
<li>ldap.baseDN <font color="red"><b>*</b></font> -- the starting DN that searches for users <li>ldap.baseDN <font color="red"><b>*</b></font> -- the starting DN that searches for users
will performed with. will performed with.
The entire subtree under the base DN will be searched for user accounts. The entire subtree under the base DN will be searched for user accounts.
......
...@@ -128,6 +128,7 @@ public class LdapManager { ...@@ -128,6 +128,7 @@ public class LdapManager {
private Collection<String> hosts = new ArrayList<String>(); private Collection<String> hosts = new ArrayList<String>();
private int port; private int port;
private int readTimeout = -1;
private String usernameField; private String usernameField;
private String nameField; private String nameField;
private String emailField; private String emailField;
...@@ -193,6 +194,15 @@ public class LdapManager { ...@@ -193,6 +194,15 @@ public class LdapManager {
Log.error(nfe); Log.error(nfe);
} }
} }
String timeout = properties.get("ldap.readTimeout");
if (timeout != null) {
try {
this.readTimeout = Integer.parseInt(timeout);
}
catch (NumberFormatException nfe) {
Log.error(nfe);
}
}
usernameField = properties.get("ldap.usernameField"); usernameField = properties.get("ldap.usernameField");
if (usernameField == null) { if (usernameField == null) {
...@@ -430,6 +440,9 @@ public class LdapManager { ...@@ -430,6 +440,9 @@ public class LdapManager {
if (!sslEnabled) { if (!sslEnabled) {
env.put("com.sun.jndi.ldap.connect.timeout", "10000"); env.put("com.sun.jndi.ldap.connect.timeout", "10000");
} }
if (readTimeout > 0) {
env.put("com.sun.jndi.ldap.read.timeout", String.valueOf(readTimeout));
}
if (ldapDebugEnabled) { if (ldapDebugEnabled) {
env.put("com.sun.jndi.ldap.trace.ber", System.err); env.put("com.sun.jndi.ldap.trace.ber", System.err);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment