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;
}
Aggregations