From 172972fe293ca19c5787c77af17a1a42bd908a34 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 8353676d..77277622 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 @@ -118,6 +118,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;