[Jboss-cvs] JBossAS SVN: r55448 - branches/MC_VDF_WORK/security/src/main/org/jboss/security/auth/spi
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 9 14:31:26 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-08-09 14:31:24 -0400 (Wed, 09 Aug 2006)
New Revision: 55448
Modified:
branches/MC_VDF_WORK/security/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java
Log:
JBAS-3448, make sure the ldap ctx created is closed when failures occur
Modified: branches/MC_VDF_WORK/security/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java
===================================================================
--- branches/MC_VDF_WORK/security/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java 2006-08-09 18:18:22 UTC (rev 55447)
+++ branches/MC_VDF_WORK/security/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java 2006-08-09 18:31:24 UTC (rev 55448)
@@ -328,17 +328,25 @@
searchScope = SearchControls.SUBTREE_SCOPE;
// Get the admin context for searching
- InitialLdapContext ctx = constructInitialLdapContext(bindDN, bindCredential);
- // Validate the user by binding against the userDN
- String userDN = bindDNAuthentication(ctx, username, credential, baseDN, baseFilter);
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = constructInitialLdapContext(bindDN, bindCredential);
+ // Validate the user by binding against the userDN
+ String userDN = bindDNAuthentication(ctx, username, credential, baseDN, baseFilter);
- // Query for roles matching the role filter
- SearchControls constraints = new SearchControls();
- constraints.setSearchScope(searchScope);
- constraints.setReturningAttributes(new String[0]);
- constraints.setTimeLimit(searchTimeLimit);
- rolesSearch(ctx, constraints, username, userDN, recursion, 0);
- ctx.close();
+ // Query for roles matching the role filter
+ SearchControls constraints = new SearchControls();
+ constraints.setSearchScope(searchScope);
+ constraints.setReturningAttributes(new String[0]);
+ constraints.setTimeLimit(searchTimeLimit);
+ rolesSearch(ctx, constraints, username, userDN, recursion, 0);
+ }
+ finally
+ {
+ if( ctx != null )
+ ctx.close();
+ }
return true;
}
@@ -489,13 +497,12 @@
private void traceLdapEnv(Properties env)
{
- if(trace)
- {
- Properties tmp = new Properties();
- tmp.putAll(env);
- tmp.setProperty(Context.SECURITY_CREDENTIALS, "***");
- log.trace("Logging into LDAP server, env=" + tmp.toString());
- }
- }
-
+ if(trace)
+ {
+ Properties tmp = new Properties();
+ tmp.putAll(env);
+ tmp.setProperty(Context.SECURITY_CREDENTIALS, "***");
+ log.trace("Logging into LDAP server, env=" + tmp.toString());
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list