Search in sources :

Example 1 with CRLReason

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));
}
Also used : X509CRLEntry(java.security.cert.X509CRLEntry) X509CRL(java.security.cert.X509CRL) BigInteger(java.math.BigInteger) CRLReason(java.security.cert.CRLReason) ReasonFlag(de.carne.certmgr.certs.x509.ReasonFlag) Date(java.util.Date) LocalDate(java.time.LocalDate) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry)

Example 2 with CRLReason

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;
}
Also used : X509CRLEntry(java.security.cert.X509CRLEntry) BigInteger(java.math.BigInteger) X500Principal(javax.security.auth.x500.X500Principal) CRLReason(java.security.cert.CRLReason) Date(java.util.Date)

Aggregations

BigInteger (java.math.BigInteger)2 CRLReason (java.security.cert.CRLReason)2 X509CRLEntry (java.security.cert.X509CRLEntry)2 Date (java.util.Date)2 UserCertStoreEntry (de.carne.certmgr.certs.UserCertStoreEntry)1 ReasonFlag (de.carne.certmgr.certs.x509.ReasonFlag)1 X509CRL (java.security.cert.X509CRL)1 LocalDate (java.time.LocalDate)1 X500Principal (javax.security.auth.x500.X500Principal)1