public void createUser( CUser user, Set<String> roles, SecurityValidationContext context ) throws InvalidConfigurationException { createUser( user, null, roles, context ); }
public void createUser( CUser user, String password, Set<String> roles ) throws InvalidConfigurationException { manager.createUser( user, password, roles, initializeContext() ); }
public void updateUserRoleMapping( CUserRoleMapping userRoleMapping ) throws InvalidConfigurationException, NoSuchRoleMappingException { updateUserRoleMapping( userRoleMapping, initializeContext() ); }
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; }
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 List<CPrivilege> listPrivileges() { List<CPrivilege> list = new ArrayList<CPrivilege>( manager.listPrivileges() ); for ( CPrivilege item : (List<CPrivilege>) getConfiguration().getPrivileges() ) { // ALL privileges that come from StaticSecurityResources are NOT editable // only roles defined in the security.xml can be updated. item.setReadOnly( true ); list.add( item ); } return list; }
protected Configuration doGetConfiguration() { final Configuration configuration = new Configuration(); for ( StaticSecurityResource resource : staticResources ) { Configuration resConfig = resource.getConfiguration(); if ( resConfig != null ) { appendConfig( configuration, resConfig ); } } for ( DynamicSecurityResource resource : dynamicResources ) { Configuration resConfig = resource.getConfiguration(); if ( resConfig != null ) { appendConfig( configuration, resConfig ); } } return configuration; }
if ( eachRole != null ) role = this.mergeRolesContents( role, eachRole ); configuration.removeRole( eachRole );
public List<CRole> listRoles() { List<CRole> list = new ArrayList<CRole>( manager.listRoles() ); for ( CRole item : (List<CRole>) getConfiguration().getRoles() ) { CRole role = item; // ALL roles that come from StaticSecurityResources are NOT editable // only roles defined in the security.xml can be updated. item.setReadOnly( true ); list.add( role ); } return list; }
public void createUserRoleMapping( CUserRoleMapping userRoleMapping, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = this.initializeContext(); } manager.createUserRoleMapping( userRoleMapping, context ); }
public CRole readRole( String id ) throws NoSuchRoleException { final CRole role = getConfiguration().getRoleById( id ); if ( role != null ) { role.setReadOnly( true ); return role; } else { // nothing found in static, try the original source, will throw if nothing is found return manager.readRole( id ); } }
public void updatePrivilege( CPrivilege privilege ) throws InvalidConfigurationException, NoSuchPrivilegeException { manager.updatePrivilege( privilege, initializeContext() ); }
public CPrivilege readPrivilege( String id ) throws NoSuchPrivilegeException { final CPrivilege privilege = getConfiguration().getPrivilegeById( id ); if ( privilege != null ) { privilege.setReadOnly( true ); return privilege; } else { return manager.readPrivilege( id ); } }
public void updateRole( CRole role ) throws InvalidConfigurationException, NoSuchRoleException { manager.updateRole( role, initializeContext() ); }
public void updateRole( CRole role, SecurityValidationContext context ) throws InvalidConfigurationException, NoSuchRoleException { if ( context == null ) { context = initializeContext(); } // The static config can't be updated, so delegate to xml file manager.updateRole( role, context ); }
public void createPrivilege( CPrivilege privilege ) throws InvalidConfigurationException { manager.createPrivilege( privilege, initializeContext() ); }
public void createRole( CRole role ) throws InvalidConfigurationException { manager.createRole( role, initializeContext() ); }
public void createRole( CRole role, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = initializeContext(); } // The static config can't be updated, so delegate to xml file manager.createRole( role, context ); }
public void createUser( CUser user, Set<String> roles ) throws InvalidConfigurationException { manager.createUser( user, roles, initializeContext() ); }
public void createUserRoleMapping( CUserRoleMapping userRoleMapping ) throws InvalidConfigurationException { manager.createUserRoleMapping( userRoleMapping, initializeContext() ); }