Class Ring
- All Implemented Interfaces:
Cloneable
Key
s.
Keys can be added to the ring by adding them to the list returned by the
getKeys()
method, or by loading them from ascii armor text via the
load(String)
method, or by loading them from a file via the
load(File)
method, or by loading them from an input stream via the
load(InputStream)
method. A ring can also be constructed from
an existing array of keys (Ring(Key...)
), or from an existing list
of keys (Ring(List)
), or from an ASCII-armor text string containing
the keys (Ring(String)
), or from a file containing the keys
(Ring(File)
), or from an input stream containing the keys
(Ring(InputStream)
).
Once keys have been loaded, their subkeys can be manipulated to customize usage flags (to indicate whether a subkey should be used for encryption, decryption, signing, or verification), and to supply the passphrase needed to unlock the subkey (which is needed to use the subkey for decryption and signing).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRing()
Constructs a new empty ring.Loads all keys from the specified file.Ring
(InputStream stream) Loads all keys from the specified input stream.Loads all keys from the specified armored text.Constructs a new ring with the specified list of keys.Constructs a new ring with the specified array of keys. -
Method Summary
Modifier and TypeMethodDescriptionboolean
True if this contains at least one key.void
Zeroes-out the cached passphrase for all keys, and releases the extracted private key material for garbage collection.clone()
All keys for which the specified ID is any subkey's full ID.All keys for which the specified string is a case-insensitive substring of either: any subkey's full ID (eg "0x1234567890ABCDEF") any subkey's fingerprint (eg "1234567890ABCDEF1234567890ABCDEF12345678") any one of any subkey's user IDs (eg "Alice (work) <alice@example.com>")All keys for which the specified pattern matches any part of either: any subkey's full ID (eg "0x1234567890ABCDEF") any subkey's fingerprint (eg "1234567890ABCDEF1234567890ABCDEF12345678") any one of any subkey's user IDs (eg "Alice (work) <alice@example.com>")Deprecated.All keys that can decrypt, or an empty list.All keys that can encrypt, or an empty list.getKeys()
All keys, an or an empty list.All keys that can sign, or an empty list.All keys that can verify, or an empty list.Loads all keys from the specified file, and adds them to this ring's existing list of keys.load
(InputStream stream) Loads all keys from the specified input stream, and adds them to this ring's existing list of keys.Loads all keys from the specified armored text, and adds them to this ring's existing list of keys.protected Key
protected Key
newKey
(org.bouncycastle.openpgp.PGPPublicKeyRing ring) protected Key
newKey
(org.bouncycastle.openpgp.PGPSecretKeyRing ring) protected Subkey
protected Subkey
newSubkey
(org.bouncycastle.openpgp.PGPPublicKey k) protected Subkey
newSubkey
(org.bouncycastle.openpgp.PGPSecretKey k) protected Iterator
<?> parse
(InputStream stream) Separates stream into PGP packets.protected void
All keys, an or an empty list.toString()
Display string for this ring, including listing each key on the ring, with each subkey's usage flags, short ID, and user IDs.
-
Field Details
-
keys
-
-
Constructor Details
-
Ring
public Ring()Constructs a new empty ring. -
Ring
Constructs a new ring with the specified array of keys. -
Ring
Constructs a new ring with the specified list of keys. -
Ring
Loads all keys from the specified armored text.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
Ring
Loads all keys from the specified file.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
Ring
Loads all keys from the specified input stream.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
-
Method Details
-
clone
-
toString
Display string for this ring, including listing each key on the ring, with each subkey's usage flags, short ID, and user IDs. -
asBoolean
public boolean asBoolean()True if this contains at least one key. -
getSigningKeys
All keys that can sign, or an empty list. -
getVerificationKeys
All keys that can verify, or an empty list. -
getEncryptionKeys
All keys that can encrypt, or an empty list. -
getDecryptionKeys
All keys that can decrypt, or an empty list. -
getKeys
All keys, an or an empty list. -
setKeys
All keys, an or an empty list. -
findById
Deprecated.UsefindAll(java.lang.Long)
(to find all subkeys on a ring, in case the same key had been included multiple times with different settings on the same ring).First key containing the subkey with the specified full ID, or null. -
findAll
All keys for which the specified ID is any subkey's full ID. Normally this will return 0 or 1 keys, but if a key has been added to a ring multiple times (with different settings, such as one time as a public key and one time as a private key), this method may return more than one key instance. -
findAll
All keys for which the specified string is a case-insensitive substring of either:- any subkey's full ID (eg "0x1234567890ABCDEF")
- any subkey's fingerprint (eg "1234567890ABCDEF1234567890ABCDEF12345678")
- any one of any subkey's user IDs (eg "Alice (work) <alice@example.com>")
So for example, a string "0x1234" would match the above full ID; a string "90ab" would match the above fingerprint; and a string "alice (work)" would match the above user ID.
-
findAll
All keys for which the specified pattern matches any part of either:- any subkey's full ID (eg "0x1234567890ABCDEF")
- any subkey's fingerprint (eg "1234567890ABCDEF1234567890ABCDEF12345678")
- any one of any subkey's user IDs (eg "Alice (work) <alice@example.com>")
So for example, a pattern /0x1234/ would match the above full ID; a pattern /(?i)90ab/ would match the above fingerprint; and a pattern /Alice .work./ would match the above user ID.
-
clearSecrets
public void clearSecrets()Zeroes-out the cached passphrase for all keys, and releases the extracted private key material for garbage collection. -
load
Loads all keys from the specified armored text, and adds them to this ring's existing list of keys.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
load
Loads all keys from the specified file, and adds them to this ring's existing list of keys.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
load
Loads all keys from the specified input stream, and adds them to this ring's existing list of keys.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
parse
protected Iterator<?> parse(InputStream stream) throws IOException, org.bouncycastle.openpgp.PGPException Separates stream into PGP packets.- Throws:
IOException
org.bouncycastle.openpgp.PGPException
- See Also:
-
newKey
-
newKey
protected Key newKey(org.bouncycastle.openpgp.PGPPublicKeyRing ring) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
newKey
protected Key newKey(org.bouncycastle.openpgp.PGPSecretKeyRing ring) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
newSubkey
-
newSubkey
protected Subkey newSubkey(org.bouncycastle.openpgp.PGPPublicKey k) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
newSubkey
protected Subkey newSubkey(org.bouncycastle.openpgp.PGPSecretKey k) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
findAll(java.lang.Long)
(to find all subkeys on a ring, in case the same key had been included multiple times with different settings on the same ring).