Package org.pgpainless.key
Class OpenPgpV4Fingerprint
- java.lang.Object
-
- org.pgpainless.key.OpenPgpFingerprint
-
- org.pgpainless.key.OpenPgpV4Fingerprint
-
- All Implemented Interfaces:
CharSequence
,Comparable<OpenPgpFingerprint>
public class OpenPgpV4Fingerprint extends OpenPgpFingerprint
This class represents a hex encoded, uppercase OpenPGP v4 fingerprint.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SCHEME
-
Fields inherited from class org.pgpainless.key.OpenPgpFingerprint
fingerprint, utf8
-
-
Constructor Summary
Constructors Constructor Description OpenPgpV4Fingerprint(byte[] bytes)
OpenPgpV4Fingerprint(String fingerprint)
Create anOpenPgpV4Fingerprint
.OpenPgpV4Fingerprint(org.bouncycastle.openpgp.PGPKeyRing ring)
OpenPgpV4Fingerprint(org.bouncycastle.openpgp.PGPPublicKey key)
OpenPgpV4Fingerprint(org.bouncycastle.openpgp.PGPPublicKeyRing ring)
OpenPgpV4Fingerprint(org.bouncycastle.openpgp.PGPSecretKey key)
OpenPgpV4Fingerprint(org.bouncycastle.openpgp.PGPSecretKeyRing ring)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(OpenPgpFingerprint openPgpFingerprint)
boolean
equals(Object other)
static OpenPgpV4Fingerprint
fromUri(URI uri)
Convert an openpgp4fpr URI to anOpenPgpV4Fingerprint
.long
getKeyId()
Return the key id of the OpenPGP public key thisOpenPgpFingerprint
belongs to.int
getVersion()
Return the version of the fingerprint.int
hashCode()
protected boolean
isValid(String fp)
Check, whether the fingerprint consists of 40 valid hexadecimal characters.String
prettyPrint()
Return a pretty printed representation of the fingerprint.URI
toUri()
Return the fingerprint as an openpgp4fprURI
.-
Methods inherited from class org.pgpainless.key.OpenPgpFingerprint
charAt, length, of, of, subSequence, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Field Detail
-
SCHEME
public static final String SCHEME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull String fingerprint)
Create anOpenPgpV4Fingerprint
.- Parameters:
fingerprint
- hexadecimal representation of the fingerprint.- See Also:
- XEP-0373 §4.1: The OpenPGP Public-Key Data Node about how to obtain the fingerprint
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull byte[] bytes)
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull org.bouncycastle.openpgp.PGPPublicKey key)
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull org.bouncycastle.openpgp.PGPSecretKey key)
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull org.bouncycastle.openpgp.PGPPublicKeyRing ring)
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull org.bouncycastle.openpgp.PGPSecretKeyRing ring)
-
OpenPgpV4Fingerprint
public OpenPgpV4Fingerprint(@Nonnull org.bouncycastle.openpgp.PGPKeyRing ring)
-
-
Method Detail
-
getVersion
public int getVersion()
Description copied from class:OpenPgpFingerprint
Return the version of the fingerprint.- Specified by:
getVersion
in classOpenPgpFingerprint
- Returns:
- version
-
isValid
protected boolean isValid(@Nonnull String fp)
Description copied from class:OpenPgpFingerprint
Check, whether the fingerprint consists of 40 valid hexadecimal characters.- Specified by:
isValid
in classOpenPgpFingerprint
- Parameters:
fp
- fingerprint to check.- Returns:
- true if fingerprint is valid.
-
getKeyId
public long getKeyId()
Description copied from class:OpenPgpFingerprint
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.- Specified by:
getKeyId
in classOpenPgpFingerprint
- Returns:
- key id
- See Also:
- RFC-4880 §12.2: Key IDs and Fingerprints
-
prettyPrint
public String prettyPrint()
Description copied from class:OpenPgpFingerprint
Return a pretty printed representation of the fingerprint.- Specified by:
prettyPrint
in classOpenPgpFingerprint
- Returns:
- pretty printed fingerprint
-
toUri
public URI toUri()
Return the fingerprint as an openpgp4fprURI
. An example would be 'openpgp4fpr:7F9116FEA90A5983936C7CFAA027DB2F3E1E118A'.- Returns:
- openpgp4fpr fingerprint uri
- See Also:
- openpgp4fpr URI scheme
-
fromUri
public static OpenPgpV4Fingerprint fromUri(URI uri)
Convert an openpgp4fpr URI to anOpenPgpV4Fingerprint
.- Parameters:
uri
-URI
with scheme 'openpgp4fpr'- Returns:
- fingerprint parsed from the uri
- See Also:
- openpgp4fpr URI scheme
-
compareTo
public int compareTo(@Nonnull OpenPgpFingerprint openPgpFingerprint)
-
-