Search in sources :

Example 1 with ChangeScepEntry

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

the class ScepUpdateCmd 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;
    }
    ChangeScepEntry entry = new ChangeScepEntry(name);
    if (realActive != null) {
        entry.setActive(realActive);
    }
    if (caName != null) {
        entry.setCa(new NameId(null, caName));
    }
    if (responderName != null) {
        entry.setResponderName(responderName);
    }
    if (CollectionUtil.isNonEmpty(profiles)) {
        if (profiles.contains("NONE")) {
            profiles.clear();
        }
    }
    if (control != null) {
        entry.setControl(control);
    }
    String msg = "SCEP responder " + name;
    try {
        caManager.changeScep(entry);
        println("updated " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : ChangeScepEntry(org.xipki.ca.server.mgmt.api.x509.ChangeScepEntry) 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)

Aggregations

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