JXTA

net.jxta.impl.membership.pse
Class CMKeyStoreManager

java.lang.Object
  extended by net.jxta.impl.membership.pse.CMKeyStoreManager
All Implemented Interfaces:
KeyStoreManager

public class CMKeyStoreManager
extends Object
implements KeyStoreManager

Manages a Keystore located within the JXTA CM.


Constructor Summary
CMKeyStoreManager(String type, String provider, PeerGroup group, ID location)
          Default constructor.
 
Method Summary
 void createKeyStore(char[] store_password)
          Create the KeyStore using the specified KeyStore passphrase.
 void eraseKeyStore()
          Erase the KeyStore.
 boolean isInitialized()
          Returns true if the KeyStore has been initialized (created).
 boolean isInitialized(char[] store_password)
          Returns true if the Keystore has been initialized (created).
 KeyStore loadKeyStore(char[] password)
          Load the KeyStore.
 void saveKeyStore(KeyStore store, char[] password)
          Save the provided KeyStore using the specified KeyStore passphrase.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CMKeyStoreManager

public CMKeyStoreManager(String type,
                         String provider,
                         PeerGroup group,
                         ID location)
                  throws NoSuchProviderException,
                         KeyStoreException
Default constructor.

Parameters:
type - The keystore type to use. The current default is the "JKS" keystore which is specified via null.
provider - The JCE cryptographic provider to use for the keystore. May also be null for the default provider.
group - The peer group which will provide the CM.
location - The ID under which the keystore will be stored in the CM.
Throws:
NoSuchProviderException - Thrown if the requested provider is not available.
KeyStoreException - Thrown for errors getting a keystore of the requested type.
Method Detail

isInitialized

public boolean isInitialized()
Returns true if the KeyStore has been initialized (created). Since this method does not provide a passphrase it is really only useful for determining if a new KeyStore needs to be created.

Specified by:
isInitialized in interface KeyStoreManager
Returns:
true if the KeyStore has been previously initialized otherwise false.

isInitialized

public boolean isInitialized(char[] store_password)
Returns true if the Keystore has been initialized (created). This method also ensures that the provided passphrase is valid for the keystore.

Specified by:
isInitialized in interface KeyStoreManager
Parameters:
store_password - The KeyStore passphrase.
Returns:
true if the Keystore has been initialized otherwise false.

createKeyStore

public void createKeyStore(char[] store_password)
                    throws KeyStoreException,
                           IOException
Create the KeyStore using the specified KeyStore passphrase.

Specified by:
createKeyStore in interface KeyStoreManager
Parameters:
store_password - The KeyStore passphrase.
Throws:
KeyStoreException - If an incorrect KeyStore passphrase is provided.
IOException - If there is a problem creating the KeyStore.

loadKeyStore

public KeyStore loadKeyStore(char[] password)
                      throws KeyStoreException,
                             IOException
Load the KeyStore.

Specified by:
loadKeyStore in interface KeyStoreManager
Parameters:
password - The KeyStore passphrase.
Returns:
the keystore
Throws:
KeyStoreException - If an incorrect KeyStore password is provided.
IOException - If there is a problem loading the KeyStore.

saveKeyStore

public void saveKeyStore(KeyStore store,
                         char[] password)
                  throws IOException,
                         KeyStoreException
Save the provided KeyStore using the specified KeyStore passphrase.

Specified by:
saveKeyStore in interface KeyStoreManager
Parameters:
store - The KeyStore to save.
password - The encryption passphrase for the keystore.
Throws:
IOException - Thrown for errors writing the keystore.
KeyStoreException - Thrown for errors with the provided key or key store.

eraseKeyStore

public void eraseKeyStore()
                   throws IOException
Erase the KeyStore. Some KeyStore implementations may not allow the KeyStore container itself to be erased and in some cases specific certificates and keys may be unerasable. All implementations should erase all user provided certificates and keys.

Specified by:
eraseKeyStore in interface KeyStoreManager
Throws:
IOException - If there is a problem erasing the KeyStore or the KeyStore cannot be erased.

toString

public String toString()

Overrides:
toString in class Object

JXSE