From fcdfd86088b2642deb5313a532b9e0f99aee0240 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 5 Dec 2006 16:37:53 +0000 Subject: [PATCH] MRM-242 added a new base role for the repository managers to inherit git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@482705 13f79535-47bb-0310-9956-ffa450edef68 --- .../security/ArchivaRoleConstants.java | 2 + .../security/ArchivaRoleProfileManager.java | 2 + .../BaseRepositoryManagerRoleProfile.java | 42 +++++++++++++++++++ .../RepositoryManagerDynamicRoleProfile.java | 6 +++ .../resources/META-INF/plexus/components.xml | 14 +++++++ 5 files changed, 66 insertions(+) create mode 100644 archiva-security/src/main/java/org/apache/maven/archiva/security/BaseRepositoryManagerRoleProfile.java diff --git a/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java b/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java index 17e085878..1ab7f4be5 100644 --- a/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java +++ b/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java @@ -29,6 +29,8 @@ public class ArchivaRoleConstants public static final String GUEST_ROLE = "Guest"; + public static final String BASE_REPOSITORY_MANAGER = "Repository Manager Base"; + // dynamic role prefixes public static final String REPOSITORY_MANAGER_ROLE_PREFIX = "Repository Manager"; diff --git a/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleProfileManager.java b/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleProfileManager.java index 1eb72ffb9..2d3aec8af 100644 --- a/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleProfileManager.java +++ b/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleProfileManager.java @@ -32,6 +32,8 @@ public class ArchivaRoleProfileManager public void initialize() throws RoleProfileException { + getRole( "archiva-repository-manager-base" ); + mergeRoleProfiles( "system-administrator", "archiva-system-administrator" ); mergeRoleProfiles( "user-administrator", "archiva-user-administrator" ); mergeRoleProfiles( "guest", "archiva-guest" ); diff --git a/archiva-security/src/main/java/org/apache/maven/archiva/security/BaseRepositoryManagerRoleProfile.java b/archiva-security/src/main/java/org/apache/maven/archiva/security/BaseRepositoryManagerRoleProfile.java new file mode 100644 index 000000000..a165e9bbc --- /dev/null +++ b/archiva-security/src/main/java/org/apache/maven/archiva/security/BaseRepositoryManagerRoleProfile.java @@ -0,0 +1,42 @@ +package org.apache.maven.archiva.security; + +import org.codehaus.plexus.rbac.profile.AbstractRoleProfile; + +import java.util.ArrayList; +import java.util.List; + +/** + * @plexus.component role="org.codehaus.plexus.rbac.profile.RoleProfile" + * role-hint="archiva-repository-manager-base" + */ +public class BaseRepositoryManagerRoleProfile + extends AbstractRoleProfile +{ + /** + * Create the Role name for a Repository Manager, using the provided repository id. + * + */ + public String getRoleName( ) + { + return ArchivaRoleConstants.BASE_REPOSITORY_MANAGER; + } + + public List getOperations() + { + List operations = new ArrayList(); + + operations.add( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ); + + return operations; + } + + public boolean isPermanent() + { + return true; + } + + public boolean isAssignable() + { + return false; + } +} diff --git a/archiva-security/src/main/java/org/apache/maven/archiva/security/RepositoryManagerDynamicRoleProfile.java b/archiva-security/src/main/java/org/apache/maven/archiva/security/RepositoryManagerDynamicRoleProfile.java index c94fbac30..c7c4b4b4f 100644 --- a/archiva-security/src/main/java/org/apache/maven/archiva/security/RepositoryManagerDynamicRoleProfile.java +++ b/archiva-security/src/main/java/org/apache/maven/archiva/security/RepositoryManagerDynamicRoleProfile.java @@ -52,6 +52,12 @@ public class RepositoryManagerDynamicRoleProfile return operations; } + + public List getChildRoles() + { + return Collections.singletonList( ArchivaRoleConstants.BASE_REPOSITORY_MANAGER ); + } + public List getDynamicChildRoles( String string ) { return Collections.singletonList( diff --git a/archiva-security/src/main/resources/META-INF/plexus/components.xml b/archiva-security/src/main/resources/META-INF/plexus/components.xml index 3f5190db0..5c34b87fe 100644 --- a/archiva-security/src/main/resources/META-INF/plexus/components.xml +++ b/archiva-security/src/main/resources/META-INF/plexus/components.xml @@ -80,6 +80,20 @@ + + org.codehaus.plexus.rbac.profile.RoleProfile + archiva-repository-manager-base + org.apache.maven.archiva.security.BaseRepositoryManagerRoleProfile + + + org.codehaus.plexus.security.rbac.RBACManager + + + org.codehaus.plexus.PlexusContainer + container + + + org.codehaus.plexus.rbac.profile.DynamicRoleProfile archiva-repository-manager -- 2.39.5