|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.bcpg.KeyIdentifier
Utility class for matching key-ids / fingerprints.
A KeyIdentifier
can be created from either a 64-bit key-id, a fingerprint, or both.
This class was created to enable a seamless transition from use of key-ids in the API
towards identifying keys via fingerprints.
Constructor Summary | |
KeyIdentifier(byte[] fingerprint)
Create a new KeyIdentifier based on a keys fingerprint.
|
|
KeyIdentifier(byte[] fingerprint,
long keyId)
Create a KeyIdentifier based on the given fingerprint and key-id. |
|
KeyIdentifier(long keyId)
Create a KeyIdentifier based on the given key-id.
|
|
KeyIdentifier(java.lang.String hexEncoded)
|
Method Summary | |
boolean |
equals(java.lang.Object obj)
|
byte[] |
getFingerprint()
Return the fingerprint of the KeyIdentifier .
|
long |
getKeyId()
Return the key-id of the KeyIdentifier .
|
boolean |
hasFingerprint(byte[] fingerprint)
Return true if the KeyIdentifier has a fingerprint corresponding to the passed in one. |
int |
hashCode()
|
boolean |
isPresentIn(java.util.List others)
Return true, if this KeyIdentifier is present in the given list of KeyIdentifier .
|
boolean |
isWildcard()
Returns true, if the KeyIdentifier specifies a wildcard (matches anything).
|
boolean |
matches(KeyIdentifier other)
Return true, if this KeyIdentifier matches the given other KeyIdentifier .
|
static boolean |
matches(java.util.List identifiers,
KeyIdentifier identifier,
boolean explicit)
|
boolean |
matchesExplicit(KeyIdentifier other)
|
java.lang.String |
toPrettyPrint()
|
java.lang.String |
toString()
|
static KeyIdentifier |
wildcard()
Create a wildcard KeyIdentifier . |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public KeyIdentifier(java.lang.String hexEncoded)
public KeyIdentifier(byte[] fingerprint)
KeyIdentifier
based on a keys fingerprint.
For fingerprints matching the format of a v4, v5 or v6 key, the constructor will
try to derive the corresponding key-id from the fingerprint.
fingerprint
- fingerprintpublic KeyIdentifier(byte[] fingerprint, long keyId)
KeyIdentifier
based on the given fingerprint and key-id.
fingerprint
- fingerprintkeyId
- key-idpublic KeyIdentifier(long keyId)
KeyIdentifier
based on the given key-id.
will be set to .
keyId
- key-idMethod Detail |
public static KeyIdentifier wildcard()
KeyIdentifier
.
public byte[] getFingerprint()
KeyIdentifier
.
might be null, if the KeyIdentifier
was created from just a key-id.
If isWildcard()
returns true, this method returns an empty, but non-null array.
public long getKeyId()
KeyIdentifier
.
This might be if isWildcard()
returns true, or if an unknown
fingerprint was passed in.
public boolean isWildcard()
KeyIdentifier
specifies a wildcard (matches anything).
This is for example used with anonymous recipient key-ids / fingerprints, where the recipient
needs to try all available keys to decrypt the message.
public boolean hasFingerprint(byte[] fingerprint)
fingerprint
- the fingerprint to match against.
public boolean matches(KeyIdentifier other)
KeyIdentifier
matches the given other KeyIdentifier
.
This will return true if the fingerprint matches, or if the key-id matches,
or if isWildcard()
returns true.
other
- the identifier we are matching against.
public boolean matchesExplicit(KeyIdentifier other)
public static boolean matches(java.util.List identifiers, KeyIdentifier identifier, boolean explicit)
public boolean isPresentIn(java.util.List others)
KeyIdentifier
is present in the given list of KeyIdentifier
.
This will return true if a fingerprint matches, or if a key-id matches,
or if isWildcard()
returns true.
others
- the list of key identifiers to check.
public boolean equals(java.lang.Object obj)
public int hashCode()
public java.lang.String toString()
public java.lang.String toPrettyPrint()
|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |