public void updateUser( CUser user ) throws InvalidConfigurationException, UserNotFoundException { Set<String> roles = Sets.newHashSet(); try { CUserRoleMapping userRoleMapping = this.readUserRoleMapping( user.getId(), SecurityXmlUserManager.SOURCE ); roles.addAll( userRoleMapping.getRoles() ); } catch ( NoSuchRoleMappingException e ) { this.logger.debug( "User: {} has no roles", user.getId()); } this.updateUser( user, new HashSet<String>( roles ) ); }
public void updateUser( CUser user ) throws InvalidConfigurationException, UserNotFoundException { Set<String> roles = new HashSet<String>(); try { CUserRoleMapping userRoleMapping = this.readUserRoleMapping( user.getId(), SecurityXmlUserManager.SOURCE ); roles.addAll( userRoleMapping.getRoles() ); } catch ( NoSuchRoleMappingException e ) { this.logger.debug( "User: {} has no roles", user.getId()); } this.updateUser(user, new HashSet<String>( roles )); }
public void run() throws Exception { CUserRoleMapping roleMapping; try { roleMapping = configuration.readUserRoleMapping( userId, source ); if ( roleMapping != null ) { for ( String roleId : (List<String>) roleMapping.getRoles() ) { RoleIdentifier role = toRole( roleId ); if ( role != null ) { roles.add( role ); } } } } catch ( NoSuchRoleMappingException e ) { logger.debug( "No user role mapping found for user: " + userId ); } } });
if (userRoleMappings != null && userRoleMappings.size() > 0) { for (final CUserRoleMapping userRoleMapping : userRoleMappings) { final List<String> userRoleMappingRoles = userRoleMapping.getRoles(); if (userRoleMappingRoles != null && userRoleMappingRoles.size() > 0) { final List<String> newRoles = Lists.newArrayList(); userRoleMapping.getRoles().clear(); userRoleMapping.getRoles().addAll(newRoles);
public Set<User> listUsers() { Set<User> users = new HashSet<User>(); List<CUserRoleMapping> userRoleMappings = this.configuration.listUserRoleMappings(); for ( CUserRoleMapping userRoleMapping : userRoleMappings ) { if ( SOURCE.equals( userRoleMapping.getSource() ) ) { User user = null; if ( userRoleMapping.getRoles().contains( this.urlRealmConfiguration.getConfiguration().getDefaultRole() ) ) { user = this.toUser( userRoleMapping.getUserId(), false ); } else { user = this.toUser( userRoleMapping.getUserId(), true ); } if ( user != null ) { users.add( user ); } } } return users; }
@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 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 ); } } } }
if ( matchesCriteria( roleMapping.getUserId(), roleMapping.getSource(), roleMapping.getRoles(), criteria ) )
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; }