Search in sources :

Example 11 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class UserAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (password == null) {
        password = new String(readPassword());
    }
    AddUserEntry userEntry = new AddUserEntry(new NameId(null, name), !inactive, password);
    String msg = "user " + name;
    try {
        caManager.addUser(userEntry);
        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) AddUserEntry(org.xipki.ca.server.mgmt.api.AddUserEntry)

Example 12 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class UserRemoveCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String msg = "user " + name;
    try {
        caManager.removeUser(name);
        println("removed " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 13 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class EnrollCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    CaEntry ca = caManager.getCa(caName);
    if (ca == null) {
        throw new CmdFailure("CA " + caName + " not available");
    }
    Date notBefore = StringUtil.isNotBlank(notBeforeS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(notBeforeS) : null;
    Date notAfter = StringUtil.isNotBlank(notAfterS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(notAfterS) : null;
    byte[] encodedCsr = IoUtil.read(csrFile);
    X509Certificate cert = caManager.generateCertificate(caName, profileName, encodedCsr, notBefore, notAfter);
    saveVerbose("saved certificate to file", new File(outFile), cert.getEncoded());
    return null;
}
Also used : CaEntry(org.xipki.ca.server.mgmt.api.CaEntry) CmdFailure(org.xipki.console.karaf.CmdFailure) File(java.io.File) Date(java.util.Date) X509Certificate(java.security.cert.X509Certificate)

Example 14 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class CaSystemUnlockCmd method execute0.

@Override
protected Object execute0() throws Exception {
    try {
        caManager.unlockCa();
        println("unlocked CA system, calling ca:restart to restart CA system");
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not unlock CA system, error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 15 with CmdFailure

use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.

the class CaUpdateCmd method execute0.

// method getChangeCaEntry
@Override
protected Object execute0() throws Exception {
    String msg = "CA " + caName;
    try {
        caManager.changeCa(getChangeCaEntry());
        println("updated " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmdFailure(org.xipki.console.karaf.CmdFailure)

Aggregations

CmdFailure (org.xipki.console.karaf.CmdFailure)99 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)52 File (java.io.File)20 X509Certificate (java.security.cert.X509Certificate)20 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)15 BigInteger (java.math.BigInteger)9 NameId (org.xipki.ca.api.NameId)9 X509CRL (java.security.cert.X509CRL)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 CaEntry (org.xipki.ca.server.mgmt.api.CaEntry)6 RequestResponseDebug (org.xipki.common.RequestResponseDebug)6 PublisherEntry (org.xipki.ca.server.mgmt.api.PublisherEntry)5 ScepClient (org.xipki.scep.client.ScepClient)4 DEROctetString (org.bouncycastle.asn1.DEROctetString)3 CertificationRequest (org.bouncycastle.asn1.pkcs.CertificationRequest)3 X500Name (org.bouncycastle.asn1.x500.X500Name)3 Client (org.jscep.client.Client)3 CertprofileEntry (org.xipki.ca.server.mgmt.api.CertprofileEntry)3 X509CrlSignerEntry (org.xipki.ca.server.mgmt.api.x509.X509CrlSignerEntry)3