]> source.dussan.org Git - archiva.git/commitdiff
Adding id methods for roles
authorMartin Stockhammer <martin_s@apache.org>
Thu, 26 Nov 2020 21:21:03 +0000 (22:21 +0100)
committerMartin Stockhammer <martin_s@apache.org>
Thu, 26 Nov 2020 21:21:03 +0000 (22:21 +0100)
archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java
archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java
archiva-modules/archiva-base/archiva-security-common/src/main/java/org/apache/archiva/security/common/ArchivaRoleConstants.java
archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java

index 26e891dcb6ed4defec94a9edc86cd1e943220ca3..a74d5bc8c4bf7012aa190633caa36f4978301b6f 100644 (file)
@@ -144,19 +144,31 @@ public class TestRBACManager implements RBACManager
     }
 
     @Override
-    public Map<String, Role> getChildRoles( Role role )
+    public Map<String, Role> getChildRoleNames( Role role )
         throws RbacManagerException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
     @Override
-    public Map<String, Role> getParentRoles( Role role )
+    public Map<String, ? extends Role> getChildRoleIds( Role role ) throws RbacManagerException
+    {
+        return null;
+    }
+
+    @Override
+    public Map<String, Role> getParentRoleNames( Role role )
         throws RbacManagerException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
+    @Override
+    public Map<String, ? extends Role> getParentRoleIds( Role role ) throws RbacManagerException
+    {
+        return null;
+    }
+
     @Override
     public List<Role> getAllRoles()
         throws RbacManagerException
@@ -399,7 +411,7 @@ public class TestRBACManager implements RBACManager
     }
 
     @Override
-    public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
+    public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleIds )
         throws RbacManagerException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
index dd87dfc040072001bc747cfcc97fcc4ff4b570ad..c0a04da748fbe8f54c5b5282eaeff6615cd1b65e 100644 (file)
@@ -47,10 +47,11 @@ public class TestRoleManager
     }
 
     @Override
-    public void createTemplatedRole( String templateId, String resource )
+    public String createTemplatedRole( String templateId, String resource )
         throws RoleManagerException
     {
         //To change body of implemented methods use File | Settings | File Templates.
+        return null;
     }
 
     @Override
@@ -61,10 +62,11 @@ public class TestRoleManager
     }
 
     @Override
-    public void moveTemplatedRole( String templateId, String oldResource, String newResource )
+    public String moveTemplatedRole( String templateId, String oldResource, String newResource )
         throws RoleManagerException
     {
         //To change body of implemented methods use File | Settings | File Templates.
+        return null;
     }
 
     @Override
index 36ab17c6a33534f996aaf049a6ba38a194cfc183..4700d964659f0fe82382c5ce7071635bc567e451 100644 (file)
@@ -40,6 +40,7 @@ public class ArchivaRoleConstants
     public static final String REPOSITORY_MANAGER_ROLE_PREFIX = "Repository Manager";
 
     public static final String REPOSITORY_OBSERVER_ROLE_PREFIX = "Repository Observer";
+    public static final String REPOSITORY_OBSERVER_ROLE_ID_PREFIX = "archiva-repository-observer";
 
     // operations
     public static final String OPERATION_MANAGE_USERS = "archiva-manage-users";
@@ -87,4 +88,9 @@ public class ArchivaRoleConstants
     {
         return REPOSITORY_OBSERVER_ROLE_PREFIX + " - " + repoId;
     }
+
+    public static String toRepositoryObserverRoleId( String repoId )
+    {
+        return REPOSITORY_OBSERVER_ROLE_ID_PREFIX + "." + repoId;
+    }
 }
index 6487e9d23f272b7c3201c9296e3e4dd8bc8d170d..d877c69f1c924ec41bd473b8002cf4a070067867 100644 (file)
@@ -170,7 +170,7 @@ public abstract class AbstractSecurityTest
             log.info( "ignore RbacObjectNotFoundException for id {} during restoreGuestInitialValues", userId );
             return;
         }
-        userAssignment.setRoleNames( new ArrayList( Arrays.asList( "Guest" ) ) );
+        userAssignment.setRoleIds( new ArrayList( Arrays.asList( "guest" ) ) );
         rbacManager.saveUserAssignment( userAssignment );
         CacheManager.getInstance().clearAll();
     }
index 86f27fcf1ae68ba9d04301c0e056585b5a64f2fa..b30e28ed149e0cf1c4264d47887828b806e6ea18 100644 (file)
@@ -112,7 +112,7 @@ public class ArchivaLockedAdminEnvironmentCheck
                     continue;
                 }
                 List<String> roles = new ArrayList<>();
-                roles.add( RedbackRoleConstants.SYSTEM_ADMINISTRATOR_ROLE );
+                roles.add( RedbackRoleConstants.SYSTEM_ADMINISTRATOR_ROLE_ID );
 
                 List<? extends UserAssignment> systemAdminstrators;
                 try
index d0995b73512e0e4efc3b74ea02719dfaff2f6698..4884882eb0df2f6f88ec4aea564e91dc350e89d6 100644 (file)
@@ -812,9 +812,9 @@ public class ArchivaRbacManager
                     UserAssignment userAssignment = rbacManager.getUserAssignment( principal );
                     if ( userAssignment != null )
                     {
-                        for ( String roleName : userAssignment.getRoleNames() )
+                        for ( String roleId : userAssignment.getRoleIds() )
                         {
-                            ua.addRoleName( roleName );
+                            ua.addRoleId( roleId );
                         }
                     }
                 }
@@ -900,9 +900,9 @@ public class ArchivaRbacManager
                     UserAssignment userAssignment = allUserAssignments.get( ua.getPrincipal() );
                     if ( userAssignment != null )
                     {
-                        for ( String roleName : ua.getRoleNames() )
+                        for ( String roleId : ua.getRoleIds() )
                         {
-                            userAssignment.addRoleName( roleName );
+                            userAssignment.addRoleId( roleId );
                         }
                     }
                     allUserAssignments.put( ua.getPrincipal(), ua );
@@ -923,7 +923,7 @@ public class ArchivaRbacManager
     }
 
     @Override
-    public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
+    public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleIds )
         throws RbacManagerException
     {
         List<UserAssignment> allUserAssignments = new ArrayList<>();
@@ -933,7 +933,7 @@ public class ArchivaRbacManager
         {
             try
             {
-                List<? extends UserAssignment> userAssignments = rbacManager.getUserAssignmentsForRoles( roleNames );
+                List<? extends UserAssignment> userAssignments = rbacManager.getUserAssignmentsForRoles( roleIds );
 
                 allUserAssignments.addAll( userAssignments );
 
index 7b487803b7fe176f63f00755e0be562e2fe4a20f..dc0d2e882a0c582d804b876a84b56a2d7e64edd3 100644 (file)
@@ -244,12 +244,12 @@ public class SecuritySynchronization
                     ua = rbacManager.createUserAssignment( principal );
                 }
 
-                ua.addRoleName( ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) );
+                ua.addRoleId( ArchivaRoleConstants.toRepositoryObserverRoleId( repoId ) );
                 rbacManager.saveUserAssignment( ua );
             }
             catch ( RbacManagerException e )
             {
-                log.warn( "Unable to add role [{}] to {} user.", ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ), principal, e );
+                log.warn( "Unable to add role [{}] to {} user.", ArchivaRoleConstants.toRepositoryObserverRoleId( repoId ), principal, e );
             }
         }
     }
index 442f21d37977aca59768954123841ef26ec22d90..b1a32a24a9d22a2209db867b2aae17cb48da37d0 100644 (file)
@@ -47,10 +47,11 @@ public class RoleManagerStub
     }
 
     @Override
-    public void createTemplatedRole( String templateId, String resource )
+    public String createTemplatedRole( String templateId, String resource )
         throws RoleManagerException
     {
         //To change body of implemented methods use File | Settings | File Templates.
+        return null;
     }
 
     @Override
@@ -61,10 +62,11 @@ public class RoleManagerStub
     }
 
     @Override
-    public void moveTemplatedRole( String templateId, String oldResource, String newResource )
+    public String moveTemplatedRole( String templateId, String oldResource, String newResource )
         throws RoleManagerException
     {
         //To change body of implemented methods use File | Settings | File Templates.
+        return null;
     }
 
     @Override