Search in sources :

Example 76 with CaMgmtException

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

the class ProfileRemoveCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String msg = "certificate profile " + name;
    try {
        caManager.removeCertprofile(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 77 with CaMgmtException

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

the class ResponderAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    String base64Cert = null;
    X509Certificate signerCert = null;
    if (certFile != null) {
        signerCert = X509Util.parseCert(certFile);
        base64Cert = IoUtil.base64Encode(signerCert.getEncoded(), false);
    }
    if ("PKCS12".equalsIgnoreCase(signerType) || "JKS".equalsIgnoreCase(signerType)) {
        signerConf = ShellUtil.canonicalizeSignerConf(signerType, signerConf, passwordResolver, securityFactory);
    }
    ResponderEntry entry = new ResponderEntry(name, signerType, signerConf, base64Cert);
    String msg = "CMP responder " + name;
    try {
        caManager.addResponder(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) CmdFailure(org.xipki.console.karaf.CmdFailure) ResponderEntry(org.xipki.ca.server.mgmt.api.ResponderEntry) X509Certificate(java.security.cert.X509Certificate)

Example 78 with CaMgmtException

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

the class ScepAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    ScepEntry entry = new ScepEntry(name, new NameId(null, caName), !inactive, responderName, profiles, scepControl);
    String msg = "SCEP " + name;
    try {
        caManager.addScep(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) ScepEntry(org.xipki.ca.server.mgmt.api.x509.ScepEntry)

Example 79 with CaMgmtException

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

the class CaManagerImpl method getCurrentCrl.

// method getCrl
@Override
public X509CRL getCurrentCrl(String caName) throws CaMgmtException {
    caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
    X509Ca ca = getX509Ca(caName);
    try {
        X509CRL crl = ca.getCurrentCrl();
        if (crl == null) {
            LOG.warn("found no CRL for CA {}", caName);
        }
        return crl;
    } catch (OperationException ex) {
        throw new CaMgmtException(ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) X509CRL(java.security.cert.X509CRL) OperationException(org.xipki.ca.api.OperationException)

Example 80 with CaMgmtException

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

the class CaManagerImpl method addCa.

@Override
public void addCa(CaEntry caEntry) throws CaMgmtException {
    ParamUtil.requireNonNull("caEntry", caEntry);
    asssertMasterMode();
    NameId ident = caEntry.getIdent();
    String name = ident.getName();
    if (caInfos.containsKey(name)) {
        throw new CaMgmtException(concat("CA named ", name, " exists"));
    }
    String origSignerConf = caEntry.getSignerConf();
    String newSignerConf = canonicalizeSignerConf(caEntry.getSignerType(), origSignerConf, null, securityFactory);
    if (!origSignerConf.equals(newSignerConf)) {
        caEntry.setSignerConf(newSignerConf);
    }
    if (caEntry instanceof X509CaEntry) {
        try {
            X509CaEntry tmpCaEntry = (X509CaEntry) caEntry;
            List<String[]> signerConfs = CaEntry.splitCaSignerConfs(tmpCaEntry.getSignerConf());
            ConcurrentContentSigner signer;
            for (String[] m : signerConfs) {
                SignerConf signerConf = new SignerConf(m[1]);
                signer = securityFactory.createSigner(tmpCaEntry.getSignerType(), signerConf, tmpCaEntry.getCert());
                if (tmpCaEntry.getCert() == null) {
                    if (signer.getCertificate() == null) {
                        throw new CaMgmtException("CA signer without certificate is not allowed");
                    }
                    tmpCaEntry.setCert(signer.getCertificate());
                }
            }
        } catch (XiSecurityException | ObjectCreationException ex) {
            throw new CaMgmtException(concat("could not create signer for new CA ", name, ": ", ex.getMessage()), ex);
        }
    }
    queryExecutor.addCa(caEntry);
    if (!createCa(name)) {
        LOG.error("could not create CA {}", name);
    } else {
        if (startCa(name)) {
            LOG.info("started CA {}", name);
        } else {
            LOG.error("could not start CA {}", name);
        }
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) ConcurrentContentSigner(org.xipki.security.ConcurrentContentSigner) XiSecurityException(org.xipki.security.exception.XiSecurityException) NameId(org.xipki.ca.api.NameId) ObjectCreationException(org.xipki.common.ObjectCreationException) SignerConf(org.xipki.security.SignerConf) X509CaEntry(org.xipki.ca.server.mgmt.api.x509.X509CaEntry)

Aggregations

CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)157 PreparedStatement (java.sql.PreparedStatement)63 SQLException (java.sql.SQLException)63 CmdFailure (org.xipki.console.karaf.CmdFailure)52 NameId (org.xipki.ca.api.NameId)31 ResultSet (java.sql.ResultSet)24 OperationException (org.xipki.ca.api.OperationException)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 InvalidConfException (org.xipki.common.InvalidConfException)11 DataAccessException (org.xipki.datasource.DataAccessException)11 CertificateEncodingException (java.security.cert.CertificateEncodingException)9 CaHasRequestorEntry (org.xipki.ca.server.mgmt.api.CaHasRequestorEntry)9 CertificateException (java.security.cert.CertificateException)8 ObjectCreationException (org.xipki.common.ObjectCreationException)8 X509Certificate (java.security.cert.X509Certificate)7 Date (java.util.Date)7 X509CaEntry (org.xipki.ca.server.mgmt.api.x509.X509CaEntry)7 IOException (java.io.IOException)6 Statement (java.sql.Statement)6 CaHasUserEntry (org.xipki.ca.server.mgmt.api.CaHasUserEntry)6