Bouncy Castle Cryptography 1.23

org.bouncycastle.openpgp
Class PGPPublicKey

java.lang.Object
  |
  +--org.bouncycastle.openpgp.PGPPublicKey

public class PGPPublicKey
extends java.lang.Object
implements PublicKeyAlgorithmTags

general class to handle a PGP public key object.


Fields inherited from interface org.bouncycastle.bcpg.PublicKeyAlgorithmTags
DIFFIE_HELLMAN, DSA, EC, ECDSA, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN
 
Constructor Summary
PGPPublicKey(int algorithm, java.security.PublicKey pubKey, java.util.Date time, java.lang.String provider)
          Create a PGPPublicKey from the passed in JCA one.
 
Method Summary
static PGPPublicKey addCertification(PGPPublicKey key, java.lang.String id, PGPSignature certification)
          Add a certfication 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 16 byte fingerprint of the key.
 java.security.PublicKey getKey(java.lang.String provider)
          Return the public key contained in the object.
 long getKeyID()
          Return the keyID associated with the public key.
 java.util.Iterator getSignaturesForID(java.lang.String id)
           
 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()
           
 int getVersion()
           
 boolean isEncryptionKey()
          return true if this key is marked as suitable for encryption.
 boolean isMasterKey()
          Return true if this is a master 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 any certifications associated with a given id on a key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGPPublicKey

public PGPPublicKey(int algorithm,
                    java.security.PublicKey pubKey,
                    java.util.Date time,
                    java.lang.String provider)
             throws PGPException,
                    java.security.NoSuchProviderException
Create a PGPPublicKey from the passed in JCA one.

Note: the time passed in affects the value of the key's keyID, so you probably only want to do this once for a JCA key, or make sure you keep track of the time you used.

Parameters:
algorithm -  
pubKey -  
time -  
provider -  
Throws:
PGPException -  
java.security.NoSuchProviderException -  
Method Detail

getVersion

public int getVersion()
Returns:
the version of this key.

getCreationTime

public java.util.Date getCreationTime()
Returns:
creation time of key.

getValidDays

public int getValidDays()
Returns:
number of valid days from creation time - zero means no expiry.

getKeyID

public long getKeyID()
Return the keyID associated with the public key.
Returns:
long

getFingerprint

public byte[] getFingerprint()
Return the 16 byte fingerprint of the key.
Returns:
key fingerprint.

isEncryptionKey

public boolean isEncryptionKey()
return true if this key is marked as suitable for encryption.

isMasterKey

public boolean isMasterKey()
Return true if this is a master key.
Returns:
true if a master key.

getAlgorithm

public int getAlgorithm()
Return the algorithm code associated with the public key.
Returns:
int

getBitStrength

public int getBitStrength()
Return the strength of the key in bits.
Returns:
bit strenght of key.

getKey

public java.security.PublicKey getKey(java.lang.String provider)
                               throws PGPException,
                                      java.security.NoSuchProviderException
Return the public key contained in the object.
Parameters:
provider - provider to construct the key for.
Returns:
PublicKey
Throws:
PGPException -  
java.security.NoSuchProviderException -  

getUserIDs

public java.util.Iterator getUserIDs()
Return any userIDs associated with the key.
Returns:
an iterator of Strings.

getUserAttributes

public java.util.Iterator getUserAttributes()
Return any user attribute vectors associated with the key.
Returns:
an iterator of Strings.

getSignaturesForID

public java.util.Iterator getSignaturesForID(java.lang.String id)

getEncoded

public byte[] getEncoded()
                  throws java.io.IOException

encode

public void encode(java.io.OutputStream outStream)
            throws java.io.IOException

addCertification

public static PGPPublicKey addCertification(PGPPublicKey key,
                                            java.lang.String id,
                                            PGPSignature certification)
Add a certfication to the given public key.
Parameters:
key - the key the certification is to be added to.
id - the id the certification is associated with.
certification - the new certification.
Returns:
the re-certified key.

removeCertification

public static PGPPublicKey removeCertification(PGPPublicKey key,
                                               java.lang.String id)
Remove any certifications associated with a given id on a key.
Parameters:
key - the key the certifications are to be removed from.
id - the id that is to be removed.
Returns:
the re-certified key, null if the id was not found on the key.

removeCertification

public static PGPPublicKey removeCertification(PGPPublicKey key,
                                               java.lang.String id,
                                               PGPSignature certification)
Remove any certifications associated with a given id on a key.
Parameters:
key - the key the certifications are to be removed from.
id - the id that the certfication is to be removed from.
certification - the certfication to be removed.
Returns:
the re-certified key, null if the certification was not found.

Bouncy Castle Cryptography 1.23