aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-11-26 22:21:03 +0100
committerMartin Stockhammer <martin_s@apache.org>2020-11-26 22:21:03 +0100
commit2f4b1d241950261ce635d84f04ed45132e88e2ba (patch)
tree9cc4ab2feb6f15e508b0b113cca90a0448a36cbc
parenta2442befca1e7b9c9f81cc434d86cf7b7ed8cd41 (diff)
downloadarchiva-2f4b1d241950261ce635d84f04ed45132e88e2ba.tar.gz
archiva-2f4b1d241950261ce635d84f04ed45132e88e2ba.zip
Adding id methods for roles
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java18
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java6
-rw-r--r--archiva-modules/archiva-base/archiva-security-common/src/main/java/org/apache/archiva/security/common/ArchivaRoleConstants.java6
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java2
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java12
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java4
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java6
8 files changed, 39 insertions, 17 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java b/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java
index 26e891dcb..a74d5bc8c 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java
@@ -144,20 +144,32 @@ 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.
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java b/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java
index dd87dfc04..c0a04da74 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java
@@ -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
diff --git a/archiva-modules/archiva-base/archiva-security-common/src/main/java/org/apache/archiva/security/common/ArchivaRoleConstants.java b/archiva-modules/archiva-base/archiva-security-common/src/main/java/org/apache/archiva/security/common/ArchivaRoleConstants.java
index 36ab17c6a..4700d9646 100644
--- a/archiva-modules/archiva-base/archiva-security-common/src/main/java/org/apache/archiva/security/common/ArchivaRoleConstants.java
+++ b/archiva-modules/archiva-base/archiva-security-common/src/main/java/org/apache/archiva/security/common/ArchivaRoleConstants.java
@@ -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;
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java
index 6487e9d23..d877c69f1 100644
--- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java
+++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java
@@ -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();
}
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java
index 86f27fcf1..b30e28ed1 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLockedAdminEnvironmentCheck.java
@@ -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
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
index d0995b735..4884882eb 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
@@ -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 );
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
index 7b487803b..dc0d2e882 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
@@ -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 );
}
}
}
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java
index 442f21d37..b1a32a24a 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java
@@ -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