Commit 3eb4af5a authored by Matt Tucker's avatar Matt Tucker Committed by matt

Code cleanup.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5375 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3e84d04c
...@@ -59,6 +59,8 @@ import java.util.regex.Pattern; ...@@ -59,6 +59,8 @@ import java.util.regex.Pattern;
* <li>ldap.autoFollowReferrals</li> * <li>ldap.autoFollowReferrals</li>
* <li>ldap.initialContextFactory -- if this value is not specified, * <li>ldap.initialContextFactory -- if this value is not specified,
* "com.sun.jndi.ldap.LdapCtxFactory" will be used.</li> * "com.sun.jndi.ldap.LdapCtxFactory" will be used.</li>
* <li>ldap.connectionPoolEnabled -- true if an LDAP connection pool should be used.
* False if not set.</li>
* </ul> * </ul>
* *
* @author Matt Tucker * @author Matt Tucker
...@@ -308,9 +310,13 @@ public class LdapManager { ...@@ -308,9 +310,13 @@ public class LdapManager {
catch (NamingException ne) { catch (NamingException ne) {
// If an alt baseDN is defined, attempt a lookup there. // If an alt baseDN is defined, attempt a lookup there.
if (alternateBaseDN != null) { if (alternateBaseDN != null) {
try { ctx.close(); } try {
catch (Exception ignored) { if (ctx != null) {
// Ignore. ctx.close();
}
}
catch (Exception e) {
Log.error(e);
} }
try { try {
// See if the user authenticates. // See if the user authenticates.
...@@ -326,7 +332,7 @@ public class LdapManager { ...@@ -326,7 +332,7 @@ public class LdapManager {
env.put(Context.SECURITY_PRINCIPAL, userDN + "," + alternateBaseDN); env.put(Context.SECURITY_PRINCIPAL, userDN + "," + alternateBaseDN);
env.put(Context.SECURITY_CREDENTIALS, password); env.put(Context.SECURITY_CREDENTIALS, password);
// Specify timeout to be 10 seconds, only on non SSL since SSL connections // Specify timeout to be 10 seconds, only on non SSL since SSL connections
// break with a teimout. // break with a timemout.
if (!sslEnabled) { if (!sslEnabled) {
env.put("com.sun.jndi.ldap.connect.timeout", "10000"); env.put("com.sun.jndi.ldap.connect.timeout", "10000");
} }
...@@ -359,9 +365,13 @@ public class LdapManager { ...@@ -359,9 +365,13 @@ public class LdapManager {
} }
} }
finally { finally {
try { ctx.close(); } try {
catch (Exception ignored) { if (ctx != null) {
// Ignore. ctx.close();
}
}
catch (Exception e) {
Log.error(e);
} }
} }
return true; return true;
......
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