From: Olivier Lamy Date: Wed, 23 Jan 2013 23:51:43 +0000 (+0000) Subject: honor useDefaultRoleName when searching all roles/groups from ldap X-Git-Tag: redback-2.1~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8c91218970dc98484ad0a7ec7656d68734e2dbd;p=archiva.git honor useDefaultRoleName when searching all roles/groups from ldap git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1437805 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java index a379a9494..5cfc431d3 100644 --- a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java +++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java @@ -813,4 +813,14 @@ public class DefaultLdapRoleMapper { this.userIdAttribute = userIdAttribute; } + + public boolean isUseDefaultRoleName() + { + return useDefaultRoleName; + } + + public void setUseDefaultRoleName( boolean useDefaultRoleName ) + { + this.useDefaultRoleName = useDefaultRoleName; + } } diff --git a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java index 7111c4b01..40b953777 100644 --- a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java +++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java @@ -148,4 +148,6 @@ public interface LdapRoleMapper String getUserIdAttribute(); + boolean isUseDefaultRoleName(); + } diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java index 462a53d7c..868df6cda 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java @@ -373,6 +373,25 @@ public class LdapRbacManager } } } + else if ( this.ldapRoleMapper.isUseDefaultRoleName() ) + { + Role role = null; + try + { + role = this.rbacImpl.getRole( group ); + } + catch ( RbacObjectNotFoundException e ) + { + // if it's mapped role to a group it doesn't exist in jdo + } + role = ( role == null ) ? new RoleImpl( group ) : role; + if ( role != null ) + { + rolesCache.put( role.getName(), role ); + roles.add( role ); + } + + } } return roles;