public Operation getOperation( String operationName ) throws RbacObjectNotFoundException, RbacManagerException { triggerInit(); assertOpertionExists( operationName ); return operations.get( operationName ); }
public Permission getPermission( String permissionName ) throws RbacObjectNotFoundException, RbacManagerException { triggerInit(); assertPermissionExists( permissionName ); return permissions.get( permissionName ); }
public Resource getResource( String resourceIdentifier ) throws RbacObjectNotFoundException, RbacManagerException { triggerInit(); assertResourceExists( resourceIdentifier ); return resources.get( resourceIdentifier ); }
public Role getRole( String roleName ) throws RbacObjectNotFoundException { triggerInit(); assertRoleExists( roleName ); return roles.get( roleName ); }
public UserAssignment getUserAssignment( String principal ) throws RbacObjectNotFoundException, RbacManagerException { triggerInit(); assertUserAssignmentExists( principal ); return userAssignments.get( principal ); }
public Permission savePermission( Permission permission ) throws RbacManagerException { triggerInit(); RBACObjectAssertions.assertValid( "Save Permission", permission ); permissions.put( permission.getName(), permission ); fireRbacPermissionSaved( permission ); saveOperation( permission.getOperation() ); saveResource( permission.getResource() ); return permission; }
public Permission createPermission( String name, String operationName, String resourceIdentifier ) throws RbacManagerException { Permission permission; try { permission = getPermission( name ); if ( StringUtils.equals( operationName, permission.getOperation().getName() ) ) { throw new RbacManagerException( "Attempted to create a permission named '" + name + "' with an operation named '" + operationName + "', but that overides the existing '" + name + "' permission with operation '" + permission.getOperation().getName() + "'" ); } } catch ( RbacObjectNotFoundException e ) { permission = new MemoryPermission(); permission.setName( name ); permission.setOperation( createOperation( operationName ) ); permission.setResource( createResource( resourceIdentifier ) ); } return permission; }
public void removePermission( Permission permission ) throws RbacObjectNotFoundException, RbacManagerException { RBACObjectAssertions.assertValid( "Remove Permission", permission ); if ( permission.isPermanent() ) { throw new RbacPermanentException( "Unable to delete permanent permission [" + permission.getName() + "]" ); } assertPermissionExists( permission.getName() ); fireRbacPermissionRemoved( permission ); permissions.remove( permission.getName() ); }
public void removeRole( Role role ) throws RbacManagerException, RbacObjectNotFoundException { RBACObjectAssertions.assertValid( "Remove Role", role ); if ( role.isPermanent() ) { throw new RbacPermanentException( "Unable to delete permanent role [" + role.getName() + "]" ); } assertRoleExists( role.getName() ); fireRbacRoleRemoved( role ); roles.remove( role.getName() ); }
public void removeUserAssignment( UserAssignment userAssignment ) throws RbacObjectNotFoundException, RbacManagerException { RBACObjectAssertions.assertValid( "Remove User Assignment", userAssignment ); if ( userAssignment.isPermanent() ) { throw new RbacPermanentException( "Unable to delete permanent user assignment [" + userAssignment.getPrincipal() + "]" ); } fireRbacUserAssignmentRemoved( userAssignment ); assertUserAssignmentExists( userAssignment.getPrincipal() ); userAssignments.remove( userAssignment.getPrincipal() ); }
public void triggerInit() { if ( !hasTriggeredInit ) { fireRbacInit( roles.isEmpty() ); hasTriggeredInit = true; } }
public void removeOperation( Operation operation ) throws RbacObjectNotFoundException, RbacManagerException { RBACObjectAssertions.assertValid( "Remove Operation", operation ); if ( operation.isPermanent() ) { throw new RbacPermanentException( "Unable to delete permanent operation [" + operation.getName() + "]" ); } assertOpertionExists( operation.getName() ); operations.remove( operation.getName() ); }
public void removeResource( Resource resource ) throws RbacObjectNotFoundException, RbacManagerException { RBACObjectAssertions.assertValid( "Remove Resource", resource ); if ( resource.isPermanent() ) { throw new RbacPermanentException( "Unable to delete permanent resource [" + resource.getIdentifier() + "]" ); } assertResourceExists( resource.getIdentifier() ); resources.remove( resource.getIdentifier() ); }