au.net.aba.pgp
Class Keyring

java.lang.Object
  |
  +--au.net.aba.pgp.Keyring

public class Keyring
extends java.lang.Object

A PGP keyring. To use this package in conjunction with the ABA crypto provider it is necessary to use a PGP 2.3 compatible keyring, with no passphrase on the keyring.

In your application:

 import au.net.aba.pgp.Keyring;

 Keyring keyRing = new Keyring(keyringdir);
 PublicKey publicKey = keyRing.getPublicKey(keyID);
 

Where keyringdir is directory containing the pgp pubring.pgp and secring.pgp files and keyID is the keyname to be retrieved.


Field Summary
static java.lang.String ident
           
 
Constructor Summary
Keyring(java.lang.String keyring)
          Construct with user supplied keyring.
 
Method Summary
 java.security.PrivateKey getPrivateKey(java.lang.String key)
          Return the private key with the given key name.
 java.security.PrivateKey getPrivateKey(java.lang.String key, java.lang.String provider)
          Return a private key generated for a specific provider.
 java.security.PublicKey getPublicKey(java.lang.String key)
          Return the public key with the given key name.
 java.security.PublicKey getPublicKey(java.lang.String key, java.lang.String provider)
          Return a public key generated for a specific provider.
static void main(java.lang.String[] arg)
          Display a key in the given keyring as a dotted hexadecimal string as per the AsciiEncodedKeySpec.
 au.net.aba.pgp.PublicKeyCertificatePacket readPublicKey(java.lang.String key)
          Read a public key certificate.
 au.net.aba.pgp.SecretKeyCertificatePacket readSecretKey(java.lang.String key)
          Read a private key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ident

public static final java.lang.String ident
Constructor Detail

Keyring

public Keyring(java.lang.String keyring)
Construct with user supplied keyring.
Method Detail

getPublicKey

public java.security.PublicKey getPublicKey(java.lang.String key)
                                     throws java.security.KeyException,
                                            java.io.IOException
Return the public key with the given key name.
Parameters:
key - the name of the key we want.
Returns:
the PrivateKey object representing that key.
Throws:
java.security.KeyException - a problem occured reading the key.

getPrivateKey

public java.security.PrivateKey getPrivateKey(java.lang.String key)
                                       throws java.security.KeyException,
                                              java.io.IOException
Return the private key with the given key name.
Parameters:
key - the name of the key we want.
Returns:
the PrivateKey object representing that key.
Throws:
java.security.KeyException - a problem occured reading the key.

getPublicKey

public java.security.PublicKey getPublicKey(java.lang.String key,
                                            java.lang.String provider)
                                     throws java.security.KeyException,
                                            java.io.IOException
Return a public key generated for a specific provider.
Parameters:
key - the name of the key we want.
provider - the name of the provider we want to use.
Returns:
the PrivateKey object representing that key.
Throws:
java.security.KeyException - a problem occured reading the key.

getPrivateKey

public java.security.PrivateKey getPrivateKey(java.lang.String key,
                                              java.lang.String provider)
                                       throws java.security.KeyException,
                                              java.io.IOException
Return a private key generated for a specific provider.
Parameters:
key - the name of the key we want.
provider - the name of the provider we want to use.
Returns:
the PrivateKey object representing that key.
Throws:
java.security.KeyException - a problem occured reading the key.

readPublicKey

public au.net.aba.pgp.PublicKeyCertificatePacket readPublicKey(java.lang.String key)
                                                        throws java.io.IOException
Read a public key certificate.

readSecretKey

public au.net.aba.pgp.SecretKeyCertificatePacket readSecretKey(java.lang.String key)
                                                        throws java.io.IOException
Read a private key.

main

public static void main(java.lang.String[] arg)
                 throws java.io.IOException
Display a key in the given keyring as a dotted hexadecimal string as per the AsciiEncodedKeySpec.