[Jboss-cvs] JBossAS SVN: r56787 - projects/security/trunk/src/main/org/jboss/security/auth/spi
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 12 18:05:36 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-09-12 18:05:35 -0400 (Tue, 12 Sep 2006)
New Revision: 56787
Modified:
projects/security/trunk/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java
Log:
SECURITY-6, close all NamingEnumeration results as these delay the close of the context connection.
Modified: projects/security/trunk/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java
===================================================================
--- projects/security/trunk/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java 2006-09-12 21:50:49 UTC (rev 56786)
+++ projects/security/trunk/src/main/org/jboss/security/auth/spi/LdapExtLoginModule.java 2006-09-12 22:05:35 UTC (rev 56787)
@@ -375,6 +375,7 @@
results = ctx.search(baseDN, filter, filterArgs, constraints);
if (results.hasMore() == false)
{
+ results.close();
throw new NamingException("Search of baseDN(" + baseDN + ") found no matches");
}
@@ -409,57 +410,65 @@
{
Object[] filterArgs = {user, userDN};
NamingEnumeration results = ctx.search(rolesCtxDN, roleFilter, filterArgs, constraints);
- while (results.hasMore())
+ try
{
- SearchResult sr = (SearchResult) results.next();
- String dn = canonicalize(sr.getName());
- String[] attrNames = {roleAttributeID};
- Attributes result = ctx.getAttributes(dn, attrNames);
- if( result != null && result.size() > 0 )
- {
- Attribute roles = result.get(roleAttributeID);
- for (int n = 0; n < roles.size(); n ++)
- {
- String roleName = (String) roles.get(n);
- try
- {
- if (roleAttributeIsDN)
- {
- // Query the roleDN location for the value of roleNameAttributeID
- String roleDN = roleName;
- String[] returnAttribute = {roleNameAttributeID};
- log.trace("Using roleDN: " + roleDN);
- try
- {
- result = ctx.getAttributes(roleDN, returnAttribute);
- if (result.get(roleNameAttributeID) != null)
- {
- roleName = result.get(roleNameAttributeID).get().toString();
- }
- }
- catch (NamingException e)
- {
- log.trace("Failed to query roleNameAttrName", e);
- }
- }
-
- Principal p = super.createIdentity(roleName);
- log.trace("Assign user to role " + roleName);
- userRoles.addMember(p);
- }
- catch (Exception e)
- {
- log.debug("Failed to create principal: " + roleName, e);
- }
- }
- }
-
- if (nesting < recursionMax)
- {
- rolesSearch(ctx, constraints, user, dn,
- recursionMax, nesting + 1);
- }
+ while (results.hasMore())
+ {
+ SearchResult sr = (SearchResult) results.next();
+ String dn = canonicalize(sr.getName());
+ String[] attrNames = {roleAttributeID};
+ Attributes result = ctx.getAttributes(dn, attrNames);
+ if( result != null && result.size() > 0 )
+ {
+ Attribute roles = result.get(roleAttributeID);
+ for (int n = 0; n < roles.size(); n ++)
+ {
+ String roleName = (String) roles.get(n);
+ try
+ {
+ if (roleAttributeIsDN)
+ {
+ // Query the roleDN location for the value of roleNameAttributeID
+ String roleDN = roleName;
+ String[] returnAttribute = {roleNameAttributeID};
+ log.trace("Using roleDN: " + roleDN);
+ try
+ {
+ result = ctx.getAttributes(roleDN, returnAttribute);
+ if (result.get(roleNameAttributeID) != null)
+ {
+ roleName = result.get(roleNameAttributeID).get().toString();
+ }
+ }
+ catch (NamingException e)
+ {
+ log.trace("Failed to query roleNameAttrName", e);
+ }
+ }
+
+ Principal p = super.createIdentity(roleName);
+ log.trace("Assign user to role " + roleName);
+ userRoles.addMember(p);
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to create principal: " + roleName, e);
+ }
+ }
+ }
+
+ if (nesting < recursionMax)
+ {
+ rolesSearch(ctx, constraints, user, dn,
+ recursionMax, nesting + 1);
+ }
+ }
}
+ finally
+ {
+ if( results != null )
+ results.close();
+ }
}
More information about the jboss-cvs-commits
mailing list