Package org.ldaptive.ssl
Class KeyStoreUtils
- java.lang.Object
-
- org.ldaptive.ssl.KeyStoreUtils
-
public final class KeyStoreUtils extends java.lang.ObjectProvides utility methods for using aKeyStore.- Author:
- Middleware Services
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.security.KeyStore.EntrygetEntry(java.lang.String alias, java.security.KeyStore keystore, char[] password)Returns a keystore entry from the supplied keystore.static java.security.KeyStorenewInstance()Creates a newKeyStorewith the default keystore type and initializes it.static java.security.KeyStorenewInstance(char[] password)Creates a newKeyStorewith the default keystore type and initializes it.static java.security.KeyStorenewInstance(java.lang.String type)Creates a newKeyStoreand initializes it.static java.security.KeyStorenewInstance(java.lang.String type, char[] password)Creates a newKeyStoreand initializes it.static voidsetCertificateEntry(java.lang.String alias, java.security.KeyStore keystore, java.security.cert.Certificate... certs)Sets certificate entries on the supplied keystore.static voidsetEntry(java.lang.String alias, java.security.KeyStore.Entry entry, java.security.KeyStore keystore, char[] password)Sets a keystore entry on the supplied keystore.static voidsetKeyEntry(java.lang.String alias, java.security.KeyStore keystore, char[] password, java.security.Key key, java.security.cert.Certificate... certs)Sets a key entry on the supplied keystore.
-
-
-
Method Detail
-
newInstance
public static java.security.KeyStore newInstance() throws java.security.GeneralSecurityExceptionCreates a newKeyStorewith the default keystore type and initializes it.- Returns:
- initialized keystore
- Throws:
java.security.GeneralSecurityException- if the keystore cannot be initialized
-
newInstance
public static java.security.KeyStore newInstance(char[] password) throws java.security.GeneralSecurityExceptionCreates a newKeyStorewith the default keystore type and initializes it.- Parameters:
password- to protect the keystore- Returns:
- initialized keystore
- Throws:
java.security.GeneralSecurityException- if the keystore cannot be initialized
-
newInstance
public static java.security.KeyStore newInstance(java.lang.String type) throws java.security.GeneralSecurityExceptionCreates a newKeyStoreand initializes it.- Parameters:
type- of keystore instance- Returns:
- initialized keystore
- Throws:
java.security.GeneralSecurityException- if the keystore cannot be initialized
-
newInstance
public static java.security.KeyStore newInstance(java.lang.String type, char[] password) throws java.security.GeneralSecurityExceptionCreates a newKeyStoreand initializes it.- Parameters:
type- of keystore instancepassword- to protect the keystore- Returns:
- initialized keystore
- Throws:
java.security.GeneralSecurityException- if the keystore cannot be initialized
-
getEntry
public static java.security.KeyStore.Entry getEntry(java.lang.String alias, java.security.KeyStore keystore, char[] password) throws java.security.GeneralSecurityExceptionReturns a keystore entry from the supplied keystore.- Parameters:
alias- of the entry to returnkeystore- to read the entry frompassword- to access the keystore- Returns:
- keystore entry
- Throws:
java.security.GeneralSecurityException- if the keystore cannot be readjava.lang.IllegalArgumentException- if the alias does not exist
-
setEntry
public static void setEntry(java.lang.String alias, java.security.KeyStore.Entry entry, java.security.KeyStore keystore, char[] password) throws java.security.GeneralSecurityExceptionSets a keystore entry on the supplied keystore.- Parameters:
alias- of the supplied entryentry- to setkeystore- to set the entry onpassword- to protect the entry- Throws:
java.security.GeneralSecurityException- if the keystore cannot be modified
-
setKeyEntry
public static void setKeyEntry(java.lang.String alias, java.security.KeyStore keystore, char[] password, java.security.Key key, java.security.cert.Certificate... certs) throws java.security.GeneralSecurityExceptionSets a key entry on the supplied keystore.- Parameters:
alias- of the supplied keykeystore- to set the key onpassword- to protect the keykey- to setcerts- associated with the key- Throws:
java.security.GeneralSecurityException- if the keystore cannot be modified
-
setCertificateEntry
public static void setCertificateEntry(java.lang.String alias, java.security.KeyStore keystore, java.security.cert.Certificate... certs) throws java.security.GeneralSecurityExceptionSets 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) oncerts- to set- Throws:
java.security.GeneralSecurityException- if the keystore cannot be modified
-
-