rolesToProcess.addAll( role.getRoles() );
public void roleRemoved( EnhancedConfiguration configuration, String roleId ) { logger.debug( "Cleaning role id {} from users and roles.", roleId ); List<CRole> roles = configuration.getRoles(); for ( CRole role : roles ) { if ( role.getRoles().contains( roleId ) ) { logger.debug( "removing ref to role {} from role {}", roleId, role.getId() ); role.getRoles().remove( roleId ); configuration.removeRoleById( role.getId() ); configuration.addRole( role ); } } List<CUserRoleMapping> mappings = configuration.getUserRoleMappings(); for ( CUserRoleMapping mapping : mappings ) { if ( mapping.getRoles().contains( roleId ) ) { logger.debug( "removing ref to role {} from user {}", mapping.getUserId() ); mapping.removeRole( roleId ); configuration.removeUserRoleMappingByUserId( mapping.getUserId(), mapping.getSource() ); configuration.addUserRoleMapping( mapping ); } } } }
@Override public void doUpgrade( Configuration cfg ) throws ConfigurationIsCorruptedException { for ( CRole role : cfg.getRoles() ) { updateDeprecatedRoles( role.getRoles() ); } for ( CUserRoleMapping map : cfg.getUserRoleMappings() ) { updateDeprecatedRoles( map.getRoles() ); } }
public SecurityValidationContext initializeContext() { SecurityValidationContext context = new SecurityValidationContext(); context.addExistingUserIds(); context.addExistingRoleIds(); context.addExistingPrivilegeIds(); List<CUser> users = new ArrayList<CUser>( listUsers() ); for ( CUser user : users ) { context.getExistingUserIds().add( user.getId() ); context.getExistingEmailMap().put( user.getId(), user.getEmail() ); } List<CRole> roles = new ArrayList<CRole>( listRoles() ); for ( CRole role : roles ) { context.getExistingRoleIds().add( role.getId() ); ArrayList<String> containedRoles = new ArrayList<String>(); containedRoles.addAll( role.getRoles() ); context.getRoleContainmentMap().put( role.getId(), containedRoles ); context.getExistingRoleNameMap().put( role.getId(), role.getName() ); } List<CPrivilege> privs = new ArrayList<CPrivilege>( listPrivileges() ); for ( CPrivilege priv : privs ) { context.getExistingPrivilegeIds().add( priv.getId() ); } return context; }
protected Role toRole( CRole secRole ) { Role role = new Role(); role.setRoleId( secRole.getId() ); role.setName( secRole.getName() ); role.setSource( SOURCE ); role.setDescription( secRole.getDescription() ); role.setReadOnly( secRole.isReadOnly() ); role.setPrivileges( new HashSet<String>( secRole.getPrivileges() ) ); role.setRoles( new HashSet<String>( secRole.getRoles() ) ); return role; }
private void addStaticSecurity(Configuration configuration, Configuration staticConfiguration) { for (CPrivilege priv : staticConfiguration.getPrivileges()) { CPrivilege p = getPrivilege(priv.getId(), configuration.getPrivileges()); if (p == null) { configuration.addPrivilege(priv); } } for (CRole role : staticConfiguration.getRoles()) { CRole existingRole = getRole(role.getId(), configuration.getRoles()); if (existingRole != null) { for (String containedRole : role.getRoles()) { if (!existingRole.getRoles().contains(containedRole)) { existingRole.addRole(containedRole); } } for (String containedPriv : role.getPrivileges()) { if (!existingRole.getPrivileges().contains(containedPriv)) { existingRole.addPrivilege(containedPriv); } } } else { configuration.addRole(role); } } }
public SecurityValidationContext initializeContext() { SecurityValidationContext context = new SecurityValidationContext(); context.addExistingUserIds(); context.addExistingRoleIds(); context.addExistingPrivilegeIds(); for ( CUser user : listUsers() ) { context.getExistingUserIds().add( user.getId() ); context.getExistingEmailMap().put( user.getId(), user.getEmail() ); } for ( CRole role : listRoles() ) { context.getExistingRoleIds().add( role.getId() ); ArrayList<String> containedRoles = new ArrayList<String>(); containedRoles.addAll( role.getRoles() ); context.getRoleContainmentMap().put( role.getId(), containedRoles ); context.getExistingRoleNameMap().put( role.getId(), role.getName() ); } for ( CPrivilege priv : listPrivileges() ) { context.getExistingPrivilegeIds().add( priv.getId() ); } for ( CUserRoleMapping roleMappings : listUserRoleMappings() ) { context.getExistingUserRoleMap().put( roleMappings.getUserId(), roleMappings.getRoles() ); } return context; }
public static CRole toCRole(RoleResource resource) { CRole role = new CRole(); role.setId(resource.getId()); role.setDescription(resource.getDescription()); role.setName(resource.getName()); role.setSessionTimeout(resource.getSessionTimeout()); 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; } }