use of java.security.cert.CRLReason in project certmgr by hdecarne.
the class CRLOptionsController method initEntries.
private void initEntries() throws IOException {
ObservableList<CRLEntryModel> entryItems = this.ctlEntryOptions.getItems();
for (UserCertStoreEntry issuedEntry : this.issuerEntryParam.get().issuedEntries()) {
BigInteger issuedSerial = issuedEntry.getCRT().getSerialNumber();
boolean revoked = false;
ReasonFlag reason = ReasonFlag.UNSPECIFIED;
Date date = null;
if (this.issuerEntryParam.get().hasCRL()) {
X509CRL crl = this.issuerEntryParam.get().getCRL();
X509CRLEntry crlEntry = crl.getRevokedCertificate(issuedSerial);
if (crlEntry != null) {
revoked = true;
CRLReason crlEntryReason = crlEntry.getRevocationReason();
if (crlEntryReason != null) {
reason = ReasonFlag.fromCRLReason(crlEntryReason);
}
date = crlEntry.getRevocationDate();
}
}
entryItems.add(new CRLEntryModel(issuedEntry, revoked, issuedSerial, reason, date));
}
entryItems.sort((o1, o2) -> o1.compareTo(o2));
}
use of java.security.cert.CRLReason in project certmgr by hdecarne.
the class X509CRLHelper method toAttributes.
/**
* Get a CRL object's {@code Attributes}.
*
* @param crl The CRL object to get the attributes for.
* @return The CRL object's attributes.
*/
public static Attributes toAttributes(X509CRL crl) {
Attributes crlAttributes = new Attributes(AttributesI18N.formatSTR_CRL());
crlAttributes.add(AttributesI18N.formatSTR_CRL_VERSION(), Integer.toString(crl.getVersion()));
crlAttributes.add(AttributesI18N.formatSTR_CRL_THISUPDATE(), Attributes.printShortDate(crl.getThisUpdate()));
crlAttributes.add(AttributesI18N.formatSTR_CRL_NEXTUPDATE(), Attributes.printShortDate(crl.getNextUpdate()));
crlAttributes.add(AttributesI18N.formatSTR_CRL_SIGALG(), crl.getSigAlgName());
crlAttributes.add(AttributesI18N.formatSTR_CRL_ISSUERDN(), X500Names.toString(crl.getIssuerX500Principal()));
X509ExtensionHelper.addAttributes(crlAttributes, crl);
Set<? extends X509CRLEntry> crlEntries = crl.getRevokedCertificates();
if (crlEntries != null) {
int entryIndex = 0;
for (X509CRLEntry crlEntry : crlEntries) {
BigInteger serial = crlEntry.getSerialNumber();
X500Principal issuer = crlEntry.getCertificateIssuer();
String entrySerial = (issuer != null ? AttributesI18N.formatSTR_CRL_ENTRY_SERIAL_INDIRECT(Attributes.printSerial(serial), issuer) : AttributesI18N.formatSTR_CRL_ENTRY_SERIAL(Attributes.printSerial(serial)));
Attributes crlEntryAttributes = crlAttributes.add(AttributesI18N.formatSTR_CRL_ENTRY(entryIndex), entrySerial);
Date revocationDate = crlEntry.getRevocationDate();
crlEntryAttributes.add(AttributesI18N.formatSTR_CRL_ENTRY_DATE(), Attributes.printShortDate(revocationDate));
CRLReason revocationReason = crlEntry.getRevocationReason();
if (revocationReason != null) {
crlEntryAttributes.add(AttributesI18N.formatSTR_CRL_ENTRY_REASON(), ReasonFlag.fromCRLReason(revocationReason).name());
}
X509ExtensionHelper.addAttributes(crlEntryAttributes, crlEntry);
entryIndex++;
}
}
return crlAttributes;
}
Aggregations