You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/04/06 11:59:32 UTC
svn commit: r1310268 [31/42] - in /archiva/redback/redback-core/trunk: ./
redback-authentication/ redback-authentication/redback-authentication-api/
redback-authentication/redback-authentication-api/src/
redback-authentication/redback-authentication-ap...
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/main/resources/META-INF/spring-context.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/main/resources/META-INF/spring-context.xml (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/main/resources/META-INF/spring-context.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan
+ base-package="org.codehaus.plexus.redback.authorization.rbac"/>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/java/org/codehaus/plexus/redback/authorization/rbac/evaluator/PermissionEvaluatorTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/java/org/codehaus/plexus/redback/authorization/rbac/evaluator/PermissionEvaluatorTest.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/java/org/codehaus/plexus/redback/authorization/rbac/evaluator/PermissionEvaluatorTest.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/java/org/codehaus/plexus/redback/authorization/rbac/evaluator/PermissionEvaluatorTest.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,63 @@
+package org.codehaus.plexus.redback.authorization.rbac.evaluator;
+
+/*
+ * Copyright 2009 Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+import org.codehaus.plexus.redback.rbac.Operation;
+import org.codehaus.plexus.redback.rbac.Permission;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.redback.rbac.memory.MemoryOperation;
+import org.codehaus.plexus.redback.rbac.memory.MemoryPermission;
+import org.codehaus.plexus.redback.rbac.memory.MemoryResource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class PermissionEvaluatorTest
+ extends TestCase
+{
+
+ @Inject
+ PermissionEvaluator permissionEvaluator;
+
+ @Test
+ public void testNullResource()
+ throws PermissionEvaluationException
+ {
+ // null resources should be considered as matching if any resource is obtained.
+ // we do this instead of using "global" as that is the inverse - you are allocated global rights,
+ // which is right to everything. null is the right to anything.
+
+ Resource resource = new MemoryResource();
+ resource.setIdentifier( "Resource" );
+
+ Operation operation = new MemoryOperation();
+ operation.setName( "Operation" );
+
+ Permission permission = new MemoryPermission();
+ permission.setName( "Permission" );
+ permission.setOperation( operation );
+ permission.setResource( resource );
+
+ assertTrue( permissionEvaluator.evaluate( permission, "Operation", null, "brett" ) );
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/java/org/codehaus/plexus/redback/authorization/rbac/evaluator/PermissionEvaluatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/java/org/codehaus/plexus/redback/authorization/rbac/evaluator/PermissionEvaluatorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/resources/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/resources/spring-context.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/resources/spring-context.xml (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/resources/spring-context.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <bean name="userManager#cached" class="org.codehaus.plexus.redback.users.cached.CachedUserManager">
+ <property name="userImpl" ref="userManager#memory"/>
+ <property name="usersCache" ref="cache#users"/>
+ </bean>
+
+ <alias name="userManager#memory" alias="userManager#jdo"/>
+
+ <bean name="cache#users" class="org.codehaus.plexus.cache.ehcache.EhcacheCache"
+ init-method="initialize">
+ <property name="diskPersistent" value="false"/>
+ <property name="eternal" value="false"/>
+ <property name="maxElementsInMemory" value="1000"/>
+ <property name="memoryEvictionPolicy" value="LRU"/>
+ <property name="name" value="usersCache"/>
+ <property name="timeToIdleSeconds" value="1800"/>
+ <property name="timeToLiveSeconds" value="14400"/>
+ </bean>
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-authorization-rbac/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/pom.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/pom.xml (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/pom.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-rbac</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-rbac-model</artifactId>
+ <name>Redback :: RBAC Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRBACManager.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRBACManager.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRBACManager.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRBACManager.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,795 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.codehaus.plexus.util.CollectionUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * AbstractRBACManager
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRBACManager
+ implements RBACManager
+{
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
+ private List<RBACManagerListener> listeners = new ArrayList<RBACManagerListener>( 0 );
+
+ private Resource globalResource;
+
+ @PostConstruct
+ public void initialize()
+ {
+ //no op
+ }
+
+ public void addListener( RBACManagerListener listener )
+ {
+ if ( !listeners.contains( listener ) )
+ {
+ listeners.add( listener );
+ }
+ }
+
+ public void removeListener( RBACManagerListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ public void fireRbacInit( boolean freshdb )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacInit( freshdb );
+ }
+ catch ( Exception e )
+ {
+ log.warn( "Unable to trigger .rbacInit( boolean ) to " + listener.getClass().getName(), e );
+ }
+ }
+ }
+
+ public void fireRbacRoleSaved( Role role )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacRoleSaved( role );
+ }
+ catch ( Exception e )
+ {
+ log.warn( "Unable to trigger .rbacRoleSaved( Role ) to " + listener.getClass().getName(), e );
+ }
+ }
+ }
+
+ public void fireRbacRoleRemoved( Role role )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacRoleRemoved( role );
+ }
+ catch ( Exception e )
+ {
+ log.warn( "Unable to trigger .rbacRoleRemoved( Role ) to " + listener.getClass().getName(), e );
+ }
+ }
+ }
+
+ public void fireRbacPermissionSaved( Permission permission )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacPermissionSaved( permission );
+ }
+ catch ( Exception e )
+ {
+ log.warn( "Unable to trigger .rbacPermissionSaved( Permission ) to " + listener.getClass().getName(),
+ e );
+ }
+ }
+ }
+
+ public void fireRbacPermissionRemoved( Permission permission )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacPermissionRemoved( permission );
+ }
+ catch ( Exception e )
+ {
+ log.warn( "Unable to trigger .rbacPermissionRemoved( Permission ) to " + listener.getClass().getName(),
+ e );
+ }
+ }
+ }
+
+ public void fireRbacUserAssignmentSaved( UserAssignment userAssignment )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacUserAssignmentSaved( userAssignment );
+ }
+ catch ( Exception e )
+ {
+ log.warn(
+ "Unable to trigger .rbacUserAssignmentSaved( UserAssignment ) to " + listener.getClass().getName(),
+ e );
+ }
+ }
+ }
+
+ public void fireRbacUserAssignmentRemoved( UserAssignment userAssignment )
+ {
+ Iterator<RBACManagerListener> it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ RBACManagerListener listener = it.next();
+ try
+ {
+ listener.rbacUserAssignmentRemoved( userAssignment );
+ }
+ catch ( Exception e )
+ {
+ log.warn( "Unable to trigger .rbacUserAssignmentRemoved( UserAssignment ) to "
+ + listener.getClass().getName(), e );
+ }
+ }
+ }
+
+ public void removeRole( String roleName )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ removeRole( getRole( roleName ) );
+ }
+
+ public void removePermission( String permissionName )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ removePermission( getPermission( permissionName ) );
+ }
+
+ public void removeOperation( String operationName )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ removeOperation( getOperation( operationName ) );
+ }
+
+ public void removeResource( String resourceIdentifier )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ removeResource( getResource( resourceIdentifier ) );
+ }
+
+ public void removeUserAssignment( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ removeUserAssignment( getUserAssignment( principal ) );
+ }
+
+ public boolean resourceExists( Resource resource )
+ {
+ try
+ {
+ return getAllResources().contains( resource );
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+ }
+
+ public boolean resourceExists( String identifier )
+ {
+ try
+ {
+ for ( Resource resource : getAllResources() )
+ {
+ if ( StringUtils.equals( resource.getIdentifier(), identifier ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ public boolean operationExists( Operation operation )
+ {
+ try
+ {
+ return getAllOperations().contains( operation );
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+ }
+
+ public boolean operationExists( String name )
+ {
+ try
+ {
+ for ( Operation operation : getAllOperations() )
+ {
+ if ( StringUtils.equals( operation.getName(), name ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ public boolean permissionExists( Permission permission )
+ {
+ try
+ {
+ return getAllPermissions().contains( permission );
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+ }
+
+ public boolean permissionExists( String name )
+ {
+ try
+ {
+ for ( Permission permission : getAllPermissions() )
+ {
+ if ( StringUtils.equals( permission.getName(), name ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ public boolean roleExists( Role role )
+ {
+ try
+ {
+ return getAllRoles().contains( role );
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+ }
+
+ public boolean roleExists( String name )
+ {
+ try
+ {
+ for ( Role role : getAllRoles() )
+ {
+ if ( StringUtils.equals( role.getName(), name ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ public boolean userAssignmentExists( String principal )
+ {
+ try
+ {
+ for ( UserAssignment assignment : getAllUserAssignments() )
+ {
+ if ( StringUtils.equals( assignment.getPrincipal(), principal ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ public boolean userAssignmentExists( UserAssignment assignment )
+ {
+ try
+ {
+ return getAllUserAssignments().contains( assignment );
+ }
+ catch ( RbacManagerException e )
+ {
+ return false;
+ }
+ }
+
+ /**
+ * returns a set of all permissions that are in all active roles for a given
+ * principal
+ *
+ * @param principal
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ public Set<Permission> getAssignedPermissions( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+
+ UserAssignment ua = getUserAssignment( principal );
+
+ Set<Permission> permissionSet = new HashSet<Permission>();
+
+ if ( ua.getRoleNames() != null )
+ {
+ boolean childRoleNamesUpdated = false;
+
+ Iterator<String> it = ua.getRoleNames().listIterator();
+ while ( it.hasNext() )
+ {
+ String roleName = it.next();
+ try
+ {
+ Role role = getRole( roleName );
+ gatherUniquePermissions( role, permissionSet );
+ }
+ catch ( RbacObjectNotFoundException e )
+ {
+ // Found a bad role name. remove it!
+ it.remove();
+ childRoleNamesUpdated = true;
+ }
+ }
+
+ if ( childRoleNamesUpdated )
+ {
+ saveUserAssignment( ua );
+ }
+ }
+
+ return permissionSet;
+ }
+
+ /**
+ * returns a map of assigned permissions keyed off of operations
+ *
+ * @param principal
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ public Map<String, List<Permission>> getAssignedPermissionMap( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ return getPermissionMapByOperation( getAssignedPermissions( principal ) );
+ }
+
+ private Map<String, List<Permission>> getPermissionMapByOperation( Collection<Permission> permissions )
+ {
+ Map<String, List<Permission>> userPermMap = new HashMap<String, List<Permission>>();
+
+ for ( Permission permission : permissions )
+ {
+ List<Permission> permList = userPermMap.get( permission.getOperation().getName() );
+
+ if ( permList != null )
+ {
+ permList.add( permission );
+ }
+ else
+ {
+ List<Permission> newPermList = new ArrayList<Permission>( permissions.size() );
+ newPermList.add( permission );
+ userPermMap.put( permission.getOperation().getName(), newPermList );
+ }
+ }
+
+ return userPermMap;
+ }
+
+ private void gatherUniquePermissions( Role role, Collection<Permission> coll )
+ throws RbacManagerException
+ {
+ if ( role.getPermissions() != null )
+ {
+ for ( Permission permission : role.getPermissions() )
+ {
+ if ( !coll.contains( permission ) )
+ {
+ coll.add( permission );
+ }
+ }
+ }
+
+ if ( role.hasChildRoles() )
+ {
+ Map<String, Role> childRoles = getChildRoles( role );
+ Iterator<Role> it = childRoles.values().iterator();
+ while ( it.hasNext() )
+ {
+ Role child = it.next();
+ gatherUniquePermissions( child, coll );
+ }
+ }
+ }
+
+ public List<Role> getAllAssignableRoles()
+ throws RbacManagerException, RbacObjectNotFoundException
+ {
+ List<Role> assignableRoles = new ArrayList<Role>();
+
+ for ( Role r : getAllRoles() )
+ {
+ Role role = getRole( r.getName() );
+ if ( role.isAssignable() )
+ {
+ assignableRoles.add( role );
+ }
+ }
+
+ return assignableRoles;
+ }
+
+ /**
+ * returns the active roles for a given principal
+ * <p/>
+ * NOTE: roles that are returned might have have roles themselves, if
+ * you just want all permissions then use {@link #getAssignedPermissions(String principal)}
+ *
+ * @param principal
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ public Collection<Role> getAssignedRoles( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ UserAssignment ua = getUserAssignment( principal );
+
+ return getAssignedRoles( ua );
+ }
+
+ /**
+ * returns only the roles that are assigned, not the roles that might be child roles of the
+ * assigned roles.
+ *
+ * @param ua
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ public Collection<Role> getAssignedRoles( UserAssignment ua )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ Set<Role> roleSet = new HashSet<Role>();
+
+ if ( ua.getRoleNames() != null )
+ {
+ boolean childRoleNamesUpdated = false;
+
+ Iterator<String> it = ua.getRoleNames().listIterator();
+ while ( it.hasNext() )
+ {
+ String roleName = it.next();
+ try
+ {
+ Role role = getRole( roleName );
+
+ if ( !roleSet.contains( role ) )
+ {
+ roleSet.add( role );
+ }
+ }
+ catch ( RbacObjectNotFoundException e )
+ {
+ // Found a bad role name. remove it!
+ it.remove();
+ childRoleNamesUpdated = true;
+ }
+ }
+
+ if ( childRoleNamesUpdated )
+ {
+ saveUserAssignment( ua );
+ }
+ }
+
+ return roleSet;
+ }
+
+ /**
+ * get all of the roles that the give role has as a child into a set
+ *
+ * @param role
+ * @param roleSet
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ private void gatherEffectiveRoles( Role role, Set<Role> roleSet )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ if ( role.hasChildRoles() )
+ {
+ for ( String roleName : role.getChildRoleNames() )
+ {
+ try
+ {
+ Role crole = getRole( roleName );
+
+ if ( !roleSet.contains( crole ) )
+ {
+ gatherEffectiveRoles( crole, roleSet );
+ }
+ }
+ catch ( RbacObjectNotFoundException e )
+ {
+ // the client application might not manage role clean up totally correctly so we want to notify
+ // of a child role issue and offer a clean up process at some point
+ log.warn( "dangling child role: " + roleName + " on " + role.getName() );
+ }
+ }
+ }
+
+ if ( !roleSet.contains( role ) )
+ {
+ roleSet.add( role );
+ }
+ }
+
+ public Collection<Role> getEffectivelyAssignedRoles( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ UserAssignment ua = getUserAssignment( principal );
+
+ return getEffectivelyAssignedRoles( ua );
+ }
+
+ public Collection<Role> getEffectivelyAssignedRoles( UserAssignment ua )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ Set<Role> roleSet = new HashSet<Role>();
+
+ if ( ua != null && ua.getRoleNames() != null )
+ {
+ boolean childRoleNamesUpdated = false;
+
+ Iterator<String> it = ua.getRoleNames().listIterator();
+ while ( it.hasNext() )
+ {
+ String roleName = it.next();
+ try
+ {
+ Role role = getRole( roleName );
+
+ gatherEffectiveRoles( role, roleSet );
+ }
+ catch ( RbacObjectNotFoundException e )
+ {
+ // Found a bad role name. remove it!
+ it.remove();
+ childRoleNamesUpdated = true;
+ }
+ }
+
+ if ( childRoleNamesUpdated )
+ {
+ saveUserAssignment( ua );
+ }
+ }
+ return roleSet;
+ }
+
+ /**
+ * @param principal
+ * @return
+ * @throws RbacManagerException
+ * @throws RbacObjectNotFoundException
+ */
+ @SuppressWarnings( "unchecked" )
+ public Collection<Role> getEffectivelyUnassignedRoles( String principal )
+ throws RbacManagerException, RbacObjectNotFoundException
+ {
+ Collection<Role> assignedRoles = getEffectivelyAssignedRoles( principal );
+ List<Role> allRoles = getAllAssignableRoles();
+
+ log.debug( "UR: assigned {}", assignedRoles.size() );
+ log.debug( "UR: available {}", allRoles.size() );
+
+ return CollectionUtils.subtract( allRoles, assignedRoles );
+ }
+
+
+ /**
+ * @param principal
+ * @return
+ * @throws RbacManagerException
+ * @throws RbacObjectNotFoundException
+ */
+ @SuppressWarnings( "unchecked" )
+ public Collection<Role> getUnassignedRoles( String principal )
+ throws RbacManagerException, RbacObjectNotFoundException
+ {
+ Collection<Role> assignedRoles = getAssignedRoles( principal );
+ List<Role> allRoles = getAllAssignableRoles();
+
+ log.debug( "UR: assigned {}", assignedRoles.size() );
+ log.debug( "UR: available {}", allRoles.size() );
+
+ return CollectionUtils.subtract( allRoles, assignedRoles );
+ }
+
+ public Resource getGlobalResource()
+ throws RbacManagerException
+ {
+ if ( globalResource == null )
+ {
+ globalResource = createResource( Resource.GLOBAL );
+ globalResource.setPermanent( true );
+ globalResource = saveResource( globalResource );
+ }
+ return globalResource;
+ }
+
+ public void addChildRole( Role role, Role childRole )
+ throws RbacObjectInvalidException, RbacManagerException
+ {
+ saveRole( childRole );
+ role.addChildRoleName( childRole.getName() );
+ }
+
+ public Map<String, Role> getChildRoles( Role role )
+ throws RbacManagerException
+ {
+ Map<String, Role> childRoles = new HashMap<String, Role>();
+
+ boolean childRoleNamesUpdated = false;
+
+ Iterator<String> it = role.getChildRoleNames().listIterator();
+ while ( it.hasNext() )
+ {
+ String roleName = (String) it.next();
+ try
+ {
+ Role child = getRole( roleName );
+ childRoles.put( child.getName(), child );
+ }
+ catch ( RbacObjectNotFoundException e )
+ {
+ // Found a bad roleName! - remove it.
+ it.remove();
+ childRoleNamesUpdated = true;
+ }
+ }
+
+ if ( childRoleNamesUpdated )
+ {
+ saveRole( role );
+ }
+
+ return childRoles;
+ }
+
+ public Map<String, Role> getParentRoles( Role role )
+ throws RbacManagerException
+ {
+ Map<String, Role> parentRoles = new HashMap<String, Role>();
+
+ for ( Role r : getAllRoles() )
+ {
+ if ( !r.getName().equals( role.getName() ) )
+ {
+ Set<Role> effectiveRoles = getEffectiveRoles( r );
+ for ( Role currentRole : effectiveRoles )
+ {
+ if ( currentRole.getName().equals( role.getName() ) )
+ {
+ if ( !parentRoles.containsKey( r.getName() ) )
+ {
+ parentRoles.put( r.getName(), r );
+ }
+ }
+ }
+ }
+ }
+ return parentRoles;
+ }
+
+ public Set<Role> getEffectiveRoles( Role role )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ Set<Role> roleSet = new HashSet<Role>();
+ gatherEffectiveRoles( role, roleSet );
+
+ return roleSet;
+ }
+
+ public Map<String, Role> getRoles( Collection<String> roleNames )
+ throws RbacObjectNotFoundException, RbacManagerException
+ {
+ Map<String, Role> roleMap = new HashMap<String, Role>();
+
+ for ( String roleName : roleNames )
+ {
+ Role child = getRole( roleName );
+ roleMap.put( child.getName(), child );
+ }
+
+ return roleMap;
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRBACManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRBACManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRole.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRole.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRole.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRole.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,33 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * AbstractRole useful for common logic that implementors can use.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRole
+ implements Role
+{
+
+ public boolean hasChildRoles()
+ {
+ return ( getChildRoleNames() != null ) && !getChildRoleNames().isEmpty();
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRole.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractRole.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractUserAssignment.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractUserAssignment.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractUserAssignment.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractUserAssignment.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,55 @@
+package org.codehaus.plexus.redback.rbac;
+
+import java.util.List;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * AbstractUserAssignment useful for common logic that implementors can use.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractUserAssignment
+ implements UserAssignment
+{
+
+ public void addRoleName( Role role )
+ {
+ addRoleName( role.getName() );
+ }
+
+ public void addRoleName( String roleName )
+ {
+ List<String> names = getRoleNames();
+ if ( !names.contains( roleName ) )
+ {
+ names.add( roleName );
+ }
+ setRoleNames( names );
+ }
+
+ public void removeRoleName( Role role )
+ {
+ removeRoleName( role.getName() );
+ }
+
+ public void removeRoleName( String roleName )
+ {
+ getRoleNames().remove( roleName );
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractUserAssignment.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/AbstractUserAssignment.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Operation.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Operation.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Operation.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Operation.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,81 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Operation
+ * <p/>
+ * In RBAC the operation is an action or functionality that can be linked with a
+ * particular resource into an assignable Permission. Operations don't exist outside
+ * Permissions.
+ *
+ * @author Jesse McConnell <jm...@apache.org>
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface Operation
+{
+
+
+ /**
+ * Long description of an operation.
+ *
+ * @return String
+ */
+ String getDescription();
+
+ /**
+ * name of the operation that is used in the act of authorization
+ * <p/>
+ * 'modify-foo', 'change-password'
+ * <p/>
+ * NOTE: This field is considered the Primary Key for this object.
+ *
+ * @return the name of the operation.
+ */
+ String getName();
+
+ /**
+ * @param description
+ */
+ void setDescription( String description );
+
+ /**
+ * Set name of the operation that is used in the act of authorization
+ * <p/>
+ * 'modify-foo', 'change-password'
+ * <p/>
+ * NOTE: This field is considered the Primary Key for this object.
+ *
+ * @param name
+ */
+ void setName( String name );
+
+ /**
+ * Test to see if the object is a permanent object or not.
+ *
+ * @return true if the object is permanent.
+ */
+ boolean isPermanent();
+
+ /**
+ * Set flag indicating if the object is a permanent object or not.
+ *
+ * @param permanent true if the object is permanent.
+ */
+ void setPermanent( boolean permanent );
+}
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Operation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Operation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Permission.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Permission.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Permission.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Permission.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,101 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Permission
+ * <p/>
+ * A permission is the wrapper for an operation and a resource effectively saying
+ * that the operation is authorized for that resource.
+ * <p/>
+ * P(Operation, Resource)
+ *
+ * @author Jesse McConnell <jm...@apache.org>
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface Permission
+{
+
+ /**
+ * Long description of the Permission
+ */
+ String getDescription();
+
+ /**
+ * Get the short name of the permission.
+ * <p/>
+ * NOTE: This field is considered the Primary Key for this object.
+ *
+ * @return the short name for this permission.
+ */
+ String getName();
+
+ /**
+ * Operation that this permission is authorizing
+ */
+ Operation getOperation();
+
+ /**
+ * This is the resource associated with this permission.
+ * <p/>
+ * Implementors must always supply a Resource.
+ *
+ * @return the Resource.
+ */
+ Resource getResource();
+
+ /**
+ * Set null
+ *
+ * @param description
+ */
+ void setDescription( String description );
+
+ /**
+ * Set the short name for this permission.
+ *
+ * @param name
+ */
+ void setName( String name );
+
+ /**
+ * Set null
+ *
+ * @param operation
+ */
+ void setOperation( Operation operation );
+
+ /**
+ * @param resource
+ */
+ void setResource( Resource resource );
+
+ /**
+ * Test to see if the object is a permanent object or not.
+ *
+ * @return true if the object is permanent.
+ */
+ boolean isPermanent();
+
+ /**
+ * Set flag indicating if the object is a permanent object or not.
+ *
+ * @param permanent true if the object is permanent.
+ */
+ void setPermanent( boolean permanent );
+}
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Permission.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/Permission.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManager.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManager.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManager.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManager.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,421 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * RBACManager
+ *
+ * @author Jesse McConnell <jm...@apache.org>
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * @todo expand on javadoc
+ */
+public interface RBACManager
+{
+
+ void addListener( RBACManagerListener listener );
+
+ void removeListener( RBACManagerListener listener );
+
+ // ------------------------------------------------------------------
+ // Role Methods
+ // ------------------------------------------------------------------
+
+ /**
+ * Creates an implementation specific {@link Role}, or return an existing {@link Role}, depending
+ * on the provided <code>name</code> parameter.
+ * <p/>
+ * Note: Be sure to use {@link #saveRole(Role)} in order to persist any changes to the Role.
+ *
+ * @param name the name.
+ * @return the new {@link Role} object.
+ */
+ Role createRole( String name );
+
+ /**
+ * Tests for the existence of a Role.
+ *
+ * @return true if role exists in store.
+ * @throws RbacManagerException
+ */
+ boolean roleExists( String name );
+
+ boolean roleExists( Role role );
+
+ Role saveRole( Role role )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ void saveRoles( Collection<Role> roles )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ /**
+ * @param roleName
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ Role getRole( String roleName )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ Map<String, Role> getRoles( Collection<String> roleNames )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ void addChildRole( Role role, Role childRole )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ Map<String, Role> getChildRoles( Role role )
+ throws RbacManagerException;
+
+ Map<String, Role> getParentRoles( Role role )
+ throws RbacManagerException;
+
+ /**
+ * Method getRoles
+ */
+ List<Role> getAllRoles()
+ throws RbacManagerException;
+
+ /**
+ * Method getEffectiveRoles
+ */
+ Set<Role> getEffectiveRoles( Role role )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * Method removeRole
+ *
+ * @param role
+ */
+ void removeRole( Role role )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ /**
+ * Method removeRole
+ *
+ * @param roleName
+ */
+ void removeRole( String roleName )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ // ------------------------------------------------------------------
+ // Permission Methods
+ // ------------------------------------------------------------------
+
+ /**
+ * Creates an implementation specific {@link Permission}, or return an existing {@link Permission}, depending
+ * on the provided <code>name</code> parameter.
+ * <p/>
+ * Note: Be sure to use {@link #savePermission(Permission)} in order to persist any changes to the Role.
+ *
+ * @param name the name.
+ * @return the new Permission.
+ * @throws RbacManagerException
+ */
+ Permission createPermission( String name )
+ throws RbacManagerException;
+
+ /**
+ * Creates an implementation specific {@link Permission} with specified {@link Operation},
+ * and {@link Resource} identifiers.
+ * <p/>
+ * Note: Be sure to use {@link #savePermission(Permission)} in order to persist any changes to the Role.
+ *
+ * @param name the name.
+ * @param operationName the {@link Operation#setName(String)} value
+ * @param resourceIdentifier the {@link Resource#setIdentifier(String)} value
+ * @return the new Permission.
+ * @throws RbacManagerException
+ */
+ Permission createPermission( String name, String operationName, String resourceIdentifier )
+ throws RbacManagerException;
+
+ /**
+ * Tests for the existence of a permission.
+ *
+ * @param name the name to test for.
+ * @return true if permission exists.
+ * @throws RbacManagerException
+ */
+ boolean permissionExists( String name );
+
+ boolean permissionExists( Permission permission );
+
+ Permission savePermission( Permission permission )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ Permission getPermission( String permissionName )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ List<Permission> getAllPermissions()
+ throws RbacManagerException;
+
+ void removePermission( Permission permission )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ void removePermission( String permissionName )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ // ------------------------------------------------------------------
+ // Operation Methods
+ // ------------------------------------------------------------------
+
+ /**
+ * Creates an implementation specific {@link Operation}, or return an existing {@link Operation}, depending
+ * on the provided <code>name</code> parameter.
+ * <p/>
+ * Note: Be sure to use {@link #saveOperation(Operation)} in order to persist any changes to the Role.
+ *
+ * @param name the name.
+ * @return the new Operation.
+ * @throws RbacManagerException
+ */
+ Operation createOperation( String name )
+ throws RbacManagerException;
+
+ boolean operationExists( String name );
+
+ boolean operationExists( Operation operation );
+
+ /**
+ * Save the new or existing operation to the store.
+ *
+ * @param operation the operation to save (new or existing)
+ * @return the Operation that was saved.
+ * @throws RbacObjectInvalidException
+ * @throws RbacManagerException
+ */
+ Operation saveOperation( Operation operation )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ Operation getOperation( String operationName )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ List<Operation> getAllOperations()
+ throws RbacManagerException;
+
+ void removeOperation( Operation operation )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ void removeOperation( String operationName )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ // ------------------------------------------------------------------
+ // Resource Methods
+ // ------------------------------------------------------------------
+
+ /**
+ * Creates an implementation specific {@link Resource}, or return an existing {@link Resource}, depending
+ * on the provided <code>identifier</code> parameter.
+ * <p/>
+ * Note: Be sure to use {@link #saveResource(Resource)} in order to persist any changes to the Role.
+ *
+ * @param identifier the identifier.
+ * @return the new Resource.
+ * @throws RbacManagerException
+ */
+ Resource createResource( String identifier )
+ throws RbacManagerException;
+
+ boolean resourceExists( String identifier );
+
+ boolean resourceExists( Resource resource );
+
+ Resource saveResource( Resource resource )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ Resource getResource( String resourceIdentifier )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ List<Resource> getAllResources()
+ throws RbacManagerException;
+
+ void removeResource( Resource resource )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ void removeResource( String resourceIdentifier )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ // ------------------------------------------------------------------
+ // UserAssignment Methods
+ // ------------------------------------------------------------------
+
+ /**
+ * Creates an implementation specific {@link UserAssignment}, or return an existing {@link UserAssignment},
+ * depending on the provided <code>identifier</code> parameter.
+ * <p/>
+ * Note: Be sure to use {@link #saveUserAssignment(UserAssignment)} in order to persist any changes to the Role.
+ *
+ * @param principal the principal reference to the user.
+ * @return the new UserAssignment object.
+ * @throws RbacManagerException
+ */
+ UserAssignment createUserAssignment( String principal )
+ throws RbacManagerException;
+
+ boolean userAssignmentExists( String principal );
+
+ boolean userAssignmentExists( UserAssignment assignment );
+
+ /**
+ * Method saveUserAssignment
+ *
+ * @param userAssignment
+ */
+ UserAssignment saveUserAssignment( UserAssignment userAssignment )
+ throws RbacObjectInvalidException, RbacManagerException;
+
+ UserAssignment getUserAssignment( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * Method getAssignments
+ */
+ List<UserAssignment> getAllUserAssignments()
+ throws RbacManagerException;
+
+ /**
+ * Method getUserAssignmentsForRoless
+ */
+ List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
+ throws RbacManagerException;
+
+ /**
+ * Method removeAssignment
+ *
+ * @param userAssignment
+ */
+ void removeUserAssignment( UserAssignment userAssignment )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ /**
+ * Method removeAssignment
+ *
+ * @param principal
+ */
+ void removeUserAssignment( String principal )
+ throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException;
+
+ // ------------------------------------------------------------------
+ // UserAssignment Utility Methods
+ // ------------------------------------------------------------------
+
+ /**
+ * returns the active roles for a given principal
+ * <p/>
+ * NOTE: roles that are returned might have have roles themselves, if
+ * you just want all permissions then use {@link #getAssignedPermissions(String principal)}
+ *
+ * @param principal
+ * @return Collection of {@link Role} objects.
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ Collection<Role> getAssignedRoles( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * Get the Collection of {@link Role} objects for this UserAssignment.
+ *
+ * @param userAssignment
+ * @return Collection of {@link Role} objects for the provided UserAssignment.
+ */
+ Collection<Role> getAssignedRoles( UserAssignment userAssignment )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * Get a list of all assignable roles that are currently not effectively assigned to the specific user,
+ * meaning, not a child of any already granted role
+ *
+ * @param principal
+ * @return
+ * @throws RbacManagerException
+ * @throws RbacObjectNotFoundException
+ */
+ Collection<Role> getEffectivelyUnassignedRoles( String principal )
+ throws RbacManagerException, RbacObjectNotFoundException;
+
+ /**
+ * Get a list of the effectively assigned roles to the specified user, this includes child roles
+ *
+ * @param principal
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ Collection<Role> getEffectivelyAssignedRoles( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * Get a list of all assignable roles that are currently not assigned to the specific user.
+ *
+ * @param principal
+ * @return
+ * @throws RbacManagerException
+ * @throws RbacObjectNotFoundException
+ */
+ Collection<Role> getUnassignedRoles( String principal )
+ throws RbacManagerException, RbacObjectNotFoundException;
+
+ /**
+ * returns a set of all permissions that are in all active roles for a given
+ * principal
+ *
+ * @param principal
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ Set<Permission> getAssignedPermissions( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * returns a map of assigned permissions keyed off of operation with a list value of Permissions
+ *
+ * @param principal
+ * @return
+ * @throws RbacObjectNotFoundException
+ * @throws RbacManagerException
+ */
+ Map<String, List<Permission>> getAssignedPermissionMap( String principal )
+ throws RbacObjectNotFoundException, RbacManagerException;
+
+ /**
+ * returns a list of all assignable roles
+ *
+ * @return
+ * @throws RbacManagerException
+ * @throws RbacObjectNotFoundException
+ */
+ List<Role> getAllAssignableRoles()
+ throws RbacManagerException, RbacObjectNotFoundException;
+
+ /**
+ * returns the global resource object
+ *
+ * @return
+ * @throws RbacManagerException
+ */
+ Resource getGlobalResource()
+ throws RbacManagerException;
+
+ void eraseDatabase();
+}
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManagerListener.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManagerListener.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManagerListener.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManagerListener.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,40 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * RBACManagerListener
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface RBACManagerListener
+{
+ public void rbacInit( boolean freshdb );
+
+ public void rbacRoleSaved( Role role );
+
+ public void rbacRoleRemoved( Role role );
+
+ public void rbacPermissionSaved( Permission permission );
+
+ public void rbacPermissionRemoved( Permission permission );
+
+ public void rbacUserAssignmentSaved( UserAssignment userAssignment );
+
+ public void rbacUserAssignmentRemoved( UserAssignment userAssignment );
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManagerListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACManagerListener.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACObjectAssertions.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACObjectAssertions.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACObjectAssertions.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACObjectAssertions.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,165 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * RBACObjectAssertions
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RBACObjectAssertions
+{
+ public static void assertValid( Role role )
+ throws RbacObjectInvalidException
+ {
+ assertValid( null, role );
+ }
+
+ public static void assertValid( String scope, Role role )
+ throws RbacObjectInvalidException
+ {
+ if ( role == null )
+ {
+ throw new RbacObjectInvalidException( scope, "Null Role object is invalid." );
+ }
+
+ if ( StringUtils.isEmpty( role.getName() ) )
+ {
+ throw new RbacObjectInvalidException( scope, "Role.name must not be empty." );
+ }
+
+ if ( role.getPermissions() != null )
+ {
+ int i = 0;
+ for ( Permission perm : role.getPermissions() )
+ {
+ assertValid( "Role.permissions[" + i + "]", perm );
+ i++;
+ }
+ }
+ }
+
+ public static void assertValid( Permission permission )
+ throws RbacObjectInvalidException
+ {
+ assertValid( null, permission );
+ }
+
+ public static void assertValid( String scope, Permission permission )
+ throws RbacObjectInvalidException
+ {
+ if ( permission == null )
+ {
+ throw new RbacObjectInvalidException( scope, "Null Permission object is invalid." );
+ }
+
+ if ( StringUtils.isEmpty( permission.getName() ) )
+ {
+ throw new RbacObjectInvalidException( scope, "Permission.name must not be empty." );
+ }
+
+ assertValid( "Permission.operation", permission.getOperation() );
+ assertValid( "Permission.resource", permission.getResource() );
+
+ }
+
+ public static void assertValid( Operation operation )
+ throws RbacObjectInvalidException
+ {
+ assertValid( null, operation );
+ }
+
+ public static void assertValid( String scope, Operation operation )
+ throws RbacObjectInvalidException
+ {
+ if ( operation == null )
+ {
+ throw new RbacObjectInvalidException( scope, "Null Operation object is invalid." );
+ }
+
+ if ( StringUtils.isEmpty( operation.getName() ) )
+ {
+ throw new RbacObjectInvalidException( scope, "Operation.name must not be empty." );
+ }
+ }
+
+ public static void assertValid( Resource resource )
+ throws RbacObjectInvalidException
+ {
+ assertValid( null, resource );
+ }
+
+ public static void assertValid( String scope, Resource resource )
+ throws RbacObjectInvalidException
+ {
+ if ( resource == null )
+ {
+ throw new RbacObjectInvalidException( scope, "Null Resource object is invalid." );
+ }
+
+ if ( StringUtils.isEmpty( resource.getIdentifier() ) )
+ {
+ throw new RbacObjectInvalidException( scope, "Resource.identifier must not be empty." );
+ }
+ }
+
+ public static void assertValid( UserAssignment assignment )
+ throws RbacObjectInvalidException
+ {
+ assertValid( null, assignment );
+ }
+
+ public static void assertValid( String scope, UserAssignment assignment )
+ throws RbacObjectInvalidException
+ {
+ if ( assignment == null )
+ {
+ throw new RbacObjectInvalidException( scope, "Null UserAssigment object is invalid." );
+ }
+
+ if ( StringUtils.isEmpty( assignment.getPrincipal() ) )
+ {
+ throw new RbacObjectInvalidException( scope, "UserAssigment.principal cannot be empty." );
+ }
+
+ if ( assignment.getRoleNames() == null )
+ {
+ throw new RbacObjectInvalidException( scope, "UserAssignment.roles cannot be null." );
+ }
+
+ /* I don't believe this assertion is valid, a person should be able to be stripped of all roles.
+ -- jesse
+ if ( assignment.getRoleNames().isEmpty() )
+ {
+ throw new RbacObjectInvalidException( scope, "UserAssignment.roles cannot be empty." );
+ }
+ */
+ int i = 0;
+ for ( String name : assignment.getRoleNames() )
+ {
+ if ( StringUtils.isEmpty( name ) )
+ {
+ throw new RbacObjectInvalidException( scope, "UserAssignment.rolename[" + i + "] cannot be empty." );
+ }
+ i++;
+ }
+ }
+
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACObjectAssertions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RBACObjectAssertions.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacManagerException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacManagerException.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacManagerException.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacManagerException.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,49 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * RbacManagerException used by {@link RBACManager} methods to indicate
+ * a fundamental persistence or store issue.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RbacManagerException
+ extends Exception
+{
+ public RbacManagerException()
+ {
+ super();
+ }
+
+ public RbacManagerException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public RbacManagerException( String message )
+ {
+ super( message );
+ }
+
+ public RbacManagerException( Throwable cause )
+ {
+ super( cause );
+ }
+
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacManagerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacManagerException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectInvalidException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectInvalidException.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectInvalidException.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectInvalidException.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,53 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * RbacObjectInvalidException
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RbacObjectInvalidException
+ extends RbacManagerException
+{
+
+ public RbacObjectInvalidException()
+ {
+ super();
+ }
+
+ public RbacObjectInvalidException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public RbacObjectInvalidException( String message )
+ {
+ super( message );
+ }
+
+ public RbacObjectInvalidException( String scope, String message )
+ {
+ super( ( ( scope != null ) ? scope + ": " : "" ) + message );
+ }
+
+ public RbacObjectInvalidException( Throwable cause )
+ {
+ super( cause );
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectInvalidException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectInvalidException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectNotFoundException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectNotFoundException.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectNotFoundException.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectNotFoundException.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,67 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * RbacObjectNotFoundException used by {@link RBACManager} methods to identify
+ * when a RBAC Object Was Not Found.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RbacObjectNotFoundException
+ extends RbacManagerException
+{
+ private Object object;
+
+ public RbacObjectNotFoundException()
+ {
+ super();
+ }
+
+ public RbacObjectNotFoundException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public RbacObjectNotFoundException( String message, Throwable cause, Object object )
+ {
+ super( message, cause );
+ this.object = object;
+ }
+
+ public RbacObjectNotFoundException( String message )
+ {
+ super( message );
+ }
+
+ public RbacObjectNotFoundException( String message, Object object )
+ {
+ super( message );
+ this.object = object;
+ }
+
+ public RbacObjectNotFoundException( Throwable cause )
+ {
+ super( cause );
+ }
+
+ public Object getObject()
+ {
+ return object;
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectNotFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacObjectNotFoundException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacPermanentException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacPermanentException.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacPermanentException.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacPermanentException.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,47 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * RbacPermanentException - tossed when a forbidden action against a permanent RBAC Object occurs.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RbacPermanentException
+ extends RbacManagerException
+{
+ public RbacPermanentException()
+ {
+ super();
+ }
+
+ public RbacPermanentException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public RbacPermanentException( String message )
+ {
+ super( message );
+ }
+
+ public RbacPermanentException( Throwable cause )
+ {
+ super( cause );
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacPermanentException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacPermanentException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacSecurityViolation.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacSecurityViolation.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacSecurityViolation.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacSecurityViolation.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,28 @@
+package org.codehaus.plexus.redback.rbac;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Exception thrown when there is a RBAC security violation.
+ */
+public class RbacSecurityViolation extends Exception
+{
+ public RbacSecurityViolation( String name )
+ {
+ super( name );
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacSecurityViolation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-model/src/main/java/org/codehaus/plexus/redback/rbac/RbacSecurityViolation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision