Search in sources :

Example 1 with CertListOrderBy

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

the class ListCertCmd method execute0.

/**
 * TODO.
 * @return comma-separated serial numbers (in hex).
 */
@Override
protected Object execute0() throws Exception {
    Date validFrom = getDate(validFromS);
    Date validTo = getDate(validToS);
    X500Name subjectPattern = null;
    if (StringUtil.isNotBlank(subjectPatternS)) {
        subjectPattern = new X500Name(subjectPatternS);
    }
    CertListOrderBy orderBy = null;
    if (orderByS != null) {
        orderBy = CertListOrderBy.forValue(orderByS);
        if (orderBy == null) {
            throw new IllegalCmdParamException("invalid order '" + orderByS + "'");
        }
    }
    List<CertListInfo> certInfos = caManager.listCertificates(caName, subjectPattern, validFrom, validTo, orderBy, num);
    final int n = certInfos.size();
    if (n == 0) {
        println("found no certificate");
        return null;
    }
    println("     | serial               | notBefore      | notAfter       | subject");
    println("-----+----------------------+----------------+----------------+-----------------");
    for (int i = 0; i < n; i++) {
        CertListInfo info = certInfos.get(i);
        println(format(i + 1, info));
    }
    return null;
}
Also used : CertListOrderBy(org.xipki.ca.server.mgmt.api.CertListOrderBy) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) CertListInfo(org.xipki.ca.server.mgmt.api.CertListInfo) X500Name(org.bouncycastle.asn1.x500.X500Name) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 X500Name (org.bouncycastle.asn1.x500.X500Name)1 CertListInfo (org.xipki.ca.server.mgmt.api.CertListInfo)1 CertListOrderBy (org.xipki.ca.server.mgmt.api.CertListOrderBy)1 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)1