Search in sources :

Example 1 with RevocationReason

use of org.bouncycastle.bcpg.sig.RevocationReason in project gerrit by GerritCodeReview.

the class PublicKeyChecker method gatherRevocationProblems.

private void gatherRevocationProblems(PGPPublicKey key, Date now, List<String> problems) {
    try {
        List<PGPSignature> revocations = new ArrayList<>();
        Map<Long, RevocationKey> revokers = new HashMap<>();
        PGPSignature selfRevocation = scanRevocations(key, now, revocations, revokers);
        if (selfRevocation != null) {
            RevocationReason reason = getRevocationReason(selfRevocation);
            if (isRevocationValid(selfRevocation, reason, now)) {
                problems.add(reasonToString(reason));
            }
        } else {
            checkRevocations(key, revocations, revokers, problems);
        }
    } catch (PGPException | IOException e) {
        problems.add("Error checking key revocation");
    }
}
Also used : RevocationReason(org.bouncycastle.bcpg.sig.RevocationReason) PGPException(org.bouncycastle.openpgp.PGPException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RevocationKey(org.bouncycastle.bcpg.sig.RevocationKey) PGPSignature(org.bouncycastle.openpgp.PGPSignature) IOException(java.io.IOException)

Example 2 with RevocationReason

use of org.bouncycastle.bcpg.sig.RevocationReason in project gerrit by GerritCodeReview.

the class PublicKeyChecker method gatherRevocationProblems.

private void gatherRevocationProblems(PGPPublicKey key, Instant now, List<String> problems) {
    try {
        List<PGPSignature> revocations = new ArrayList<>();
        Map<Long, RevocationKey> revokers = new HashMap<>();
        PGPSignature selfRevocation = scanRevocations(key, now, revocations, revokers);
        if (selfRevocation != null) {
            RevocationReason reason = getRevocationReason(selfRevocation);
            if (isRevocationValid(selfRevocation, reason, now)) {
                problems.add(reasonToString(reason));
            }
        } else {
            checkRevocations(key, revocations, revokers, problems);
        }
    } catch (PGPException | IOException e) {
        problems.add("Error checking key revocation");
    }
}
Also used : RevocationReason(org.bouncycastle.bcpg.sig.RevocationReason) PGPException(org.bouncycastle.openpgp.PGPException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RevocationKey(org.bouncycastle.bcpg.sig.RevocationKey) PGPSignature(org.bouncycastle.openpgp.PGPSignature) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RevocationKey (org.bouncycastle.bcpg.sig.RevocationKey)2 RevocationReason (org.bouncycastle.bcpg.sig.RevocationReason)2 PGPException (org.bouncycastle.openpgp.PGPException)2 PGPSignature (org.bouncycastle.openpgp.PGPSignature)2