Package org.pgpainless.key
Class OpenPgpFingerprint
java.lang.Object
org.pgpainless.key.OpenPgpFingerprint
- All Implemented Interfaces:
CharSequence
,Comparable<OpenPgpFingerprint>
- Direct Known Subclasses:
OpenPgpV4Fingerprint
,OpenPgpV5Fingerprint
public abstract class OpenPgpFingerprint
extends Object
implements CharSequence, Comparable<OpenPgpFingerprint>
Abstract super class of different version OpenPGP fingerprints.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOpenPgpFingerprint
(byte[] bytes) OpenPgpFingerprint
(String fingerprint) OpenPgpFingerprint
(org.bouncycastle.openpgp.PGPKeyRing ring) OpenPgpFingerprint
(org.bouncycastle.openpgp.PGPPublicKey key) OpenPgpFingerprint
(org.bouncycastle.openpgp.PGPPublicKeyRing ring) OpenPgpFingerprint
(org.bouncycastle.openpgp.PGPSecretKeyRing ring) -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int i) abstract long
getKeyId()
Return the key id of the OpenPGP public key thisOpenPgpFingerprint
belongs to.abstract int
Return the version of the fingerprint.protected abstract boolean
Check, whether the fingerprint consists of 40 valid hexadecimal characters.int
length()
static OpenPgpFingerprint
of
(org.bouncycastle.openpgp.PGPKeyRing ring) Return the fingerprint of the primary key of the given key ring.static OpenPgpFingerprint
of
(org.bouncycastle.openpgp.PGPPublicKey key) Return the fingerprint of the given key.static OpenPgpFingerprint
Try to parse anOpenPgpFingerprint
from the given fingerprint string.static OpenPgpFingerprint
parseFromBinary
(byte[] binaryFingerprint) Parse a binary OpenPGP fingerprint into anOpenPgpFingerprint
object.abstract String
Return a pretty printed representation of the fingerprint.subSequence
(int i, int i1) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
utf8
-
fingerprint
-
-
Constructor Details
-
OpenPgpFingerprint
-
OpenPgpFingerprint
public OpenPgpFingerprint(@Nonnull byte[] bytes) -
OpenPgpFingerprint
public OpenPgpFingerprint(org.bouncycastle.openpgp.PGPPublicKey key) -
OpenPgpFingerprint
public OpenPgpFingerprint(@Nonnull org.bouncycastle.openpgp.PGPPublicKeyRing ring) -
OpenPgpFingerprint
public OpenPgpFingerprint(@Nonnull org.bouncycastle.openpgp.PGPSecretKeyRing ring) -
OpenPgpFingerprint
public OpenPgpFingerprint(@Nonnull org.bouncycastle.openpgp.PGPKeyRing ring)
-
-
Method Details
-
of
Return the fingerprint of the given key. This method automatically matches key versions to fingerprint implementations.- Parameters:
key
- key- Returns:
- fingerprint
-
of
Return the fingerprint of the primary key of the given key ring. This method automatically matches key versions to fingerprint implementations.- Parameters:
ring
- key ring- Returns:
- fingerprint
-
parse
Try to parse anOpenPgpFingerprint
from the given fingerprint string.- Parameters:
fingerprint
- fingerprint- Returns:
- parsed fingerprint
-
parseFromBinary
Parse a binary OpenPGP fingerprint into anOpenPgpFingerprint
object.- Parameters:
binaryFingerprint
- binary representation of the fingerprint- Returns:
- parsed fingerprint
-
getVersion
public abstract int getVersion()Return the version of the fingerprint.- Returns:
- version
-
isValid
Check, whether the fingerprint consists of 40 valid hexadecimal characters.- Parameters:
fp
- fingerprint to check.- Returns:
- true if fingerprint is valid.
-
getKeyId
public abstract long getKeyId()Return the key id of the OpenPGP public key thisOpenPgpFingerprint
belongs to. This method can be implemented for V4 and V5 fingerprints. V3 key-IDs cannot be derived from the fingerprint, but we don't care, since V3 is deprecated.- Returns:
- key id
- See Also:
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int i) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
prettyPrint
Return a pretty printed representation of the fingerprint.- Returns:
- pretty printed fingerprint
-