From cb594c3b2c0381ded9387875a50de2949cc05a39 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sat, 24 Jun 2023 10:11:36 +0200 Subject: [PATCH] Add utility methods to KeyRingInfo --- .../org/pgpainless/key/info/KeyRingInfo.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java b/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java index 1c20a06c..d906ab14 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java @@ -117,6 +117,26 @@ public class KeyRingInfo { this.revocationState = findRevocationState(); } + /** + * Return the underlying {@link PGPKeyRing}. + * @return keys + */ + public PGPKeyRing getKeys() { + return keys; + } + + public List getValidSubkeys() { + List subkeys = new ArrayList<>(); + Iterator iterator = getKeys().getPublicKeys(); + while (iterator.hasNext()) { + PGPPublicKey key = iterator.next(); + if (isKeyValidlyBound(key.getKeyID())) { + subkeys.add(key); + } + } + return subkeys; + } + @Nonnull private RevocationState findRevocationState() { PGPSignature revocation = signatures.primaryKeyRevocation;