]> source.dussan.org Git - archiva.git/commitdiff
honor useDefaultRoleName when searching all roles/groups from ldap
authorOlivier Lamy <olamy@apache.org>
Wed, 23 Jan 2013 23:51:43 +0000 (23:51 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 23 Jan 2013 23:51:43 +0000 (23:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1437805 13f79535-47bb-0310-9956-ffa450edef68

redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java
redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java
redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java

index a379a94940724e7b364ce8525bde8ad87e0ca8a6..5cfc431d3ae6f8f069856392f5513e56e6b08d28 100644 (file)
@@ -813,4 +813,14 @@ public class DefaultLdapRoleMapper
     {
         this.userIdAttribute = userIdAttribute;
     }
+
+    public boolean isUseDefaultRoleName()
+    {
+        return useDefaultRoleName;
+    }
+
+    public void setUseDefaultRoleName( boolean useDefaultRoleName )
+    {
+        this.useDefaultRoleName = useDefaultRoleName;
+    }
 }
index 462a53d7cd465bbe72c5016f73f51f325ceebce5..868df6cda851732c9ae3780b4b7b475d74fcf9df 100644 (file)
@@ -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;