From 28a93c17b4d65207f764b3291225cac20af0a004 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Thu, 12 Jan 2012 17:41:47 +0100 Subject: [PATCH] Bug #1333: Allow specify * in role matching This will be a wildcard to refer to all users or groups in the LDAP role matching configuration. FEA: ItEr76S04BugFixing --- .../LDAPCustomAuthenticationProvider.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java index 4fd7f4ac5..f30d5851f 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java @@ -97,6 +97,12 @@ public class LDAPCustomAuthenticationProvider extends private static final Log LOG = LogFactory .getLog(LDAPCustomAuthenticationProvider.class); + /** + * LDAP role matching could be configured using an asterix (*) to specify + * all users or groups + */ + private static final String WILDCHAR_ALL = "*"; + @Override protected void additionalAuthenticationChecks(UserDetails arg0, UsernamePasswordAuthenticationToken arg1) @@ -287,6 +293,11 @@ public class LDAPCustomAuthenticationProvider extends List rolesReturn = new ArrayList(); for (ConfigurationRolesLDAP roleLDAP : rolesLdap) { + if (roleLDAP.getRoleLdap().equals(WILDCHAR_ALL)) { + rolesReturn.add(roleLDAP.getRoleLibreplan()); + continue; + } + // We must make a search for each role-matching in nodes List resultsSearch = new ArrayList(); resultsSearch.addAll(ldapTemplate.search( @@ -317,6 +328,11 @@ public class LDAPCustomAuthenticationProvider extends List rolesReturn = new ArrayList(); for (ConfigurationRolesLDAP roleLdap : rolesLdap) { + if (roleLdap.getRoleLdap().equals(WILDCHAR_ALL)) { + rolesReturn.add(roleLdap.getRoleLibreplan()); + continue; + } + // We must make a search for each role matching DirContextAdapter adapter = null; try {