public void validateRoleContainment( Role role ) throws ResourceException { if ( role.getRoles().size() == 0 && role.getPrivileges().size() == 0 ) { throw new PlexusResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", getErrorResponse( "privileges", "One or more roles/privilegs are required." ) ); } }
public void validateRoleContainment(Role role) throws ResourceException { if (role.getRoles().size() == 0 && role.getPrivileges().size() == 0) { throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", getErrorResponse("privileges", "One or more roles/privilegs are required.")); } }
protected void handleRole(Role role, List<Role> parentList, AuthorizationManager authzManager, AssignedPrivilegeListResourceResponse response) { List<Role> newParentList = new ArrayList<Role>(); if (parentList != null) { newParentList.addAll(parentList); } newParentList.add(0, role); for (String roleId : role.getRoles()) { try { handleRole(authzManager.getRole(roleId), newParentList, authzManager, response); } catch (NoSuchRoleException e) { getLogger().debug("handleRole() failed, roleId: " + roleId + " not found"); } } for (String privilegeId : role.getPrivileges()) { try { handlePrivilege(authzManager.getPrivilege(privilegeId), newParentList, response); } catch (NoSuchPrivilegeException e) { getLogger().debug("handleRole() failed, privilegeId: " + privilegeId + " not found"); } } }
for ( String privilegeId : role.getPrivileges() )
protected CRole toRole( Role role ) { CRole secRole = new CRole(); secRole.setId( role.getRoleId() ); secRole.setName( role.getName() ); secRole.setDescription( role.getDescription() ); secRole.setReadOnly( role.isReadOnly() ); // null check if ( role.getPrivileges() != null ) { secRole.setPrivileges( new ArrayList<String>( role.getPrivileges() ) ); } else { secRole.setPrivileges( new ArrayList<String>() ); } // null check if ( role.getRoles() != null ) { secRole.setRoles( new ArrayList<String>( role.getRoles() ) ); } else { secRole.setRoles( new ArrayList<String>() ); } return secRole; }
public Role restToSecurityModel(Role role, RoleResource resource) { if (role == null) { role = new Role(); } role.setRoleId(resource.getId()); role.setDescription(resource.getDescription()); role.setName(resource.getName()); role.getRoles().clear(); for (String roleId : (List<String>) resource.getRoles()) { role.addRole(roleId); } role.getPrivileges().clear(); for (String privId : (List<String>) resource.getPrivileges()) { role.addPrivilege(privId); } return role; }
public Role restToSecurityModel( Role role, RoleResource resource ) { if ( role == null ) { role = new Role(); } role.setRoleId( resource.getId() ); role.setDescription( resource.getDescription() ); role.setName( resource.getName() ); role.getRoles().clear(); for ( String roleId : (List<String>) resource.getRoles() ) { role.addRole( roleId ); } role.getPrivileges().clear(); for ( String privId : (List<String>) resource.getPrivileges() ) { role.addPrivilege( privId ); } return role; }
for (String privilegeId : role.getPrivileges()) { try { Privilege childPrivilege = authzManager.getPrivilege(privilegeId);
for ( String privilegeId : role.getPrivileges() )
public RoleResource securityToRestModel(Role role, Request request, boolean appendResourceId) { // and will convert to the rest object RoleResource resource = new RoleResource(); resource.setDescription(role.getDescription()); resource.setId(role.getRoleId()); resource.setName(role.getName()); String resourceId = ""; if (appendResourceId) { resourceId = resource.getId(); } resource.setResourceURI(this.createChildReference(request, resourceId).toString()); resource.setUserManaged(!role.isReadOnly()); for (String roleId : role.getRoles()) { resource.addRole(roleId); } for (String privId : role.getPrivileges()) { resource.addPrivilege(privId); } return resource; }
public RoleResource securityToRestModel( Role role, Request request, boolean appendResourceId ) { // and will convert to the rest object RoleResource resource = new RoleResource(); resource.setDescription( role.getDescription() ); resource.setId( role.getRoleId() ); resource.setName( role.getName() ); String resourceId = ""; if ( appendResourceId ) { resourceId = resource.getId(); } resource.setResourceURI( this.createChildReference( request, resourceId ).toString() ); resource.setUserManaged( !role.isReadOnly() ); for ( String roleId : role.getRoles() ) { resource.addRole( roleId ); } for ( String privId : role.getPrivileges() ) { resource.addPrivilege( privId ); } return resource; }