public final class KeyStoreUtils
extends java.lang.Object
KeyStore.| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
DEFAULT_TYPE
Default keystore type.
|
| Modifier | Constructor and Description |
|---|---|
private |
KeyStoreUtils()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static java.security.KeyStore.Entry |
getEntry(java.lang.String alias,
java.security.KeyStore keystore,
char[] password)
Returns a keystore entry from the supplied keystore.
|
static java.security.KeyStore |
newInstance()
Creates a new
KeyStore with the default keystore type and initializes it. |
static java.security.KeyStore |
newInstance(char[] password)
Creates a new
KeyStore with the default keystore type and initializes it. |
static java.security.KeyStore |
newInstance(java.lang.String type)
Creates a new
KeyStore and initializes it. |
static java.security.KeyStore |
newInstance(java.lang.String type,
char[] password)
Creates a new
KeyStore and initializes it. |
static void |
setCertificateEntry(java.lang.String alias,
java.security.KeyStore keystore,
java.security.cert.Certificate... certs)
Sets certificate entries on the supplied keystore.
|
static void |
setEntry(java.lang.String alias,
java.security.KeyStore.Entry entry,
java.security.KeyStore keystore,
char[] password)
Sets a keystore entry on the supplied keystore.
|
static void |
setKeyEntry(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.
|
public static java.security.KeyStore newInstance()
throws java.security.GeneralSecurityException
KeyStore with the default keystore type and initializes it.java.security.GeneralSecurityException - if the keystore cannot be initializedpublic static java.security.KeyStore newInstance(char[] password)
throws java.security.GeneralSecurityException
KeyStore with the default keystore type and initializes it.password - to protect the keystorejava.security.GeneralSecurityException - if the keystore cannot be initializedpublic static java.security.KeyStore newInstance(java.lang.String type)
throws java.security.GeneralSecurityException
KeyStore and initializes it.type - of keystore instancejava.security.GeneralSecurityException - if the keystore cannot be initializedpublic static java.security.KeyStore newInstance(java.lang.String type,
char[] password)
throws java.security.GeneralSecurityException
KeyStore and initializes it.type - of keystore instancepassword - to protect the keystorejava.security.GeneralSecurityException - if the keystore cannot be initializedpublic static java.security.KeyStore.Entry getEntry(java.lang.String alias,
java.security.KeyStore keystore,
char[] password)
throws java.security.GeneralSecurityException
alias - of the entry to returnkeystore - to read the entry frompassword - to access the keystorejava.security.GeneralSecurityException - if the keystore cannot be readjava.lang.IllegalArgumentException - if the alias does not existpublic static void setEntry(java.lang.String alias,
java.security.KeyStore.Entry entry,
java.security.KeyStore keystore,
char[] password)
throws java.security.GeneralSecurityException
alias - of the supplied entryentry - to setkeystore - to set the entry onpassword - to protect the entryjava.security.GeneralSecurityException - if the keystore cannot be modifiedpublic 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.GeneralSecurityException
alias - of the supplied keykeystore - to set the key onpassword - to protect the keykey - to setcerts - associated with the keyjava.security.GeneralSecurityException - if the keystore cannot be modifiedpublic static void setCertificateEntry(java.lang.String alias,
java.security.KeyStore keystore,
java.security.cert.Certificate... certs)
throws java.security.GeneralSecurityException
alias - of the supplied certificate(s)keystore - to set the cert(s) oncerts - to setjava.security.GeneralSecurityException - if the keystore cannot be modified