public Set<String> listUserIds() { Set<String> userIds = new HashSet<String>(); List<CUserRoleMapping> userRoleMappings = this.configuration.listUserRoleMappings(); for ( CUserRoleMapping userRoleMapping : userRoleMappings ) { if ( SOURCE.equals( userRoleMapping.getSource() ) ) { String userId = userRoleMapping.getUserId(); if ( StringUtils.isNotEmpty( userId ) ) { userIds.add( userId ); } } } return userIds; }
protected void rebuildId2RoleMappingsLookupMap() { id2roleMappings.clear(); for ( CUserRoleMapping user2role : delegate.getUserRoleMappings() ) { id2roleMappings.put( getUserRoleMappingKey( user2role.getUserId(), user2role.getSource() ), user2role ); } }
public void removeUserRoleMapping( final CUserRoleMapping cUserRoleMapping ) { id2roleMappings.remove( getUserRoleMappingKey( cUserRoleMapping.getUserId(), cUserRoleMapping.getSource() ) ); delegate.removeUserRoleMapping( cUserRoleMapping ); }
for ( CUserRoleMapping roleMapping : roleMappings ) if ( !SOURCE.equals( roleMapping.getSource() ) ) if ( matchesCriteria( roleMapping.getUserId(), roleMapping.getSource(), roleMapping.getRoles(), criteria ) ) User user = getSecuritySystem().getUser( roleMapping.getUserId(), roleMapping.getSource() ); users.add( user ); + roleMapping.getSource() + "' could not be found.", e ); + roleMapping.getSource() + "' could not be found.", e );
public Set<User> listUsers() { Set<User> users = new HashSet<User>(); List<CUserRoleMapping> userRoleMappings = this.configuration.listUserRoleMappings(); for ( CUserRoleMapping userRoleMapping : userRoleMappings ) { try { User user = this.getSecuritySystem().getUser( userRoleMapping.getUserId(), userRoleMapping.getSource() ); if ( user != null ) { users.add( user ); } } catch ( UserNotFoundException e ) { this.logger.warn( "User: '" + userRoleMapping.getUserId() + "' of source: '" + userRoleMapping.getSource() + "' could not be found." ); this.logger.debug( "Most likely caused by a user role mapping that is invalid.", e ); } catch ( NoSuchUserManagerException e ) { this.logger.warn( "User: '" + userRoleMapping.getUserId() + "' of source: '" + userRoleMapping.getSource() + "' could not be found.", e ); } } return users; }
public void addUserRoleMapping( final CUserRoleMapping cUserRoleMapping ) { final CUserRoleMapping curm = cUserRoleMapping.clone(); delegate.addUserRoleMapping( curm ); id2roleMappings.put( getUserRoleMappingKey( curm.getUserId(), curm.getSource() ), curm ); }
private void createOrUpdateUserRoleMapping( CUserRoleMapping roleMapping ) { // delete first, ask questions later // we are always updating, its possible that this object could have already existed, because we cannot fully // sync with external realms. try { deleteUserRoleMapping( roleMapping.getUserId(), roleMapping.getSource() ); } catch ( NoSuchRoleMappingException e ) { // it didn't exist, thats ok. } // now add it getConfiguration().addUserRoleMapping( roleMapping ); }
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; }
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 ); } } } }
public void updateUserRoleMapping( CUserRoleMapping userRoleMapping, SecurityValidationContext context ) throws InvalidConfigurationException, NoSuchRoleMappingException { if ( context == null ) { context = initializeContext(); } if ( readUserRoleMapping( userRoleMapping.getUserId(), userRoleMapping.getSource() ) == null ) { ValidationResponse vr = new ValidationResponse(); vr.addValidationError( new ValidationMessage( "*", "No User Role Mapping found for user '" + userRoleMapping.getUserId() + "'." ) ); throw new InvalidConfigurationException( vr ); } ValidationResponse vr = validator.validateUserRoleMapping( context, userRoleMapping, true ); if ( vr.getValidationErrors().size() > 0 ) { throw new InvalidConfigurationException( vr ); } deleteUserRoleMapping( userRoleMapping.getUserId(), userRoleMapping.getSource() ); getConfiguration().addUserRoleMapping( userRoleMapping ); }
public void createUserRoleMapping( CUserRoleMapping userRoleMapping, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = this.initializeContext(); } try { // this will throw a NoSuchRoleMappingException, if there isn't one readUserRoleMapping( userRoleMapping.getUserId(), userRoleMapping.getSource() ); ValidationResponse vr = new ValidationResponse(); vr.addValidationError( new ValidationMessage( "*", "User Role Mapping for user '" + userRoleMapping.getUserId() + "' already exists." ) ); throw new InvalidConfigurationException( vr ); } catch ( NoSuchRoleMappingException e ) { // expected } ValidationResponse vr = validator.validateUserRoleMapping( context, userRoleMapping, false ); if ( vr.getValidationErrors().size() > 0 ) { throw new InvalidConfigurationException( vr ); } getConfiguration().addUserRoleMapping( userRoleMapping ); logValidationWarnings( vr ); }