private void processAdminCommand()

in src/main/java/org/apache/directory/fortress/core/cli/CommandLineInterpreter.java [480:691]


    private void processAdminCommand( Set<String> commands, Options options )
    {
        String command;
        try
        {
            if ( commands.contains( ADD_USER ) )
            {
                command = ADD_USER;
                LOG.info( command );
                User user = options.getUser();
                adminMgr.addUser( user );
            }
            else if ( commands.contains( UPDATE_USER ) )
            {
                command = UPDATE_USER;
                LOG.info( command );
                User user = options.getUser();
                adminMgr.updateUser( user );
            }
            else if ( commands.contains( DELETE_USER ) )
            {
                command = DELETE_USER;
                LOG.info( command );
                User user = options.getUser();
                adminMgr.deleteUser( user );
            }
            else if ( commands.contains( ADD_ROLE ) )
            {
                command = ADD_ROLE;
                LOG.info( command );
                Role role = options.getRole();
                adminMgr.addRole( role );
            }
            else if ( commands.contains( UPDATE_ROLE ) )
            {
                command = UPDATE_ROLE;
                LOG.info( command );
                Role role = options.getRole();
                adminMgr.updateRole( role );
            }
            else if ( commands.contains( DELETE_ROLE ) )
            {
                command = DELETE_ROLE;
                LOG.info( command );
                Role role = options.getRole();
                adminMgr.deleteRole( role );
            }
            else if ( commands.contains( ASSIGN_ROLE ) )
            {
                command = ASSIGN_ROLE;
                LOG.info( command );
                Role role = options.getRole();
                String userId = options.getUserId();
                adminMgr.assignUser( new UserRole( userId, role ) );
            }
            else if ( commands.contains( DEASSIGN_ROLE ) )
            {
                command = DEASSIGN_ROLE;
                LOG.info( command );
                Role role = options.getRole();
                String userId = options.getUserId();
                adminMgr.deassignUser( new UserRole( userId, role ) );
            }
            else if ( commands.contains( ADD_ROLE_INHERITANCE ) )
            {
                command = ADD_ROLE_INHERITANCE;
                LOG.info( command );
                Relationship relationship = options.getRelationship();
                adminMgr.addInheritance( new Role( relationship.getParent() ), new Role( relationship.getChild() ) );
            }
            else if ( commands.contains( DELETE_ROLE_INHERITANCE ) )
            {
                command = DELETE_ROLE_INHERITANCE;
                LOG.info( command );
                Relationship relationship = options.getRelationship();
                adminMgr.deleteInheritance( new Role( relationship.getParent() ), new Role( relationship.getChild() ) );
            }
            else if ( commands.contains( ADD_POBJ ) )
            {
                command = ADD_POBJ;
                LOG.info( command );
                PermObj permObj = options.getPermObj();
                adminMgr.addPermObj( permObj );
            }
            else if ( commands.contains( UPDATE_POBJ ) )
            {
                command = UPDATE_POBJ;
                LOG.info( command );
                PermObj permObj = options.getPermObj();
                adminMgr.updatePermObj( permObj );
            }
            else if ( commands.contains( DELETE_POBJ ) )
            {
                command = DELETE_POBJ;
                LOG.info( command );
                PermObj permObj = options.getPermObj();
                adminMgr.deletePermObj( permObj );
            }
            else if ( commands.contains( ADD_PERM ) )
            {
                command = ADD_PERM;
                LOG.info( command );
                Permission perm = options.getPermission();
                adminMgr.addPermission( perm );
            }
            else if ( commands.contains( UPDATE_PERM ) )
            {
                command = UPDATE_PERM;
                LOG.info( command );
                Permission perm = options.getPermission();
                adminMgr.updatePermission( perm );
            }
            else if ( commands.contains( DELETE_PERM ) )
            {
                command = DELETE_PERM;
                LOG.info( command );
                Permission permObj = options.getPermission();
                adminMgr.deletePermission( permObj );
            }
            else if ( commands.contains( GRANT ) )
            {
                command = GRANT;
                LOG.info( command );
                Permission perm = options.getPermission();
                Role role = options.getRole();
                role.setName( options.getRoleNm() );
                adminMgr.grantPermission( perm, role );
            }
            else if ( commands.contains( REVOKE ) )
            {
                command = REVOKE;
                LOG.info( command );
                Permission perm = options.getPermission();
                Role role = options.getRole();
                role.setName( options.getRoleNm() );
                adminMgr.revokePermission( perm, role );
            }
            else if ( commands.contains( CREATE_SSD_SET ) )
            {
                command = CREATE_SSD_SET;
                LOG.info( command );
                SDSet ssd = options.getSdSet();
                ssd.setType( SDSet.SDType.STATIC );
                adminMgr.createSsdSet( ssd );
            }
            else if ( commands.contains( DELETE_SSD_SET ) )
            {
                command = DELETE_SSD_SET;
                LOG.info( command );
                SDSet ssd = options.getSdSet();
                ssd.setType( SDSet.SDType.STATIC );
                adminMgr.deleteSsdSet( ssd );
            }
            else if ( commands.contains( CREATE_DSD_SET ) )
            {
                command = CREATE_DSD_SET;
                LOG.info( command );
                SDSet ssd = options.getSdSet();
                ssd.setType( SDSet.SDType.DYNAMIC );
                adminMgr.createDsdSet( ssd );
            }
            else if ( commands.contains( DELETE_DSD_SET ) )
            {
                command = DELETE_DSD_SET;
                LOG.info( command );
                SDSet ssd = options.getSdSet();
                ssd.setType( SDSet.SDType.DYNAMIC );
                adminMgr.deleteDsdSet( ssd );
            }
            else if ( commands.contains( CHANGE_PASSWORD ) )
            {
                command = CHANGE_PASSWORD;
                LOG.info( command );
                User user = options.getUser();
                String newPassword = options.getNewPassword();
                adminMgr.changePassword( user, newPassword );
            }
            else if ( commands.contains( RESET_PASSWORD ) )
            {
                command = RESET_PASSWORD;
                LOG.info( command );
                User user = options.getUser();
                String newPassword = options.getNewPassword();
                adminMgr.resetPassword( user, newPassword );
            }
            else if ( commands.contains( LOCK_USER_ACCOUNT ) )
            {
                command = LOCK_USER_ACCOUNT;
                LOG.info( command );
                User user = options.getUser();
                adminMgr.lockUserAccount( user );
            }
            else if ( commands.contains( UNLOCK_USER_ACCOUNT ) )
            {
                command = UNLOCK_USER_ACCOUNT;
                LOG.info( command );
                User user = options.getUser();
                adminMgr.unlockUserAccount( user );
            }
            else
            {
                LOG.warn( "unknown admin operation detected" );
                return;
            }
            LOG.info( "command:{} was successful", command );
        }
        catch ( SecurityException se )
        {
            String error = "processAdminCommand caught SecurityException=" + se + ", return code=" + se.getErrorId();
            LOG.error( error );
        }
    }