JXTA

net.jxta.impl.membership.pse
Class FileKeyStoreManager

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

public class FileKeyStoreManager
extends Object
implements KeyStoreManager

Manages a Keystore located within a single File.


Constructor Summary
FileKeyStoreManager(String type, String provider, File 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

FileKeyStoreManager

public FileKeyStoreManager(String type,
                           String provider,
                           File location)
                    throws NoSuchProviderException,
                           KeyStoreException
Default constructor.

Parameters:
type - keystore type
provider - the provider
location - Store location
Throws:
NoSuchProviderException - if the security provider requested is not available in the environment.
KeyStoreException - if a keystore error occurs
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 KeyStoreException,
                         IOException
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:
KeyStoreException - Thrown for errors with the provided key or key store.
IOException - Thrown for errors writing the keystore.

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