Search in sources :

Example 41 with NameId

use of org.xipki.ca.api.NameId 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)

Example 42 with NameId

use of org.xipki.ca.api.NameId in project xipki by xipki.

the class PublisherAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (conf == null && confFile != null) {
        conf = new String(IoUtil.read(confFile));
    }
    PublisherEntry entry = new PublisherEntry(new NameId(null, name), type, conf);
    String msg = "publisher " + name;
    try {
        caManager.addPublisher(entry);
        println("added " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) PublisherEntry(org.xipki.ca.server.mgmt.api.PublisherEntry) NameId(org.xipki.ca.api.NameId) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 43 with NameId

use of org.xipki.ca.api.NameId in project xipki by xipki.

the class RequestorAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String base64Cert = IoUtil.base64Encode(IoUtil.read(certFile), false);
    RequestorEntry entry = new RequestorEntry(new NameId(null, name), base64Cert);
    String msg = "CMP requestor " + name;
    if (entry.getCert() == null) {
        throw new CmdFailure("could not add " + msg + ", error: could not get requestor certificate");
    }
    try {
        caManager.addRequestor(entry);
        println("added " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not add " + 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) RequestorEntry(org.xipki.ca.server.mgmt.api.RequestorEntry)

Aggregations

NameId (org.xipki.ca.api.NameId)43 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)31 PreparedStatement (java.sql.PreparedStatement)12 SQLException (java.sql.SQLException)12 ResultSet (java.sql.ResultSet)9 OperationException (org.xipki.ca.api.OperationException)9 CmdFailure (org.xipki.console.karaf.CmdFailure)9 BigInteger (java.math.BigInteger)8 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)6 CaHasRequestorEntry (org.xipki.ca.server.mgmt.api.CaHasRequestorEntry)6 X509Certificate (java.security.cert.X509Certificate)5 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)5 CaHasUserEntry (org.xipki.ca.server.mgmt.api.CaHasUserEntry)5 X509CaEntry (org.xipki.ca.server.mgmt.api.x509.X509CaEntry)5 Date (java.util.Date)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 CaStatus (org.xipki.ca.server.mgmt.api.CaStatus)4 X509CaUris (org.xipki.ca.server.mgmt.api.x509.X509CaUris)4 ConfPairs (org.xipki.common.ConfPairs)4 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)4