Package org.pgpainless.key
Class OpenPgpFingerprint
java.lang.Object
org.pgpainless.key.OpenPgpFingerprint
- All Implemented Interfaces:
CharSequence,Comparable<OpenPgpFingerprint>
- Direct Known Subclasses:
_64DigitFingerprint,OpenPgpV4Fingerprint
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 TypeMethodDescriptioncharcharAt(int i) abstract longgetKeyId()Return the key id of the OpenPGP public key thisOpenPgpFingerprintbelongs to.abstract intReturn the version of the fingerprint.protected abstract booleanCheck, whether the fingerprint consists of 40 valid hexadecimal characters.intlength()static OpenPgpFingerprintof(org.bouncycastle.openpgp.PGPKeyRing ring) Return the fingerprint of the primary key of the given key ring.static OpenPgpFingerprintof(org.bouncycastle.openpgp.PGPPublicKey key) Return the fingerprint of the given key.static OpenPgpFingerprintof(org.bouncycastle.openpgp.PGPSecretKey key) Return the fingerprint of the given key.static OpenPgpFingerprintDeprecated.Use the constructor methods of the versioned fingerprint subclasses instead.static OpenPgpFingerprintparseFromBinary(byte[] binaryFingerprint) Deprecated.use the parse() methods of the versioned fingerprint subclasses instead.abstract StringReturn 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, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmptyMethods 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 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
Deprecated.Use the constructor methods of the versioned fingerprint subclasses instead.Try to parse anOpenPgpFingerprintfrom the given fingerprint string. If the trimmed fingerprint without whitespace is 64 characters long, it is either a v5 or v6 fingerprint. In this case, we return a_64DigitFingerprint. Since this is ambiguous, it is generally recommended to know the version of the key beforehand.- Parameters:
fingerprint- fingerprint- Returns:
- parsed fingerprint
-
parseFromBinary
Deprecated.use the parse() methods of the versioned fingerprint subclasses instead.Parse a binary OpenPGP fingerprint into anOpenPgpFingerprintobject.- 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 thisOpenPgpFingerprintbelongs 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:
lengthin interfaceCharSequence
-
charAt
public char charAt(int i) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
prettyPrint
Return a pretty printed representation of the fingerprint.- Returns:
- pretty printed fingerprint
-