Search in sources :

Example 1 with ChangeUserEntry

use of org.xipki.ca.server.mgmt.api.ChangeUserEntry in project xipki by xipki.

the class UserUpdateCmd method execute0.

@Override
protected Object execute0() throws Exception {
    Boolean realActive;
    if (active != null) {
        if (inactive != null) {
            throw new IllegalCmdParamException("maximal one of --active and --inactive can be set");
        }
        realActive = Boolean.TRUE;
    } else if (inactive != null) {
        realActive = Boolean.FALSE;
    } else {
        realActive = null;
    }
    ChangeUserEntry entry = new ChangeUserEntry(new NameId(null, name));
    if (realActive != null) {
        entry.setActive(realActive);
    }
    if ("CONSOLE".equalsIgnoreCase(password)) {
        password = new String(readPassword());
    }
    if (password != null) {
        entry.setPassword(password);
    }
    String msg = "user " + name;
    try {
        caManager.changeUser(entry);
        println("changed " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not change " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) NameId(org.xipki.ca.api.NameId) CmdFailure(org.xipki.console.karaf.CmdFailure) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) ChangeUserEntry(org.xipki.ca.server.mgmt.api.ChangeUserEntry)

Aggregations

NameId (org.xipki.ca.api.NameId)1 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)1 ChangeUserEntry (org.xipki.ca.server.mgmt.api.ChangeUserEntry)1 CmdFailure (org.xipki.console.karaf.CmdFailure)1 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)1