org.ldaptive.ssl
Class KeyStoreUtils

java.lang.Object
  extended by org.ldaptive.ssl.KeyStoreUtils

public final class KeyStoreUtils
extends Object

Provides utility methods for using a KeyStore.

Version:
$Revision: 2885 $ $Date: 2014-02-05 16:28:49 -0500 (Wed, 05 Feb 2014) $
Author:
Middleware Services

Method Summary
static KeyStore.Entry getEntry(String alias, KeyStore keystore, char[] password)
          Returns a keystore entry from the supplied keystore.
static KeyStore newInstance()
          Creates a new KeyStore with the default keystore type and initializes it.
static KeyStore newInstance(char[] password)
          Creates a new KeyStore with the default keystore type and initializes it.
static KeyStore newInstance(String type)
          Creates a new KeyStore and initializes it.
static KeyStore newInstance(String type, char[] password)
          Creates a new KeyStore and initializes it.
static void setCertificateEntry(String alias, KeyStore keystore, Certificate... certs)
          Sets certificate entries on the supplied keystore.
static void setEntry(String alias, KeyStore.Entry entry, KeyStore keystore, char[] password)
          Sets a keystore entry on the supplied keystore.
static void setKeyEntry(String alias, KeyStore keystore, char[] password, Key key, Certificate... certs)
          Sets a key entry on the supplied keystore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static KeyStore newInstance()
                            throws GeneralSecurityException
Creates a new KeyStore with the default keystore type and initializes it.

Returns:
initialized keystore
Throws:
GeneralSecurityException - if the keystore cannot be initialized

newInstance

public static KeyStore newInstance(char[] password)
                            throws GeneralSecurityException
Creates a new KeyStore with the default keystore type and initializes it.

Parameters:
password - to protect the keystore
Returns:
initialized keystore
Throws:
GeneralSecurityException - if the keystore cannot be initialized

newInstance

public static KeyStore newInstance(String type)
                            throws GeneralSecurityException
Creates a new KeyStore and initializes it.

Parameters:
type - of keystore instance
Returns:
initialized keystore
Throws:
GeneralSecurityException - if the keystore cannot be initialized

newInstance

public static KeyStore newInstance(String type,
                                   char[] password)
                            throws GeneralSecurityException
Creates a new KeyStore and initializes it.

Parameters:
type - of keystore instance
password - to protect the keystore
Returns:
initialized keystore
Throws:
GeneralSecurityException - if the keystore cannot be initialized

getEntry

public static KeyStore.Entry getEntry(String alias,
                                      KeyStore keystore,
                                      char[] password)
                               throws GeneralSecurityException
Returns a keystore entry from the supplied keystore.

Parameters:
alias - of the entry to return
keystore - to read the entry from
password - to access the keystore
Returns:
keystore entry
Throws:
GeneralSecurityException - if the keystore cannot be read
IllegalArgumentException - if the alias does not exist

setEntry

public static void setEntry(String alias,
                            KeyStore.Entry entry,
                            KeyStore keystore,
                            char[] password)
                     throws GeneralSecurityException
Sets a keystore entry on the supplied keystore.

Parameters:
alias - of the supplied entry
entry - to set
keystore - to set the entry on
password - to protect the entry
Throws:
GeneralSecurityException - if the keystore cannot be modified

setKeyEntry

public static void setKeyEntry(String alias,
                               KeyStore keystore,
                               char[] password,
                               Key key,
                               Certificate... certs)
                        throws GeneralSecurityException
Sets a key entry on the supplied keystore.

Parameters:
alias - of the supplied key
keystore - to set the key on
password - to protect the key
key - to set
certs - associated with the key
Throws:
GeneralSecurityException - if the keystore cannot be modified

setCertificateEntry

public static void setCertificateEntry(String alias,
                                       KeyStore keystore,
                                       Certificate... certs)
                                throws GeneralSecurityException
Sets certificate entries on the supplied keystore. For certificate arrays of size greater than 1, the alias is appended with an index.

Parameters:
alias - of the supplied certificate(s)
keystore - to set the cert(s) on
certs - to set
Throws:
GeneralSecurityException - if the keystore cannot be modified


Copyright © 2003-2015 Virginia Tech. All Rights Reserved.