Search in sources :

Example 16 with NameId

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

the class CaRequestorAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    boolean ra = isEnabled(raS, false, "ra");
    CaHasRequestorEntry entry = new CaHasRequestorEntry(new NameId(null, requestorName));
    entry.setRa(ra);
    entry.setProfiles(profiles);
    int intPermission = ShellUtil.getPermission(permissions);
    entry.setPermission(intPermission);
    String msg = "requestor " + requestorName + " to CA " + caName;
    try {
        caManager.addRequestorToCa(entry, caName);
        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) CaHasRequestorEntry(org.xipki.ca.server.mgmt.api.CaHasRequestorEntry)

Example 17 with NameId

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

the class CaUserAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    CaHasUserEntry entry = new CaHasUserEntry(new NameId(null, userName));
    entry.setProfiles(profiles);
    int intPermission = ShellUtil.getPermission(permissions);
    entry.setPermission(intPermission);
    String msg = "user " + userName + " to CA " + caName;
    try {
        caManager.addUserToCa(entry, caName);
        println("added " + msg);
        return null;
    } catch (CaMgmtException ex) {
        throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
    }
}
Also used : CaHasUserEntry(org.xipki.ca.server.mgmt.api.CaHasUserEntry) CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) NameId(org.xipki.ca.api.NameId) CmdFailure(org.xipki.console.karaf.CmdFailure)

Example 18 with NameId

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

the class CaAddOrGenAction method getCaEntry.

protected X509CaEntry getCaEntry() throws Exception {
    ParamUtil.requireRange("sn-bitlen", snBitLen, 63, 159);
    if (nextCrlNumber < 1) {
        throw new IllegalCmdParamException("invalid CRL number: " + nextCrlNumber);
    }
    if (numCrls < 0) {
        throw new IllegalCmdParamException("invalid numCrls: " + numCrls);
    }
    if (expirationPeriod < 0) {
        throw new IllegalCmdParamException("invalid expirationPeriod: " + expirationPeriod);
    }
    if ("PKCS12".equalsIgnoreCase(signerType) || "JKS".equalsIgnoreCase(signerType)) {
        signerConf = ShellUtil.canonicalizeSignerConf(signerType, signerConf, passwordResolver, securityFactory);
    }
    X509CaUris caUris = new X509CaUris(caCertUris, ocspUris, crlUris, deltaCrlUris);
    X509CaEntry entry = new X509CaEntry(new NameId(null, caName), snBitLen, nextCrlNumber, signerType, signerConf, caUris, numCrls.intValue(), expirationPeriod.intValue());
    entry.setKeepExpiredCertInDays(keepExpiredCertInDays.intValue());
    boolean duplicateKeyPermitted = isEnabled(duplicateKeyS, true, "duplicate-key");
    entry.setDuplicateKeyPermitted(duplicateKeyPermitted);
    boolean duplicateSubjectPermitted = isEnabled(duplicateSubjectS, true, "duplicate-subject");
    entry.setDuplicateSubjectPermitted(duplicateSubjectPermitted);
    boolean saveReq = isEnabled(saveReqS, false, "save-req");
    entry.setSaveRequest(saveReq);
    ValidityMode validityMode = ValidityMode.forName(validityModeS);
    entry.setValidityMode(validityMode);
    CaStatus status = CaStatus.forName(caStatus);
    entry.setStatus(status);
    if (crlSignerName != null) {
        entry.setCrlSignerName(crlSignerName);
    }
    if (responderName != null) {
        entry.setResponderName(responderName);
    }
    CertValidity tmpMaxValidity = CertValidity.getInstance(maxValidity);
    entry.setMaxValidity(tmpMaxValidity);
    entry.setKeepExpiredCertInDays(keepExpiredCertInDays);
    if (cmpControlName != null) {
        entry.setCmpControlName(cmpControlName);
    }
    int intPermission = ShellUtil.getPermission(permissions);
    entry.setPermission(intPermission);
    if (extraControl != null) {
        extraControl = extraControl.trim();
    }
    if (StringUtil.isNotBlank(extraControl)) {
        entry.setExtraControl(new ConfPairs(extraControl).unmodifiable());
    }
    return entry;
}
Also used : X509CaUris(org.xipki.ca.server.mgmt.api.x509.X509CaUris) ValidityMode(org.xipki.ca.server.mgmt.api.ValidityMode) NameId(org.xipki.ca.api.NameId) CertValidity(org.xipki.ca.api.profile.CertValidity) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) ConfPairs(org.xipki.common.ConfPairs) CaStatus(org.xipki.ca.server.mgmt.api.CaStatus) X509CaEntry(org.xipki.ca.server.mgmt.api.x509.X509CaEntry)

Example 19 with NameId

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

the class ProfileAddCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (conf == null && confFile != null) {
        conf = new String(IoUtil.read(confFile));
    }
    CertprofileEntry entry = new CertprofileEntry(new NameId(null, name), type, conf);
    String msg = "certificate profile " + name;
    try {
        caManager.addCertprofile(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) CertprofileEntry(org.xipki.ca.server.mgmt.api.CertprofileEntry)

Example 20 with NameId

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

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