aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java24
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-indexer-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java2
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java50
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java2
4 files changed, 75 insertions, 3 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 adcc42550..26e891dcb 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
@@ -79,12 +79,24 @@ public class TestRBACManager implements RBACManager
}
@Override
+ public Role createRole( String id, String name )
+ {
+ return null;
+ }
+
+ @Override
public boolean roleExists( String name )
{
return false;
}
@Override
+ public boolean roleExistsById( String id ) throws RbacManagerException
+ {
+ return false;
+ }
+
+ @Override
public boolean roleExists( Role role )
{
return false;
@@ -112,6 +124,12 @@ public class TestRBACManager implements RBACManager
}
@Override
+ public Role getRoleById( String id ) throws RbacObjectNotFoundException, RbacManagerException
+ {
+ return null;
+ }
+
+ @Override
public Map<String, Role> getRoles( Collection<String> roleNames )
throws RbacObjectNotFoundException, RbacManagerException
{
@@ -168,6 +186,12 @@ public class TestRBACManager implements RBACManager
}
@Override
+ public void removeRoleById( String id ) throws RbacObjectNotFoundException, RbacManagerException
+ {
+
+ }
+
+ @Override
public Permission createPermission( String name )
throws RbacManagerException
{
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 8f3bb644f..dd87dfc04 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
@@ -61,7 +61,7 @@ public class TestRoleManager
}
@Override
- public void updateRole( String templateId, String oldResource, String newResource )
+ public void moveTemplatedRole( String templateId, String oldResource, String newResource )
throws RoleManagerException
{
//To change body of implemented methods use File | Settings | File Templates.
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 67dc4b7a4..d0995b735 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
@@ -80,6 +80,10 @@ public class ArchivaRbacManager
private Cache<String, Role> rolesCache;
@Inject
+ @Named( value = "cache#rolesById" )
+ private Cache<String, Role> rolesByIdCache;
+
+ @Inject
@Named( value = "cache#userAssignments" )
private Cache<String, UserAssignment> userAssignmentsCache;
@@ -134,6 +138,7 @@ public class ArchivaRbacManager
operationsCache.clear();
permissionsCache.clear();
rolesCache.clear();
+ rolesByIdCache.clear();
userAssignmentsCache.clear();
userPermissionsCache.clear();
effectiveRoleSetCache.clear();
@@ -161,6 +166,12 @@ public class ArchivaRbacManager
}
@Override
+ public Role createRole( String id, String name )
+ {
+ return getRbacManagerForWrite( ).createRole( id, name );
+ }
+
+ @Override
public Role saveRole( Role role )
throws RbacObjectInvalidException, RbacManagerException
{
@@ -235,6 +246,7 @@ public class ArchivaRbacManager
if ( role != null )
{
rolesCache.put( role.getName(), role );
+ rolesByIdCache.put( role.getId( ), role );
return role;
}
}
@@ -248,7 +260,42 @@ public class ArchivaRbacManager
{
throw new RbacManagerException( lastException.getMessage(), lastException );
}
- return null;
+ throw new RbacObjectNotFoundException( "Role not found " + roleName );
+ }
+
+ @Override
+ public Role getRoleById( String id ) throws RbacObjectNotFoundException, RbacManagerException
+ {
+ Role el = rolesByIdCache.get( id );
+ if ( el != null )
+ {
+ return el;
+ }
+
+ Exception lastException = null;
+ for ( RBACManager rbacManager : rbacManagersPerId.values() )
+ {
+ try
+ {
+ Role role = rbacManager.getRoleById( id );
+ if ( role != null )
+ {
+ rolesCache.put( role.getName(), role );
+ rolesByIdCache.put( role.getId( ), role );
+ return role;
+ }
+ }
+ catch ( Exception e )
+ {
+ lastException = e;
+ }
+ }
+ log.debug( "cannot find role for id: ‘{}", id );
+ if ( lastException != null )
+ {
+ throw new RbacManagerException( lastException.getMessage(), lastException );
+ }
+ throw new RbacObjectNotFoundException( "Role not found " + id );
}
@Override
@@ -295,6 +342,7 @@ public class ArchivaRbacManager
{
rbacManager.removeRole( role );
rolesCache.remove( role.getName() );
+ rolesByIdCache.remove( role.getId( ) );
allFailed = false;
}
catch ( Exception 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 7b3e31200..442f21d37 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
@@ -61,7 +61,7 @@ public class RoleManagerStub
}
@Override
- public void updateRole( String templateId, String oldResource, String newResource )
+ public void moveTemplatedRole( String templateId, String oldResource, String newResource )
throws RoleManagerException
{
//To change body of implemented methods use File | Settings | File Templates.