Changing some generic interfaces
This commit is contained in:
parent
51c9a3ef42
commit
87e8bba27c
|
@ -87,7 +87,7 @@ public class RbacAuthorizer
|
|||
if ( principal != null )
|
||||
{
|
||||
// Set permissions = manager.getAssignedPermissions( principal.toString(), operation );
|
||||
Map<String, List<Permission>> permissionMap = manager.getAssignedPermissionMap( principal );
|
||||
Map<String, List<? extends Permission>> permissionMap = manager.getAssignedPermissionMap( principal );
|
||||
|
||||
if ( permissionMap.keySet().contains( operation ) )
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ public class RbacAuthorizer
|
|||
if ( !guest.isLocked() )
|
||||
{
|
||||
// Set permissions = manager.getAssignedPermissions( principal.toString(), operation );
|
||||
Map<String, List<Permission>> permissionMap = manager.getAssignedPermissionMap( guest.getUsername() );
|
||||
Map<String, List<? extends Permission>> permissionMap = manager.getAssignedPermissionMap( guest.getUsername() );
|
||||
|
||||
if ( permissionMap.keySet().contains( operation ) )
|
||||
{
|
||||
|
|
|
@ -254,8 +254,8 @@ public class DataManagementTest
|
|||
|
||||
dataManagementTool.restoreRBACDatabase( manager, targetDirectory );
|
||||
|
||||
List<Role> roles = manager.getAllRoles();
|
||||
List<UserAssignment> assignments = manager.getAllUserAssignments();
|
||||
List<? extends Role> roles = manager.getAllRoles();
|
||||
List<? extends UserAssignment> assignments = manager.getAllUserAssignments();
|
||||
assertEquals( 4, roles.size() );
|
||||
assertEquals( 2, assignments.size() );
|
||||
assertEquals( 6, manager.getAllOperations().size() );
|
||||
|
|
|
@ -76,7 +76,7 @@ public class LockedAdminEnvironmentCheck
|
|||
List<String> roles = new ArrayList<String>();
|
||||
roles.add( RedbackRoleConstants.SYSTEM_ADMINISTRATOR_ROLE );
|
||||
|
||||
List<UserAssignment> systemAdminstrators;
|
||||
List<? extends UserAssignment> systemAdminstrators;
|
||||
try
|
||||
{
|
||||
systemAdminstrators = rbacManager.getUserAssignmentsForRoles( roles );
|
||||
|
|
|
@ -253,7 +253,7 @@ public class DefaultRoleManagementService
|
|||
}
|
||||
try
|
||||
{
|
||||
List<org.apache.archiva.redback.rbac.Role> roles =
|
||||
List<? extends org.apache.archiva.redback.rbac.Role> roles =
|
||||
filterAssignableRoles( rbacManager.getEffectivelyAssignedRoles( username ) );
|
||||
|
||||
List<Role> effectivelyAssignedRoles = new ArrayList<Role>( roles.size() );
|
||||
|
@ -312,7 +312,7 @@ public class DefaultRoleManagementService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<org.apache.archiva.redback.rbac.Role> roles = rbacManager.getAllRoles();
|
||||
List<? extends org.apache.archiva.redback.rbac.Role> roles = rbacManager.getAllRoles();
|
||||
|
||||
if ( roles == null )
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ public class DefaultRoleManagementService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<org.apache.archiva.redback.rbac.Role> roles = rbacManager.getAllRoles();
|
||||
List<? extends org.apache.archiva.redback.rbac.Role> roles = rbacManager.getAllRoles();
|
||||
|
||||
if ( roles == null )
|
||||
{
|
||||
|
@ -365,8 +365,8 @@ public class DefaultRoleManagementService
|
|||
}
|
||||
}
|
||||
|
||||
private List<org.apache.archiva.redback.rbac.Role> filterAssignableRoles(
|
||||
Collection<org.apache.archiva.redback.rbac.Role> roles )
|
||||
private List<? extends org.apache.archiva.redback.rbac.Role> filterAssignableRoles(
|
||||
Collection<? extends org.apache.archiva.redback.rbac.Role> roles )
|
||||
{
|
||||
List<org.apache.archiva.redback.rbac.Role> assignableRoles =
|
||||
new ArrayList<org.apache.archiva.redback.rbac.Role>( roles.size() );
|
||||
|
@ -388,13 +388,13 @@ public class DefaultRoleManagementService
|
|||
org.apache.archiva.redback.rbac.Role rbacRole = rbacManager.getRole( roleName );
|
||||
Role role = new Role( rbacRole );
|
||||
|
||||
Map<String, org.apache.archiva.redback.rbac.Role> parentRoles = rbacManager.getParentRoles( rbacRole );
|
||||
Map<String, ? extends org.apache.archiva.redback.rbac.Role> parentRoles = rbacManager.getParentRoles( rbacRole );
|
||||
for ( String parentRoleName : parentRoles.keySet() )
|
||||
{
|
||||
role.getParentRoleNames().add( parentRoleName );
|
||||
}
|
||||
|
||||
List<UserAssignment> userAssignments = rbacManager.getUserAssignmentsForRoles( Arrays.asList( roleName ) );
|
||||
List<? extends UserAssignment> userAssignments = rbacManager.getUserAssignmentsForRoles( Arrays.asList( roleName ) );
|
||||
|
||||
if ( userAssignments != null )
|
||||
{
|
||||
|
@ -414,7 +414,7 @@ public class DefaultRoleManagementService
|
|||
|
||||
if ( !role.getParentRoleNames().isEmpty() )
|
||||
{
|
||||
List<UserAssignment> userParentAssignments =
|
||||
List<? extends UserAssignment> userParentAssignments =
|
||||
rbacManager.getUserAssignmentsForRoles( parentRoles.keySet() );
|
||||
if ( userParentAssignments != null )
|
||||
{
|
||||
|
@ -614,7 +614,7 @@ public class DefaultRoleManagementService
|
|||
rbacManager.saveUserAssignment( assignment );
|
||||
}
|
||||
|
||||
List<org.apache.archiva.redback.rbac.Role> allRoles =
|
||||
List<? extends org.apache.archiva.redback.rbac.Role> allRoles =
|
||||
filterRolesForCurrentUserAccess( rbacManager.getAllRoles() );
|
||||
|
||||
List<ModelApplication> modelApplications = roleManager.getModel().getApplications();
|
||||
|
@ -628,7 +628,7 @@ public class DefaultRoleManagementService
|
|||
applicationRoles.setDescription( modelApplication.getDescription() );
|
||||
applicationRoles.setName( modelApplication.getId() );
|
||||
|
||||
Collection<org.apache.archiva.redback.rbac.Role> appRoles =
|
||||
Collection<? extends org.apache.archiva.redback.rbac.Role> appRoles =
|
||||
filterApplicationRoles( modelApplication, allRoles, modelApplication.getTemplates() );
|
||||
|
||||
List<String> roleNames = new ArrayList<String>( toRoleNames( appRoles ) );
|
||||
|
@ -750,7 +750,7 @@ public class DefaultRoleManagementService
|
|||
//----------------------------------------------------------------
|
||||
|
||||
private org.apache.archiva.redback.rbac.Role isInList( String roleName,
|
||||
Collection<org.apache.archiva.redback.rbac.Role> roles )
|
||||
Collection<? extends org.apache.archiva.redback.rbac.Role> roles )
|
||||
{
|
||||
for ( org.apache.archiva.redback.rbac.Role role : roles )
|
||||
{
|
||||
|
@ -762,8 +762,8 @@ public class DefaultRoleManagementService
|
|||
return null;
|
||||
}
|
||||
|
||||
private Collection<org.apache.archiva.redback.rbac.Role> filterApplicationRoles( ModelApplication application,
|
||||
List<org.apache.archiva.redback.rbac.Role> allRoles,
|
||||
private Collection<? extends org.apache.archiva.redback.rbac.Role> filterApplicationRoles( ModelApplication application,
|
||||
List<? extends org.apache.archiva.redback.rbac.Role> allRoles,
|
||||
List<ModelTemplate> applicationTemplates )
|
||||
{
|
||||
Set<org.apache.archiva.redback.rbac.Role> applicationRoles =
|
||||
|
@ -810,7 +810,7 @@ public class DefaultRoleManagementService
|
|||
return false;
|
||||
}
|
||||
|
||||
private List<String> toRoleNames( Collection<org.apache.archiva.redback.rbac.Role> roles )
|
||||
private List<String> toRoleNames( Collection<? extends org.apache.archiva.redback.rbac.Role> roles )
|
||||
{
|
||||
List<String> names = new ArrayList<String>( roles.size() );
|
||||
|
||||
|
@ -847,7 +847,7 @@ public class DefaultRoleManagementService
|
|||
}
|
||||
|
||||
private Set<String> discoverResources( List<ModelTemplate> applicationTemplates,
|
||||
Collection<org.apache.archiva.redback.rbac.Role> roles )
|
||||
Collection<? extends org.apache.archiva.redback.rbac.Role> roles )
|
||||
{
|
||||
Set<String> resources = new HashSet<String>();
|
||||
for ( ModelTemplate modelTemplate : applicationTemplates )
|
||||
|
@ -876,8 +876,8 @@ public class DefaultRoleManagementService
|
|||
* @throws RedbackServiceException
|
||||
*
|
||||
*/
|
||||
protected List<org.apache.archiva.redback.rbac.Role> filterRolesForCurrentUserAccess(
|
||||
List<org.apache.archiva.redback.rbac.Role> roleList )
|
||||
protected List<? extends org.apache.archiva.redback.rbac.Role> filterRolesForCurrentUserAccess(
|
||||
List<? extends org.apache.archiva.redback.rbac.Role> roleList )
|
||||
throws RedbackServiceException
|
||||
{
|
||||
RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get();
|
||||
|
@ -892,12 +892,12 @@ public class DefaultRoleManagementService
|
|||
new ArrayList<org.apache.archiva.redback.rbac.Role>();
|
||||
try
|
||||
{
|
||||
Map<String, List<Permission>> assignedPermissionMap = rbacManager.getAssignedPermissionMap( currentUser );
|
||||
Map<String, List<? extends Permission>> assignedPermissionMap = rbacManager.getAssignedPermissionMap( currentUser );
|
||||
List<String> resourceGrants = new ArrayList<String>();
|
||||
|
||||
if ( assignedPermissionMap.containsKey( RedbackRoleConstants.USER_MANAGEMENT_ROLE_GRANT_OPERATION ) )
|
||||
{
|
||||
List<Permission> roleGrantPermissions =
|
||||
List<? extends Permission> roleGrantPermissions =
|
||||
assignedPermissionMap.get( RedbackRoleConstants.USER_MANAGEMENT_ROLE_GRANT_OPERATION );
|
||||
|
||||
for ( Permission permission : roleGrantPermissions )
|
||||
|
|
|
@ -842,7 +842,7 @@ public class DefaultUserService
|
|||
{
|
||||
try
|
||||
{
|
||||
Set<org.apache.archiva.redback.rbac.Permission> permissions =
|
||||
Set<? extends org.apache.archiva.redback.rbac.Permission> permissions =
|
||||
rbacManager.getAssignedPermissions( userName );
|
||||
// FIXME return guest permissions !!
|
||||
List<Permission> userPermissions = new ArrayList<Permission>( permissions.size() );
|
||||
|
|
|
@ -30,6 +30,8 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* AbstractRBACManager
|
||||
|
@ -45,18 +47,21 @@ public abstract class AbstractRBACManager
|
|||
|
||||
private Resource globalResource;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void initialize()
|
||||
{
|
||||
//no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinalImplementation()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addListener( RBACManagerListener listener )
|
||||
{
|
||||
if ( !listeners.contains( listener ) )
|
||||
|
@ -65,6 +70,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( RBACManagerListener listener )
|
||||
{
|
||||
listeners.remove( listener );
|
||||
|
@ -179,36 +185,42 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRole( String roleName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
removeRole( getRole( roleName ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( String permissionName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
removePermission( getPermission( permissionName ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOperation( String operationName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
removeOperation( getOperation( operationName ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource( String resourceIdentifier )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
removeResource( getResource( resourceIdentifier ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserAssignment( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
removeUserAssignment( getUserAssignment( principal ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( Resource resource )
|
||||
{
|
||||
try
|
||||
|
@ -221,6 +233,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( String identifier )
|
||||
{
|
||||
try
|
||||
|
@ -241,6 +254,7 @@ public abstract class AbstractRBACManager
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean operationExists( Operation operation )
|
||||
{
|
||||
try
|
||||
|
@ -253,6 +267,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean operationExists( String name )
|
||||
{
|
||||
try
|
||||
|
@ -273,6 +288,7 @@ public abstract class AbstractRBACManager
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionExists( Permission permission )
|
||||
{
|
||||
try
|
||||
|
@ -285,6 +301,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionExists( String name )
|
||||
{
|
||||
try
|
||||
|
@ -305,6 +322,7 @@ public abstract class AbstractRBACManager
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roleExists( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -318,6 +336,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roleExists( String name )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -339,6 +358,7 @@ public abstract class AbstractRBACManager
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userAssignmentExists( String principal )
|
||||
{
|
||||
try
|
||||
|
@ -359,6 +379,7 @@ public abstract class AbstractRBACManager
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userAssignmentExists( UserAssignment assignment )
|
||||
{
|
||||
try
|
||||
|
@ -380,7 +401,8 @@ public abstract class AbstractRBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
public Set<Permission> getAssignedPermissions( String principal )
|
||||
@Override
|
||||
public Set<? extends Permission> getAssignedPermissions( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
||||
|
@ -426,33 +448,18 @@ public abstract class AbstractRBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
public Map<String, List<Permission>> getAssignedPermissionMap( String principal )
|
||||
@Override
|
||||
public Map<String, List<? extends Permission>> getAssignedPermissionMap( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
return getPermissionMapByOperation( getAssignedPermissions( principal ) );
|
||||
}
|
||||
|
||||
private Map<String, List<Permission>> getPermissionMapByOperation( Collection<Permission> permissions )
|
||||
private Map<String, List<? extends Permission>> getPermissionMapByOperation( Collection<? extends 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;
|
||||
Map<String, List<? extends Permission>> tList = new HashMap<>( );
|
||||
tList.putAll( permissions.stream().collect( Collectors.<Permission, String>groupingBy( p -> p.getOperation( ).getName( ) ) ) );
|
||||
return tList;
|
||||
}
|
||||
|
||||
private void gatherUniquePermissions( Role role, Collection<Permission> coll )
|
||||
|
@ -471,8 +478,8 @@ public abstract class AbstractRBACManager
|
|||
|
||||
if ( role.hasChildRoles() )
|
||||
{
|
||||
Map<String, Role> childRoles = getChildRoles( role );
|
||||
Iterator<Role> it = childRoles.values().iterator();
|
||||
Map<String, ? extends Role> childRoles = getChildRoles( role );
|
||||
Iterator<? extends Role> it = childRoles.values().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Role child = it.next();
|
||||
|
@ -481,6 +488,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> getAllAssignableRoles()
|
||||
throws RbacManagerException, RbacObjectNotFoundException
|
||||
{
|
||||
|
@ -509,6 +517,7 @@ public abstract class AbstractRBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
@Override
|
||||
public Collection<Role> getAssignedRoles( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -526,6 +535,7 @@ public abstract class AbstractRBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
@Override
|
||||
public Collection<Role> getAssignedRoles( UserAssignment ua )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -604,6 +614,7 @@ public abstract class AbstractRBACManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Role> getEffectivelyAssignedRoles( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -653,6 +664,7 @@ public abstract class AbstractRBACManager
|
|||
* @throws RbacManagerException
|
||||
* @throws RbacObjectNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public Collection<Role> getEffectivelyUnassignedRoles( String principal )
|
||||
throws RbacManagerException, RbacObjectNotFoundException
|
||||
{
|
||||
|
@ -672,6 +684,7 @@ public abstract class AbstractRBACManager
|
|||
* @throws RbacManagerException
|
||||
* @throws RbacObjectNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public Collection<Role> getUnassignedRoles( String principal )
|
||||
throws RbacManagerException, RbacObjectNotFoundException
|
||||
{
|
||||
|
@ -684,6 +697,7 @@ public abstract class AbstractRBACManager
|
|||
return CollectionUtils.subtract( allRoles, assignedRoles );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getGlobalResource()
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -696,6 +710,7 @@ public abstract class AbstractRBACManager
|
|||
return globalResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildRole( Role role, Role childRole )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -703,7 +718,8 @@ public abstract class AbstractRBACManager
|
|||
role.addChildRoleName( childRole.getName() );
|
||||
}
|
||||
|
||||
public Map<String, Role> getChildRoles( Role role )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getChildRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
Map<String, Role> childRoles = new HashMap<String, Role>();
|
||||
|
@ -759,7 +775,8 @@ public abstract class AbstractRBACManager
|
|||
return childRoles;
|
||||
}
|
||||
|
||||
public Map<String, Role> getParentRoles( Role role )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getParentRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
Map<String, Role> parentRoles = new HashMap<String, Role>();
|
||||
|
@ -768,7 +785,7 @@ public abstract class AbstractRBACManager
|
|||
{
|
||||
if ( !r.getName().equals( role.getName() ) )
|
||||
{
|
||||
Set<Role> effectiveRoles = getEffectiveRoles( r );
|
||||
Set<? extends Role> effectiveRoles = getEffectiveRoles( r );
|
||||
for ( Role currentRole : effectiveRoles )
|
||||
{
|
||||
if ( currentRole.getName().equals( role.getName() ) )
|
||||
|
@ -784,7 +801,8 @@ public abstract class AbstractRBACManager
|
|||
return parentRoles;
|
||||
}
|
||||
|
||||
public Set<Role> getEffectiveRoles( Role role )
|
||||
@Override
|
||||
public Set<? extends Role> getEffectiveRoles( Role role )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
Set<Role> roleSet = new HashSet<Role>();
|
||||
|
@ -793,7 +811,8 @@ public abstract class AbstractRBACManager
|
|||
return roleSet;
|
||||
}
|
||||
|
||||
public Map<String, Role> getRoles( Collection<String> roleNames )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getRoles( Collection<String> roleNames )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
Map<String, Role> roleMap = new HashMap<String, Role>();
|
||||
|
|
|
@ -81,28 +81,28 @@ public interface RBACManager
|
|||
Role getRole( String roleName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
Map<String, Role> getRoles( Collection<String> roleNames )
|
||||
Map<String, ? extends Role> getRoles( Collection<String> roleNames )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
void addChildRole( Role role, Role childRole )
|
||||
throws RbacObjectInvalidException, RbacManagerException;
|
||||
|
||||
Map<String, Role> getChildRoles( Role role )
|
||||
Map<String, ? extends Role> getChildRoles( Role role )
|
||||
throws RbacManagerException;
|
||||
|
||||
Map<String, Role> getParentRoles( Role role )
|
||||
Map<String, ? extends Role> getParentRoles( Role role )
|
||||
throws RbacManagerException;
|
||||
|
||||
/**
|
||||
* Method getRoles
|
||||
*/
|
||||
List<Role> getAllRoles()
|
||||
List<? extends Role> getAllRoles()
|
||||
throws RbacManagerException;
|
||||
|
||||
/**
|
||||
* Method getEffectiveRoles
|
||||
*/
|
||||
Set<Role> getEffectiveRoles( Role role )
|
||||
Set<? extends Role> getEffectiveRoles( Role role )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -169,7 +169,7 @@ public interface RBACManager
|
|||
Permission getPermission( String permissionName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
List<Permission> getAllPermissions()
|
||||
List<? extends Permission> getAllPermissions()
|
||||
throws RbacManagerException;
|
||||
|
||||
void removePermission( Permission permission )
|
||||
|
@ -213,7 +213,7 @@ public interface RBACManager
|
|||
Operation getOperation( String operationName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
List<Operation> getAllOperations()
|
||||
List<? extends Operation> getAllOperations()
|
||||
throws RbacManagerException;
|
||||
|
||||
void removeOperation( Operation operation )
|
||||
|
@ -249,7 +249,7 @@ public interface RBACManager
|
|||
Resource getResource( String resourceIdentifier )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
List<Resource> getAllResources()
|
||||
List<? extends Resource> getAllResources()
|
||||
throws RbacManagerException;
|
||||
|
||||
void removeResource( Resource resource )
|
||||
|
@ -293,13 +293,13 @@ public interface RBACManager
|
|||
/**
|
||||
* Method getAssignments
|
||||
*/
|
||||
List<UserAssignment> getAllUserAssignments()
|
||||
List<? extends UserAssignment> getAllUserAssignments()
|
||||
throws RbacManagerException;
|
||||
|
||||
/**
|
||||
* Method getUserAssignmentsForRoless
|
||||
*/
|
||||
List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
|
||||
List<? extends UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
|
||||
throws RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -333,7 +333,7 @@ public interface RBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
Collection<Role> getAssignedRoles( String principal )
|
||||
Collection<? extends Role> getAssignedRoles( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -342,7 +342,7 @@ public interface RBACManager
|
|||
* @param userAssignment
|
||||
* @return Collection of {@link Role} objects for the provided UserAssignment.
|
||||
*/
|
||||
Collection<Role> getAssignedRoles( UserAssignment userAssignment )
|
||||
Collection<? extends Role> getAssignedRoles( UserAssignment userAssignment )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -354,7 +354,7 @@ public interface RBACManager
|
|||
* @throws RbacManagerException
|
||||
* @throws RbacObjectNotFoundException
|
||||
*/
|
||||
Collection<Role> getEffectivelyUnassignedRoles( String principal )
|
||||
Collection<? extends Role> getEffectivelyUnassignedRoles( String principal )
|
||||
throws RbacManagerException, RbacObjectNotFoundException;
|
||||
|
||||
/**
|
||||
|
@ -365,7 +365,7 @@ public interface RBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
Collection<Role> getEffectivelyAssignedRoles( String principal )
|
||||
Collection<? extends Role> getEffectivelyAssignedRoles( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -376,7 +376,7 @@ public interface RBACManager
|
|||
* @throws RbacManagerException
|
||||
* @throws RbacObjectNotFoundException
|
||||
*/
|
||||
Collection<Role> getUnassignedRoles( String principal )
|
||||
Collection<? extends Role> getUnassignedRoles( String principal )
|
||||
throws RbacManagerException, RbacObjectNotFoundException;
|
||||
|
||||
/**
|
||||
|
@ -388,7 +388,7 @@ public interface RBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
Set<Permission> getAssignedPermissions( String principal )
|
||||
Set<? extends Permission> getAssignedPermissions( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -399,7 +399,7 @@ public interface RBACManager
|
|||
* @throws RbacObjectNotFoundException
|
||||
* @throws RbacManagerException
|
||||
*/
|
||||
Map<String, List<Permission>> getAssignedPermissionMap( String principal )
|
||||
Map<String, List<? extends Permission>> getAssignedPermissionMap( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException;
|
||||
|
||||
/**
|
||||
|
@ -409,7 +409,7 @@ public interface RBACManager
|
|||
* @throws RbacManagerException
|
||||
* @throws RbacObjectNotFoundException
|
||||
*/
|
||||
List<Role> getAllAssignableRoles()
|
||||
List<? extends Role> getAllAssignableRoles()
|
||||
throws RbacManagerException, RbacObjectNotFoundException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,7 +77,7 @@ public interface Role
|
|||
/**
|
||||
* Method getPermissions
|
||||
*/
|
||||
List<Permission> getPermissions();
|
||||
List<? extends Permission> getPermissions();
|
||||
|
||||
/**
|
||||
* true if this role is available to be assigned to a user
|
||||
|
|
|
@ -79,17 +79,19 @@ public class CachedRbacManager
|
|||
|
||||
@Inject
|
||||
@Named( value = "cache#userPermissions" )
|
||||
private Cache<String, Map<String, List<Permission>>> userPermissionsCache;
|
||||
private Cache<String, Map<String, List<? extends Permission>>> userPermissionsCache;
|
||||
|
||||
@Inject
|
||||
@Named( value = "cache#effectiveRoleSet" )
|
||||
private Cache<String, Set<Role>> effectiveRoleSetCache;
|
||||
private Cache<String, Set<? extends Role>> effectiveRoleSetCache;
|
||||
|
||||
@Override
|
||||
public void initialize()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildRole( Role role, Role childRole )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -104,11 +106,13 @@ public class CachedRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( RBACManagerListener listener )
|
||||
{
|
||||
this.rbacImpl.addListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation createOperation( String name )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -116,6 +120,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.createOperation( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission createPermission( String name )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -123,6 +128,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.createPermission( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission createPermission( String name, String operationName, String resourceIdentifier )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -130,6 +136,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.createPermission( name, operationName, resourceIdentifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource createResource( String identifier )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -137,12 +144,14 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.createResource( identifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role createRole( String name )
|
||||
{
|
||||
rolesCache.remove( name );
|
||||
return this.rbacImpl.createRole( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAssignment createUserAssignment( String principal )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -150,6 +159,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.createUserAssignment( principal );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseDatabase()
|
||||
{
|
||||
try
|
||||
|
@ -166,42 +176,48 @@ public class CachedRbacManager
|
|||
/**
|
||||
* @see org.apache.archiva.redback.rbac.RBACManager#getAllAssignableRoles()
|
||||
*/
|
||||
public List<Role> getAllAssignableRoles()
|
||||
@Override
|
||||
public List<? extends Role> getAllAssignableRoles()
|
||||
throws RbacManagerException, RbacObjectNotFoundException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAllAssignableRoles()" );
|
||||
return this.rbacImpl.getAllAssignableRoles();
|
||||
}
|
||||
|
||||
public List<Operation> getAllOperations()
|
||||
@Override
|
||||
public List<? extends Operation> getAllOperations()
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAllOperations()" );
|
||||
return this.rbacImpl.getAllOperations();
|
||||
}
|
||||
|
||||
public List<Permission> getAllPermissions()
|
||||
@Override
|
||||
public List<? extends Permission> getAllPermissions()
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAllPermissions()" );
|
||||
return this.rbacImpl.getAllPermissions();
|
||||
}
|
||||
|
||||
public List<Resource> getAllResources()
|
||||
@Override
|
||||
public List<? extends Resource> getAllResources()
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAllResources()" );
|
||||
return this.rbacImpl.getAllResources();
|
||||
}
|
||||
|
||||
public List<Role> getAllRoles()
|
||||
@Override
|
||||
public List<? extends Role> getAllRoles()
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAllRoles()" );
|
||||
return this.rbacImpl.getAllRoles();
|
||||
}
|
||||
|
||||
public List<UserAssignment> getAllUserAssignments()
|
||||
@Override
|
||||
public List<? extends UserAssignment> getAllUserAssignments()
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAllUserAssignments()" );
|
||||
|
@ -211,11 +227,12 @@ public class CachedRbacManager
|
|||
/**
|
||||
* @see org.apache.archiva.redback.rbac.RBACManager#getAssignedPermissionMap(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public Map<String, List<Permission>> getAssignedPermissionMap( String principal )
|
||||
public Map<String, List<? extends Permission>> getAssignedPermissionMap( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
Map<String, List<Permission>> el = userPermissionsCache.get( principal );
|
||||
Map<String, List<? extends Permission>> el = userPermissionsCache.get( principal );
|
||||
|
||||
if ( el != null )
|
||||
{
|
||||
|
@ -224,66 +241,74 @@ public class CachedRbacManager
|
|||
}
|
||||
|
||||
log.debug( "building user permission map" );
|
||||
Map<String, List<Permission>> userPermMap = this.rbacImpl.getAssignedPermissionMap( principal );
|
||||
Map<String, List<? extends Permission>> userPermMap = this.rbacImpl.getAssignedPermissionMap( principal );
|
||||
userPermissionsCache.put( principal, userPermMap );
|
||||
return userPermMap;
|
||||
|
||||
}
|
||||
|
||||
public Set<Permission> getAssignedPermissions( String principal )
|
||||
@Override
|
||||
public Set<? extends Permission> getAssignedPermissions( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAssignedPermissions(String)" );
|
||||
return this.rbacImpl.getAssignedPermissions( principal );
|
||||
}
|
||||
|
||||
public Collection<Role> getAssignedRoles( String principal )
|
||||
@Override
|
||||
public Collection<? extends Role> getAssignedRoles( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAssignedRoles(String)" );
|
||||
return this.rbacImpl.getAssignedRoles( principal );
|
||||
}
|
||||
|
||||
public Collection<Role> getAssignedRoles( UserAssignment userAssignment )
|
||||
@Override
|
||||
public Collection<? extends Role> getAssignedRoles( UserAssignment userAssignment )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getAssignedRoles(UserAssignment)" );
|
||||
return this.rbacImpl.getAssignedRoles( userAssignment );
|
||||
}
|
||||
|
||||
public Map<String, Role> getChildRoles( Role role )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getChildRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getChildRoles(Role)" );
|
||||
return this.rbacImpl.getChildRoles( role );
|
||||
}
|
||||
|
||||
public Map<String, Role> getParentRoles( Role role )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getParentRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getParentRoles(Role)" );
|
||||
return this.rbacImpl.getParentRoles( role );
|
||||
}
|
||||
|
||||
public Collection<Role> getEffectivelyAssignedRoles( String principal )
|
||||
@Override
|
||||
public Collection<? extends Role> getEffectivelyAssignedRoles( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getEffectivelyAssignedRoles(String)" );
|
||||
return this.rbacImpl.getEffectivelyAssignedRoles( principal );
|
||||
}
|
||||
|
||||
public Collection<Role> getEffectivelyUnassignedRoles( String principal )
|
||||
@Override
|
||||
public Collection<? extends Role> getEffectivelyUnassignedRoles( String principal )
|
||||
throws RbacManagerException, RbacObjectNotFoundException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getEffectivelyUnassignedRoles(String)" );
|
||||
return this.rbacImpl.getEffectivelyUnassignedRoles( principal );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public Set<Role> getEffectiveRoles( Role role )
|
||||
public Set<? extends Role> getEffectiveRoles( Role role )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
Set<Role> el = effectiveRoleSetCache.get( role.getName() );
|
||||
Set<? extends Role> el = effectiveRoleSetCache.get( role.getName() );
|
||||
|
||||
if ( el != null )
|
||||
{
|
||||
|
@ -293,12 +318,13 @@ public class CachedRbacManager
|
|||
else
|
||||
{
|
||||
log.debug( "building effective role set" );
|
||||
Set<Role> effectiveRoleSet = this.rbacImpl.getEffectiveRoles( role );
|
||||
Set<? extends Role> effectiveRoleSet = this.rbacImpl.getEffectiveRoles( role );
|
||||
effectiveRoleSetCache.put( role.getName(), effectiveRoleSet );
|
||||
return effectiveRoleSet;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getGlobalResource()
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -307,6 +333,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.getGlobalResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation( String operationName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -323,6 +350,7 @@ public class CachedRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission getPermission( String permissionName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -339,6 +367,7 @@ public class CachedRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getResource( String resourceIdentifier )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -355,6 +384,7 @@ public class CachedRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role getRole( String roleName )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -371,20 +401,23 @@ public class CachedRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
public Map<String, Role> getRoles( Collection<String> roleNames )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getRoles( Collection<String> roleNames )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getRoles(Collection)" );
|
||||
return this.rbacImpl.getRoles( roleNames );
|
||||
}
|
||||
|
||||
public Collection<Role> getUnassignedRoles( String principal )
|
||||
@Override
|
||||
public Collection<? extends Role> getUnassignedRoles( String principal )
|
||||
throws RbacManagerException, RbacObjectNotFoundException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getUnassignedRoles(String)" );
|
||||
return this.rbacImpl.getUnassignedRoles( principal );
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAssignment getUserAssignment( String principal )
|
||||
throws RbacObjectNotFoundException, RbacManagerException
|
||||
{
|
||||
|
@ -401,13 +434,15 @@ public class CachedRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
|
||||
@Override
|
||||
public List<? extends UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
|
||||
throws RbacManagerException
|
||||
{
|
||||
log.debug( "NOT CACHED - .getUserAssignmentsForRoles(Collection)" );
|
||||
return this.rbacImpl.getUserAssignmentsForRoles( roleNames );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean operationExists( Operation operation )
|
||||
{
|
||||
if ( operation == null )
|
||||
|
@ -423,6 +458,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.operationExists( operation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean operationExists( String name )
|
||||
{
|
||||
if ( operationsCache.hasKey( name ) )
|
||||
|
@ -433,6 +469,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.operationExists( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionExists( Permission permission )
|
||||
{
|
||||
if ( permission == null )
|
||||
|
@ -448,6 +485,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.permissionExists( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionExists( String name )
|
||||
{
|
||||
if ( permissionsCache.hasKey( name ) )
|
||||
|
@ -458,6 +496,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.permissionExists( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacInit( boolean freshdb )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -473,6 +512,7 @@ public class CachedRbacManager
|
|||
this.userPermissionsCache.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacPermissionRemoved( Permission permission )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -483,6 +523,7 @@ public class CachedRbacManager
|
|||
invalidateCachedPermission( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacPermissionSaved( Permission permission )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -493,6 +534,7 @@ public class CachedRbacManager
|
|||
invalidateCachedPermission( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacRoleRemoved( Role role )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -503,6 +545,7 @@ public class CachedRbacManager
|
|||
invalidateCachedRole( role );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacRoleSaved( Role role )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -513,6 +556,7 @@ public class CachedRbacManager
|
|||
invalidateCachedRole( role );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacUserAssignmentRemoved( UserAssignment userAssignment )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -523,6 +567,7 @@ public class CachedRbacManager
|
|||
invalidateCachedUserAssignment( userAssignment );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacUserAssignmentSaved( UserAssignment userAssignment )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -533,11 +578,13 @@ public class CachedRbacManager
|
|||
invalidateCachedUserAssignment( userAssignment );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( RBACManagerListener listener )
|
||||
{
|
||||
this.rbacImpl.removeListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOperation( Operation operation )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -545,6 +592,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeOperation( operation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOperation( String operationName )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -552,6 +600,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeOperation( operationName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( Permission permission )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -559,6 +608,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removePermission( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( String permissionName )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -566,6 +616,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removePermission( permissionName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource( Resource resource )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -573,6 +624,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeResource( resource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource( String resourceIdentifier )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -580,6 +632,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeResource( resourceIdentifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRole( Role role )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -587,6 +640,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeRole( role );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRole( String roleName )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -594,6 +648,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeRole( roleName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserAssignment( String principal )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -601,6 +656,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeUserAssignment( principal );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserAssignment( UserAssignment userAssignment )
|
||||
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -608,6 +664,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.removeUserAssignment( userAssignment );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( Resource resource )
|
||||
{
|
||||
if ( resourcesCache.hasKey( resource.getIdentifier() ) )
|
||||
|
@ -618,6 +675,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.resourceExists( resource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( String identifier )
|
||||
{
|
||||
if ( resourcesCache.hasKey( identifier ) )
|
||||
|
@ -628,6 +686,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.resourceExists( identifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roleExists( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -639,6 +698,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.roleExists( role );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roleExists( String name )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -650,6 +710,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.roleExists( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation saveOperation( Operation operation )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -657,6 +718,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.saveOperation( operation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission savePermission( Permission permission )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -664,6 +726,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.savePermission( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource saveResource( Resource resource )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -671,6 +734,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.saveResource( resource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Role saveRole( Role role )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -697,6 +761,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.saveRole( role );
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void saveRoles( Collection<Role> roles )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -719,6 +784,7 @@ public class CachedRbacManager
|
|||
this.rbacImpl.saveRoles( roles );
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAssignment saveUserAssignment( UserAssignment userAssignment )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
|
@ -726,6 +792,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.saveUserAssignment( userAssignment );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userAssignmentExists( String principal )
|
||||
{
|
||||
if ( userAssignmentsCache.hasKey( principal ) )
|
||||
|
@ -736,6 +803,7 @@ public class CachedRbacManager
|
|||
return this.rbacImpl.userAssignmentExists( principal );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userAssignmentExists( UserAssignment assignment )
|
||||
{
|
||||
if ( userAssignmentsCache.hasKey( assignment.getPrincipal() ) )
|
||||
|
@ -803,72 +871,77 @@ public class CachedRbacManager
|
|||
userPermissionsCache.clear();
|
||||
}
|
||||
|
||||
public Cache getOperationsCache()
|
||||
public Cache<String, ? extends Operation> getOperationsCache()
|
||||
{
|
||||
return operationsCache;
|
||||
}
|
||||
|
||||
public void setOperationsCache( Cache operationsCache )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void setOperationsCache( Cache<String, ? extends Operation> operationsCache )
|
||||
{
|
||||
this.operationsCache = operationsCache;
|
||||
this.operationsCache = (Cache<String, Operation>) operationsCache;
|
||||
}
|
||||
|
||||
public Cache getPermissionsCache()
|
||||
public Cache<String, ? extends Permission> getPermissionsCache()
|
||||
{
|
||||
return permissionsCache;
|
||||
}
|
||||
|
||||
public void setPermissionsCache( Cache permissionsCache )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void setPermissionsCache( Cache<String, ? extends Permission> permissionsCache )
|
||||
{
|
||||
this.permissionsCache = permissionsCache;
|
||||
this.permissionsCache = (Cache<String, Permission>) permissionsCache;
|
||||
}
|
||||
|
||||
public Cache getResourcesCache()
|
||||
public Cache<String, ? extends Resource> getResourcesCache()
|
||||
{
|
||||
return resourcesCache;
|
||||
}
|
||||
|
||||
public void setResourcesCache( Cache resourcesCache )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void setResourcesCache( Cache<String, ? extends Resource> resourcesCache )
|
||||
{
|
||||
this.resourcesCache = resourcesCache;
|
||||
this.resourcesCache = (Cache<String, Resource>) resourcesCache;
|
||||
}
|
||||
|
||||
public Cache getRolesCache()
|
||||
public Cache<String, ? extends Role> getRolesCache()
|
||||
{
|
||||
return rolesCache;
|
||||
}
|
||||
|
||||
public void setRolesCache( Cache rolesCache )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void setRolesCache( Cache<String, ? extends Role> rolesCache )
|
||||
{
|
||||
this.rolesCache = rolesCache;
|
||||
this.rolesCache = (Cache<String, Role>) rolesCache;
|
||||
}
|
||||
|
||||
public Cache getUserAssignmentsCache()
|
||||
public Cache<String, ? extends UserAssignment> getUserAssignmentsCache()
|
||||
{
|
||||
return userAssignmentsCache;
|
||||
}
|
||||
|
||||
public void setUserAssignmentsCache( Cache userAssignmentsCache )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void setUserAssignmentsCache( Cache<String, ? extends UserAssignment> userAssignmentsCache )
|
||||
{
|
||||
this.userAssignmentsCache = userAssignmentsCache;
|
||||
this.userAssignmentsCache = (Cache<String, UserAssignment>) userAssignmentsCache;
|
||||
}
|
||||
|
||||
public Cache getUserPermissionsCache()
|
||||
public Cache<String, Map<String, List<? extends Permission>>> getUserPermissionsCache()
|
||||
{
|
||||
return userPermissionsCache;
|
||||
}
|
||||
|
||||
public void setUserPermissionsCache( Cache userPermissionsCache )
|
||||
public void setUserPermissionsCache( Cache<String, Map<String, List<? extends Permission>>> userPermissionsCache )
|
||||
{
|
||||
this.userPermissionsCache = userPermissionsCache;
|
||||
}
|
||||
|
||||
public Cache getEffectiveRoleSetCache()
|
||||
public Cache<String, Set<? extends Role>> getEffectiveRoleSetCache()
|
||||
{
|
||||
return effectiveRoleSetCache;
|
||||
}
|
||||
|
||||
public void setEffectiveRoleSetCache( Cache effectiveRoleSetCache )
|
||||
public void setEffectiveRoleSetCache( Cache<String, Set<? extends Role>> effectiveRoleSetCache )
|
||||
{
|
||||
this.effectiveRoleSetCache = effectiveRoleSetCache;
|
||||
}
|
||||
|
@ -884,16 +957,19 @@ public class CachedRbacManager
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFinalImplementation()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionKey()
|
||||
{
|
||||
return "archiva.redback.rbacmanager.cached";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -76,13 +76,13 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public Map<String, List<Permission>> getAssignedPermissionMap(String principal) throws RbacManagerException {
|
||||
public Map<String, List<? extends Permission>> getAssignedPermissionMap(String principal) throws RbacManagerException {
|
||||
return super.getAssignedPermissionMap(principal);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Map<String, Role> getChildRoles(Role role) throws RbacManagerException {
|
||||
public Map<String, ? extends Role> getChildRoles(Role role) throws RbacManagerException {
|
||||
return super.getChildRoles(role);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
}
|
||||
|
||||
final EntityManager em = getEm();
|
||||
List<Role> merged = new ArrayList<Role>();
|
||||
List<Role> merged = new ArrayList<>( );
|
||||
for (Role role : roles ) {
|
||||
RBACObjectAssertions.assertValid(role);
|
||||
merged.add(em.merge(role));
|
||||
|
@ -129,9 +129,9 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Role> getAllRoles() throws RbacManagerException {
|
||||
public List<? extends Role> getAllRoles() throws RbacManagerException {
|
||||
final EntityManager em = getEm();
|
||||
Query q = em.createQuery("SELECT r FROM JpaRole r");
|
||||
TypedQuery<JpaRole> q = em.createQuery("SELECT r FROM JpaRole r", JpaRole.class);
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
if (myRole == null) {
|
||||
throw new RbacObjectNotFoundException("Role not found "+role.getName());
|
||||
}
|
||||
myRole.setPermissions(new ArrayList<Permission>());
|
||||
myRole.setPermissions( new ArrayList<>( ));
|
||||
em.remove(myRole);
|
||||
fireRbacRoleRemoved(myRole);
|
||||
}
|
||||
|
@ -210,10 +210,10 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> getAllPermissions() throws RbacManagerException {
|
||||
public List<? extends Permission> getAllPermissions() throws RbacManagerException {
|
||||
final EntityManager em = getEm();
|
||||
TypedQuery<JpaPermission> q = em.createQuery("SELECT p FROM JpaPermission p",JpaPermission.class);
|
||||
return (List<Permission>)(List<?>)q.getResultList();
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -251,8 +251,7 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
throw new RbacObjectInvalidException("Operation is not JpaOperation object");
|
||||
}
|
||||
final EntityManager em = getEm();
|
||||
Operation savedOperation = em.merge(operation);
|
||||
return savedOperation;
|
||||
return em.merge(operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,9 +265,9 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Operation> getAllOperations() throws RbacManagerException {
|
||||
public List<? extends Operation> getAllOperations() throws RbacManagerException {
|
||||
final EntityManager em = getEm();
|
||||
Query q = em.createQuery("SELECT o FROM JpaOperation o");
|
||||
TypedQuery<JpaOperation> q = em.createQuery("SELECT o FROM JpaOperation o", JpaOperation.class);
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
|
@ -306,8 +305,7 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
throw new RbacObjectInvalidException("Resource is not JpaResource");
|
||||
}
|
||||
final EntityManager em = getEm();
|
||||
Resource savedResource = em.merge(resource);
|
||||
return savedResource;
|
||||
return em.merge(resource);
|
||||
}
|
||||
|
||||
// Overriding to add the transactional attribute here
|
||||
|
@ -330,10 +328,10 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Resource> getAllResources() throws RbacManagerException {
|
||||
public List<? extends Resource> getAllResources() throws RbacManagerException {
|
||||
final EntityManager em = getEm();
|
||||
TypedQuery<JpaResource> q = em.createQuery("SELECT r FROM JpaResource r",JpaResource.class);
|
||||
return (List<Resource>)(List<?>)q.getResultList();
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -385,17 +383,17 @@ public class JpaRbacManager extends AbstractRBACManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<UserAssignment> getAllUserAssignments() throws RbacManagerException {
|
||||
public List<? extends UserAssignment> getAllUserAssignments() throws RbacManagerException {
|
||||
final EntityManager em = getEm();
|
||||
Query q = em.createQuery("SELECT ua FROM JpaUserAssignment ua");
|
||||
TypedQuery<JpaUserAssignment> q = em.createQuery("SELECT ua FROM JpaUserAssignment ua", JpaUserAssignment.class);
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserAssignment> getUserAssignmentsForRoles(Collection<String> roleNames) throws RbacManagerException {
|
||||
public List<? extends UserAssignment> getUserAssignmentsForRoles(Collection<String> roleNames) throws RbacManagerException {
|
||||
try {
|
||||
final EntityManager em = getEm();
|
||||
Query q = em.createQuery("SELECT ua FROM JpaUserAssignment ua WHERE ua.roleNames IN :roles");
|
||||
TypedQuery<JpaUserAssignment> q = em.createQuery("SELECT ua FROM JpaUserAssignment ua WHERE ua.roleNames IN :roles", JpaUserAssignment.class);
|
||||
q.setParameter("roles", roleNames);
|
||||
return q.getResultList();
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -99,9 +99,8 @@ public class JpaRole extends AbstractRole implements Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
// Maybe better to create a new list?
|
||||
return (List<Permission>)(List<?>)permissions;
|
||||
public List<? extends Permission> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -115,6 +115,7 @@ public class LdapRbacManager
|
|||
|
||||
private boolean writableLdap = false;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void initialize()
|
||||
{
|
||||
|
@ -122,47 +123,55 @@ public class LdapRbacManager
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addChildRole( Role role, Role childRole )
|
||||
throws RbacObjectInvalidException, RbacManagerException
|
||||
{
|
||||
this.rbacImpl.addChildRole( role, childRole );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( RBACManagerListener listener )
|
||||
{
|
||||
super.addListener( listener );
|
||||
this.rbacImpl.addListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation createOperation( String name )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.createOperation( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission createPermission( String name )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.createPermission( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission createPermission( String name, String operationName, String resourceIdentifier )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.createPermission( name, operationName, resourceIdentifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource createResource( String identifier )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.createResource( identifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role createRole( String name )
|
||||
{
|
||||
return this.rbacImpl.createRole( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAssignment createUserAssignment( String username )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -170,6 +179,7 @@ public class LdapRbacManager
|
|||
return this.rbacImpl.createUserAssignment( username );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseDatabase()
|
||||
{
|
||||
if ( writableLdap )
|
||||
|
@ -204,6 +214,7 @@ public class LdapRbacManager
|
|||
/**
|
||||
* @see org.apache.archiva.redback.rbac.RBACManager#getAllAssignableRoles()
|
||||
*/
|
||||
@Override
|
||||
public List<Role> getAllAssignableRoles()
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -229,24 +240,28 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
public List<Operation> getAllOperations()
|
||||
@Override
|
||||
public List<? extends Operation> getAllOperations()
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getAllOperations();
|
||||
}
|
||||
|
||||
public List<Permission> getAllPermissions()
|
||||
@Override
|
||||
public List<? extends Permission> getAllPermissions()
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getAllPermissions();
|
||||
}
|
||||
|
||||
public List<Resource> getAllResources()
|
||||
@Override
|
||||
public List<? extends Resource> getAllResources()
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getAllResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> getAllRoles()
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -277,6 +292,7 @@ public class LdapRbacManager
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserAssignment> getAllUserAssignments()
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -407,7 +423,7 @@ public class LdapRbacManager
|
|||
protected List<String> getRealRoles()
|
||||
throws RbacManagerException
|
||||
{
|
||||
List<Role> roles = this.rbacImpl.getAllRoles();
|
||||
List<? extends Role> roles = this.rbacImpl.getAllRoles();
|
||||
List<String> roleNames = new ArrayList<String>( roles.size() );
|
||||
for ( Role role : roles )
|
||||
{
|
||||
|
@ -416,6 +432,7 @@ public class LdapRbacManager
|
|||
return roleNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Role> getAssignedRoles( String username )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -454,19 +471,22 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Role> getAssignedRoles( UserAssignment userAssignment )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return getAssignedRoles( userAssignment.getPrincipal() );
|
||||
}
|
||||
|
||||
public Map<String, Role> getChildRoles( Role role )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getChildRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getChildRoles( role );
|
||||
}
|
||||
|
||||
public Map<String, Role> getParentRoles( Role role )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getParentRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getParentRoles( role );
|
||||
|
@ -488,36 +508,42 @@ public class LdapRbacManager
|
|||
// }
|
||||
|
||||
|
||||
public Set<Role> getEffectiveRoles( Role role )
|
||||
@Override
|
||||
public Set<? extends Role> getEffectiveRoles( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getEffectiveRoles( role );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getGlobalResource()
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getGlobalResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation( String operationName )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getOperation( operationName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission getPermission( String permissionName )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getPermission( permissionName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getResource( String resourceIdentifier )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getResource( resourceIdentifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role getRole( String roleName )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -555,12 +581,14 @@ public class LdapRbacManager
|
|||
return role;
|
||||
}
|
||||
|
||||
public Map<String, Role> getRoles( Collection<String> roleNames )
|
||||
@Override
|
||||
public Map<String, ? extends Role> getRoles( Collection<String> roleNames )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.getRoles( roleNames );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Role> getUnassignedRoles( String username )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -604,6 +632,7 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAssignment getUserAssignment( String username )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -643,33 +672,39 @@ public class LdapRbacManager
|
|||
//return this.rbacImpl.getUserAssignment( username );
|
||||
}
|
||||
|
||||
public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
|
||||
@Override
|
||||
public List<? extends UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
|
||||
throws RbacManagerException
|
||||
{
|
||||
// TODO from ldap
|
||||
return this.rbacImpl.getUserAssignmentsForRoles( roleNames );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean operationExists( Operation operation )
|
||||
{
|
||||
return this.rbacImpl.operationExists( operation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean operationExists( String name )
|
||||
{
|
||||
return this.rbacImpl.operationExists( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionExists( Permission permission )
|
||||
{
|
||||
return this.rbacImpl.permissionExists( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionExists( String name )
|
||||
{
|
||||
return this.rbacImpl.permissionExists( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacInit( boolean freshdb )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -678,6 +713,7 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacPermissionRemoved( Permission permission )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -687,6 +723,7 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacPermissionSaved( Permission permission )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -696,6 +733,7 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacRoleRemoved( Role role )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -705,6 +743,7 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacRoleSaved( Role role )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -714,6 +753,7 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacUserAssignmentRemoved( UserAssignment userAssignment )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -723,6 +763,7 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rbacUserAssignmentSaved( UserAssignment userAssignment )
|
||||
{
|
||||
if ( rbacImpl instanceof RBACManagerListener )
|
||||
|
@ -732,47 +773,55 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( RBACManagerListener listener )
|
||||
{
|
||||
this.rbacImpl.removeListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOperation( Operation operation )
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.rbacImpl.removeOperation( operation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOperation( String operationName )
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.rbacImpl.removeOperation( operationName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( Permission permission )
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.rbacImpl.removePermission( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( String permissionName )
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.rbacImpl.removePermission( permissionName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource( Resource resource )
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.rbacImpl.removeResource( resource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource( String resourceIdentifier )
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.rbacImpl.removeResource( resourceIdentifier );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRole( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -805,6 +854,7 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRole( String roleName )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -815,6 +865,7 @@ public class LdapRbacManager
|
|||
removeRole( new RoleImpl( roleName ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserAssignment( String username )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -823,6 +874,7 @@ public class LdapRbacManager
|
|||
this.rbacImpl.removeUserAssignment( username );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserAssignment( UserAssignment userAssignment )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -834,11 +886,13 @@ public class LdapRbacManager
|
|||
this.rbacImpl.removeUserAssignment( userAssignment );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( Resource resource )
|
||||
{
|
||||
return this.rbacImpl.resourceExists( resource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( String identifier )
|
||||
{
|
||||
return this.rbacImpl.resourceExists( identifier );
|
||||
|
@ -894,24 +948,28 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation saveOperation( Operation operation )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.saveOperation( operation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission savePermission( Permission permission )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.savePermission( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource saveResource( Resource resource )
|
||||
throws RbacManagerException
|
||||
{
|
||||
return this.rbacImpl.saveResource( resource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Role saveRole( Role role )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -950,6 +1008,7 @@ public class LdapRbacManager
|
|||
//return new RoleImpl( role.getName(), role.getPermissions() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void saveRoles( Collection<Role> roles )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -981,6 +1040,7 @@ public class LdapRbacManager
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAssignment saveUserAssignment( UserAssignment userAssignment )
|
||||
throws RbacManagerException
|
||||
{
|
||||
|
@ -1045,6 +1105,7 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userAssignmentExists( String principal )
|
||||
{
|
||||
if ( userAssignmentsCache.hasKey( principal ) )
|
||||
|
@ -1084,6 +1145,7 @@ public class LdapRbacManager
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userAssignmentExists( UserAssignment assignment )
|
||||
{
|
||||
if ( assignment == null )
|
||||
|
@ -1145,76 +1207,91 @@ public class LdapRbacManager
|
|||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission( Permission permission )
|
||||
{
|
||||
this.permissions.add( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildRoleName( String name )
|
||||
{
|
||||
this.childRoleNames.add( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getChildRoleNames()
|
||||
{
|
||||
return this.childRoleNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return this.permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAssignable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( Permission permission )
|
||||
{
|
||||
this.permissions.remove( permission );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAssignable( boolean assignable )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildRoleNames( List<String> names )
|
||||
{
|
||||
this.childRoleNames = names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDescription( String description )
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermissions( List<Permission> permissions )
|
||||
{
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermanent( boolean permanent )
|
||||
{
|
||||
// no op
|
||||
|
@ -1282,16 +1359,19 @@ public class LdapRbacManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrincipal()
|
||||
{
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleNames()
|
||||
{
|
||||
return this.roleNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRoleName( Role role )
|
||||
{
|
||||
if ( role == null )
|
||||
|
@ -1301,6 +1381,7 @@ public class LdapRbacManager
|
|||
this.roleNames.add( role.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRoleName( String roleName )
|
||||
{
|
||||
if ( roleName == null )
|
||||
|
@ -1310,6 +1391,7 @@ public class LdapRbacManager
|
|||
this.roleNames.add( roleName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoleName( Role role )
|
||||
{
|
||||
if ( role == null )
|
||||
|
@ -1319,6 +1401,7 @@ public class LdapRbacManager
|
|||
this.roleNames.remove( role.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoleName( String roleName )
|
||||
{
|
||||
if ( roleName == null )
|
||||
|
@ -1328,21 +1411,25 @@ public class LdapRbacManager
|
|||
this.roleNames.remove( roleName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrincipal( String principal )
|
||||
{
|
||||
this.username = principal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoleNames( List<String> roles )
|
||||
{
|
||||
this.roleNames = roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return this.permanent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermanent( boolean permanent )
|
||||
{
|
||||
this.permanent = permanent;
|
||||
|
@ -1368,11 +1455,13 @@ public class LdapRbacManager
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionKey()
|
||||
{
|
||||
return "archiva.redback.rbacmanager.ldap";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly()
|
||||
{
|
||||
return !writableLdap;
|
||||
|
|
|
@ -167,7 +167,7 @@ public class DefaultRoleModelProcessor
|
|||
throw new RoleManagerException( "cycle detected: this should have been caught in validation", e );
|
||||
}
|
||||
|
||||
List<Role> allRoles;
|
||||
List<? extends Role> allRoles;
|
||||
try
|
||||
{
|
||||
allRoles = rbacManager.getAllRoles();
|
||||
|
@ -187,7 +187,7 @@ public class DefaultRoleModelProcessor
|
|||
{
|
||||
ModelRole roleProfile = RoleModelUtils.getModelRole( model, roleId );
|
||||
|
||||
List<Permission> permissions = processPermissions( roleProfile.getPermissions() );
|
||||
List<? extends Permission> permissions = processPermissions( roleProfile.getPermissions() );
|
||||
|
||||
boolean roleExists = allRoleNames.contains( roleProfile.getName() );// false;
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class DefaultRoleModelProcessor
|
|||
log.info( "time to process roles model: {} ms", stopWatch.getTime() );
|
||||
}
|
||||
|
||||
private List<Permission> processPermissions( List<ModelPermission> permissions )
|
||||
private List<? extends Permission> processPermissions( List<ModelPermission> permissions )
|
||||
throws RoleManagerException
|
||||
{
|
||||
List<Permission> rbacPermissions = new ArrayList<Permission>( permissions.size() );
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class AbstractRoleManagerTest
|
|||
throws Exception
|
||||
{
|
||||
|
||||
List<Resource> all = rbacManager.getAllResources();
|
||||
List<? extends Resource> all = rbacManager.getAllResources();
|
||||
|
||||
|
||||
assertTrue( rbacManager.resourceExists( "*" ) );
|
||||
|
|
|
@ -467,7 +467,7 @@ public abstract class AbstractRbacManagerTestCase
|
|||
|
||||
assertEquals( 1, manager.getAllUserAssignments().size() );
|
||||
|
||||
Set<Permission> assignedPermissions = manager.getAssignedPermissions( adminPrincipal );
|
||||
Set<? extends Permission> assignedPermissions = manager.getAssignedPermissions( adminPrincipal );
|
||||
|
||||
assertThat( assignedPermissions ).isNotNull().isNotEmpty().hasSize( 1 );
|
||||
|
||||
|
@ -689,7 +689,7 @@ public abstract class AbstractRbacManagerTestCase
|
|||
afterSetup();
|
||||
|
||||
// Get the List of Assigned Roles for user bob.
|
||||
Collection<Role> assignedRoles = manager.getAssignedRoles( username );
|
||||
Collection<? extends Role> assignedRoles = manager.getAssignedRoles( username );
|
||||
|
||||
assertThat( assignedRoles ).isNotNull().isNotEmpty().hasSize( 3 );
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ public abstract class AbstractRbacManagerTestCase
|
|||
assertThat( manager.getAllPermissions() ).isNotNull().isNotEmpty().hasSize( 3 );
|
||||
|
||||
// Get the List of Assigned Roles for user bob.
|
||||
Collection<Permission> assignedPermissions = manager.getAssignedPermissions( username );
|
||||
Collection<? extends Permission> assignedPermissions = manager.getAssignedPermissions( username );
|
||||
|
||||
assertThat( assignedPermissions ).isNotNull().isNotEmpty().hasSize( 1 );
|
||||
}
|
||||
|
@ -852,16 +852,16 @@ public abstract class AbstractRbacManagerTestCase
|
|||
rbacManager.saveUserAssignment( assignment );
|
||||
|
||||
assertEquals( incAssignements( 1 ), rbacManager.getAllUserAssignments().size() );
|
||||
List<Permission> permissions = rbacManager.getAllPermissions();
|
||||
List<? extends Permission> permissions = rbacManager.getAllPermissions();
|
||||
Assertions.assertThat( permissions ).isNotNull().isNotEmpty().hasSize( 6 );
|
||||
|
||||
List<Role> roles = rbacManager.getAllRoles();
|
||||
List<? extends Role> roles = rbacManager.getAllRoles();
|
||||
Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 4 );
|
||||
|
||||
afterSetup();
|
||||
|
||||
// Get the List of Assigned Roles for user bob.
|
||||
Collection<Permission> assignedPermissions = rbacManager.getAssignedPermissions( username );
|
||||
Collection<? extends Permission> assignedPermissions = rbacManager.getAssignedPermissions( username );
|
||||
|
||||
assertNotNull( assignedPermissions );
|
||||
assertEquals( 6, assignedPermissions.size() );
|
||||
|
|
Loading…
Reference in New Issue