Search in sources :

Example 1 with CertWithStatusInfo

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

the class CertStatusCmd method execute0.

@Override
protected Object execute0() throws Exception {
    CertWithStatusInfo certInfo = caManager.getCert(caName, getSerialNumber());
    X509Certificate cert = (X509Certificate) certInfo.getCert();
    if (cert == null) {
        System.out.println("certificate unknown");
        return null;
    }
    String msg = StringUtil.concat("certificate profile: ", certInfo.getCertprofile(), "\nstatus: ", (certInfo.getRevocationInfo() == null ? "good" : "revoked with " + certInfo.getRevocationInfo()));
    println(msg);
    if (outputFile != null) {
        saveVerbose("certificate saved to file", new File(outputFile), cert.getEncoded());
    }
    return null;
}
Also used : CertWithStatusInfo(org.xipki.ca.server.mgmt.api.x509.CertWithStatusInfo) File(java.io.File) X509Certificate(java.security.cert.X509Certificate)

Example 2 with CertWithStatusInfo

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

the class GetCertCmd method execute0.

@Override
protected Object execute0() throws Exception {
    CertWithStatusInfo certInfo = caManager.getCert(caName, toBigInt(serialNumberS));
    X509Certificate cert = (X509Certificate) certInfo.getCert();
    if (cert == null) {
        System.out.println("certificate unknown");
        return null;
    }
    saveVerbose("certificate saved to file", new File(outputFile), cert.getEncoded());
    return null;
}
Also used : CertWithStatusInfo(org.xipki.ca.server.mgmt.api.x509.CertWithStatusInfo) File(java.io.File) X509Certificate(java.security.cert.X509Certificate)

Example 3 with CertWithStatusInfo

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

the class CaManagerImpl method getCert.

// method canonicalizeSignerConf
@Override
public CertWithStatusInfo getCert(String caName, BigInteger serialNumber) throws CaMgmtException {
    caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
    ParamUtil.requireNonNull("serialNumber", serialNumber);
    X509Ca ca = getX509Ca(caName);
    X509CertWithRevocationInfo certInfo;
    try {
        certInfo = ca.getCertWithRevocationInfo(serialNumber);
    } catch (CertificateException | OperationException ex) {
        throw new CaMgmtException(ex.getMessage(), ex);
    }
    return (certInfo != null) ? certInfo.toCertWithStatusInfo() : new CertWithStatusInfo();
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CertWithStatusInfo(org.xipki.ca.server.mgmt.api.x509.CertWithStatusInfo) CertificateException(java.security.cert.CertificateException) X509CertWithRevocationInfo(org.xipki.ca.server.impl.store.X509CertWithRevocationInfo) OperationException(org.xipki.ca.api.OperationException)

Example 4 with CertWithStatusInfo

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

the class X509CertWithRevocationInfo method toCertWithStatusInfo.

public CertWithStatusInfo toCertWithStatusInfo() {
    CertWithStatusInfo ret = new CertWithStatusInfo();
    ret.setCert(cert.getCert());
    ret.setCertprofile(certprofile);
    ret.setRevocationInfo(revInfo);
    return ret;
}
Also used : CertWithStatusInfo(org.xipki.ca.server.mgmt.api.x509.CertWithStatusInfo)

Aggregations

CertWithStatusInfo (org.xipki.ca.server.mgmt.api.x509.CertWithStatusInfo)4 File (java.io.File)2 X509Certificate (java.security.cert.X509Certificate)2 CertificateException (java.security.cert.CertificateException)1 OperationException (org.xipki.ca.api.OperationException)1 X509CertWithRevocationInfo (org.xipki.ca.server.impl.store.X509CertWithRevocationInfo)1 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)1