goldengate.common.crypto.ssl
Class GgSecureKeyStore

java.lang.Object
  extended by goldengate.common.crypto.ssl.GgSecureKeyStore

public class GgSecureKeyStore
extends Object

SecureKeyStore for SLL

Author:
Frederic Bregier

Constructor Summary
GgSecureKeyStore(String _keyStorePasswd, String _keyPassword)
          Initialize empty KeyStore.
GgSecureKeyStore(String keyStoreFilename, String _keyStorePasswd, String _keyPassword)
          Initialize the SecureKeyStore with no TrustStore from file
GgSecureKeyStore(String keyStoreFilename, String _keyStorePasswd, String _keyPassword, String trustStoreFilename, String _trustStorePasswd, boolean needClientAuthent)
          Initialize the SecureKeyStore and TrustStore from files
 
Method Summary
 boolean deleteKeyFromKeyStore(String alias)
          Delete a Key from the KeyStore based on its alias
 boolean deleteKeyFromTrustStore(String alias)
          Delete a Key from the TrustStore based on its alias
 char[] getCertificatePassword()
           
 KeyManagerFactory getKeyManagerFactory()
           
 char[] getKeyStorePassword()
           
 char[] getKeyTrustStorePassword()
           
 GgSecureTrustManagerFactory getSecureTrustManagerFactory()
           
 boolean initEmptyTrustStore()
          Initialize an empty TrustStore
 void initKeyStore(String keyStoreFilename, String _keyStorePasswd, String _keyPassword)
          Initialize the SecureKeyStore with no TrustStore from file
 void initTrustStore(String trustStoreFilename, String _trustStorePasswd, boolean needClientAuthent)
          Initialize the TrustStore from a filename and its password
static Certificate loadX509Certificate(String filename)
          Load a certificate from a filename
 boolean saveKeyStore(String filename)
          Save a KeyStore to a file
 boolean saveTrustStore(String filename)
          Save the TrustStore to a file
 boolean setKeytoKeyStore(String alias, Key key, Certificate[] chain)
          Add a Key and its certificates into the KeyStore based on its alias
 boolean setKeytoTrustStore(String alias, Certificate cert)
          Add a Certificate into the TrustStore based on its alias
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GgSecureKeyStore

public GgSecureKeyStore(String _keyStorePasswd,
                        String _keyPassword)
                 throws CryptoException
Initialize empty KeyStore. No TrustStore is internally created.

Parameters:
_keyStorePasswd -
_keyPassword -
Throws:
CryptoException

GgSecureKeyStore

public GgSecureKeyStore(String keyStoreFilename,
                        String _keyStorePasswd,
                        String _keyPassword)
                 throws CryptoException
Initialize the SecureKeyStore with no TrustStore from file

Parameters:
keyStoreFilename -
_keyStorePasswd -
_keyPassword -
Throws:
CryptoException

GgSecureKeyStore

public GgSecureKeyStore(String keyStoreFilename,
                        String _keyStorePasswd,
                        String _keyPassword,
                        String trustStoreFilename,
                        String _trustStorePasswd,
                        boolean needClientAuthent)
                 throws CryptoException
Initialize the SecureKeyStore and TrustStore from files

Parameters:
keyStoreFilename -
_keyStorePasswd -
_keyPassword -
trustStoreFilename - if Null, no TrustKeyStore will be created
_trustStorePasswd -
needClientAuthent - True if the TrustStore is also used for Client Authentication
Throws:
CryptoException
Method Detail

initKeyStore

public void initKeyStore(String keyStoreFilename,
                         String _keyStorePasswd,
                         String _keyPassword)
                  throws CryptoException
Initialize the SecureKeyStore with no TrustStore from file

Parameters:
keyStoreFilename -
_keyStorePasswd -
_keyPassword -
Throws:
CryptoException

deleteKeyFromKeyStore

public boolean deleteKeyFromKeyStore(String alias)
Delete a Key from the KeyStore based on its alias

Parameters:
alias -
Returns:
True if entry is deleted

setKeytoKeyStore

public boolean setKeytoKeyStore(String alias,
                                Key key,
                                Certificate[] chain)
Add a Key and its certificates into the KeyStore based on its alias

Parameters:
alias -
key -
chain -
Returns:
True if entry is added

saveKeyStore

public boolean saveKeyStore(String filename)
Save a KeyStore to a file

Parameters:
filename -
Returns:
True if keyStore is saved to file

initTrustStore

public void initTrustStore(String trustStoreFilename,
                           String _trustStorePasswd,
                           boolean needClientAuthent)
                    throws CryptoException
Initialize the TrustStore from a filename and its password

Parameters:
trustStoreFilename -
_trustStorePasswd -
needClientAuthent - True if the TrustStore is also to authenticate clients
Throws:
CryptoException

initEmptyTrustStore

public boolean initEmptyTrustStore()
Initialize an empty TrustStore

Returns:
True if correctly initialized empty

deleteKeyFromTrustStore

public boolean deleteKeyFromTrustStore(String alias)
Delete a Key from the TrustStore based on its alias

Parameters:
alias -
Returns:
True if entry is deleted

setKeytoTrustStore

public boolean setKeytoTrustStore(String alias,
                                  Certificate cert)
Add a Certificate into the TrustStore based on its alias

Parameters:
alias -
cert -
Returns:
True if entry is added

saveTrustStore

public boolean saveTrustStore(String filename)
Save the TrustStore to a file

Parameters:
filename -
Returns:
True if keyTrustStore is saved to file

loadX509Certificate

public static Certificate loadX509Certificate(String filename)
                                       throws CertificateException,
                                              FileNotFoundException
Load a certificate from a filename

Parameters:
filename -
Returns:
the X509 Certificate from filename
Throws:
CertificateException
FileNotFoundException

getCertificatePassword

public char[] getCertificatePassword()
Returns:
the certificate Password

getKeyStorePassword

public char[] getKeyStorePassword()
Returns:
the KeyStore Password

getKeyTrustStorePassword

public char[] getKeyTrustStorePassword()
Returns:
the KeyTrustStore Password

getSecureTrustManagerFactory

public GgSecureTrustManagerFactory getSecureTrustManagerFactory()
Returns:
the secureTrustManagerFactory

getKeyManagerFactory

public KeyManagerFactory getKeyManagerFactory()
Returns:
the keyManagerFactory


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.