public class PGPPublicKey extends java.lang.Object implements PublicKeyAlgorithmTags
DIFFIE_HELLMAN, DSA, EC, ECDH, ECDSA, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, EXPERIMENTAL_1, EXPERIMENTAL_10, EXPERIMENTAL_11, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, EXPERIMENTAL_5, EXPERIMENTAL_6, EXPERIMENTAL_7, EXPERIMENTAL_8, EXPERIMENTAL_9, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN
Constructor and Description |
---|
PGPPublicKey(PublicKeyPacket publicKeyPacket,
KeyFingerPrintCalculator fingerPrintCalculator)
Create a PGP public key from a packet descriptor using the passed in fingerPrintCalculator to do calculate
the fingerprint and keyID.
|
Modifier and Type | Method and Description |
---|---|
static PGPPublicKey |
addCertification(PGPPublicKey key,
byte[] rawID,
PGPSignature certification)
Add a certification for an id to the given public key.
|
static PGPPublicKey |
addCertification(PGPPublicKey key,
PGPSignature certification)
Add a revocation or some other key certification to a key.
|
static PGPPublicKey |
addCertification(PGPPublicKey key,
PGPUserAttributeSubpacketVector userAttributes,
PGPSignature certification)
Add a certification for the given UserAttributeSubpackets to the given public key.
|
static PGPPublicKey |
addCertification(PGPPublicKey key,
java.lang.String id,
PGPSignature certification)
Add a certification for an id to the given public key.
|
void |
encode(java.io.OutputStream outStream) |
int |
getAlgorithm()
Return the algorithm code associated with the public key.
|
int |
getBitStrength()
Return the strength of the key in bits.
|
java.util.Date |
getCreationTime() |
byte[] |
getEncoded() |
byte[] |
getFingerprint()
Return the fingerprint of the key.
|
long |
getKeyID()
Return the keyID associated with the public key.
|
java.util.Iterator |
getKeySignatures()
Return all signatures/certifications directly associated with this key (ie, not to a user id).
|
PublicKeyPacket |
getPublicKeyPacket() |
java.util.Iterator |
getRawUserIDs()
Return any userIDs associated with the key in raw byte form.
|
java.util.Iterator |
getSignatures()
Return all signatures/certifications associated with this key.
|
java.util.Iterator |
getSignaturesForID(byte[] rawID)
Return any signatures associated with the passed in id.
|
java.util.Iterator |
getSignaturesForID(java.lang.String id)
Return any signatures associated with the passed in id.
|
java.util.Iterator |
getSignaturesForUserAttribute(PGPUserAttributeSubpacketVector userAttributes)
Return an iterator of signatures associated with the passed in user attributes.
|
java.util.Iterator |
getSignaturesOfType(int signatureType)
Return signatures of the passed in type that are on this key.
|
byte[] |
getTrustData()
Return the trust data associated with the public key, if present.
|
java.util.Iterator |
getUserAttributes()
Return any user attribute vectors associated with the key.
|
java.util.Iterator |
getUserIDs()
Return any userIDs associated with the key.
|
int |
getValidDays()
Deprecated.
use getValidSeconds(): greater than version 3 keys may be valid for less than a day.
|
long |
getValidSeconds() |
int |
getVersion() |
boolean |
hasRevocation()
Check whether this (sub)key has a revocation signature on it.
|
boolean |
isEncryptionKey()
Return true if this key has an algorithm type that makes it suitable to use for encryption.
|
boolean |
isMasterKey()
Return true if this is a master key.
|
boolean |
isRevoked()
Deprecated.
this method is poorly named, use hasRevocation().
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
byte[] rawID)
Remove any certifications associated with a given id on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
byte[] id,
PGPSignature certification)
Remove a certification associated with a given id on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
PGPSignature certification)
Remove a certification from the key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
PGPUserAttributeSubpacketVector userAttributes)
Remove any certifications associated with a given user attribute subpacket
on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
PGPUserAttributeSubpacketVector userAttributes,
PGPSignature certification)
Remove a certification associated with a given user attributes on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
java.lang.String id)
Remove any certifications associated with a given id on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
java.lang.String id,
PGPSignature certification)
Remove a certification associated with a given id on a key.
|
public PGPPublicKey(PublicKeyPacket publicKeyPacket, KeyFingerPrintCalculator fingerPrintCalculator) throws PGPException
publicKeyPacket
- packet describing the public key.fingerPrintCalculator
- calculator providing the digest support ot create the key fingerprint.PGPException
- if the packet is faulty, or the required calculations fail.public int getVersion()
public java.util.Date getCreationTime()
public int getValidDays()
public byte[] getTrustData()
public long getValidSeconds()
public long getKeyID()
public byte[] getFingerprint()
public boolean isEncryptionKey()
Note: with version 4 keys KeyFlags subpackets should also be considered when present for determining the preferred use of the key.
public boolean isMasterKey()
public int getAlgorithm()
public int getBitStrength()
public java.util.Iterator getUserIDs()
public java.util.Iterator getRawUserIDs()
public java.util.Iterator getUserAttributes()
public java.util.Iterator getSignaturesForID(java.lang.String id)
id
- the id to be matched.public java.util.Iterator getSignaturesForID(byte[] rawID)
rawID
- the id to be matched in raw byte form.public java.util.Iterator getSignaturesForUserAttribute(PGPUserAttributeSubpacketVector userAttributes)
userAttributes
- the vector of user attributes to be matched.public java.util.Iterator getSignaturesOfType(int signatureType)
signatureType
- the type of the signature to be returned.public java.util.Iterator getSignatures()
public java.util.Iterator getKeySignatures()
public PublicKeyPacket getPublicKeyPacket()
public byte[] getEncoded() throws java.io.IOException
java.io.IOException
public void encode(java.io.OutputStream outStream) throws java.io.IOException
java.io.IOException
public boolean isRevoked()
public boolean hasRevocation()
public static PGPPublicKey addCertification(PGPPublicKey key, byte[] rawID, PGPSignature certification)
key
- the key the certification is to be added to.rawID
- the raw bytes making up the user id..certification
- the new certification.public static PGPPublicKey addCertification(PGPPublicKey key, java.lang.String id, PGPSignature certification)
key
- the key the certification is to be added to.id
- the id the certification is associated with.certification
- the new certification.public static PGPPublicKey addCertification(PGPPublicKey key, PGPUserAttributeSubpacketVector userAttributes, PGPSignature certification)
key
- the key the certification is to be added to.userAttributes
- the attributes the certification is associated with.certification
- the new certification.public static PGPPublicKey removeCertification(PGPPublicKey key, PGPUserAttributeSubpacketVector userAttributes)
key
- the key the certifications are to be removed from.userAttributes
- the attributes to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, java.lang.String id)
key
- the key the certifications are to be removed from.id
- the id that is to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, byte[] rawID)
key
- the key the certifications are to be removed from.rawID
- the id that is to be removed in raw byte form.public static PGPPublicKey removeCertification(PGPPublicKey key, byte[] id, PGPSignature certification)
key
- the key the certifications are to be removed from.id
- the id that the certification is to be removed from (in its raw byte form)certification
- the certification to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, java.lang.String id, PGPSignature certification)
key
- the key the certifications are to be removed from.id
- the id that the certification is to be removed from.certification
- the certification to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, PGPUserAttributeSubpacketVector userAttributes, PGPSignature certification)
key
- the key the certifications are to be removed from.userAttributes
- the user attributes that the certification is to be removed from.certification
- the certification to be removed.public static PGPPublicKey addCertification(PGPPublicKey key, PGPSignature certification)
key
- the key the revocation is to be added to.certification
- the key signature to be added.public static PGPPublicKey removeCertification(PGPPublicKey key, PGPSignature certification)
key
- the key the certifications are to be removed from.certification
- the certification to be removed.