public final class KeyManagerUtils
extends java.lang.Object
How to use with a client certificate:
KeyManager km = KeyManagerUtils.createClientKeyManager("JKS",
"/path/to/privatekeystore.jks","storepassword",
"privatekeyalias", "keypassword");
FTPSClient cl = new FTPSClient();
cl.setKeyManager(km);
cl.connect(...);
If using the default store type and the key password is the same as the
store password, these parameters can be omitted.
KeyManager km = KeyManagerUtils.createClientKeyManager(
"/path/to/privatekeystore.jks","storepassword");
FTPSClient cl = new FTPSClient();
cl.setKeyManager(km);
cl.connect(...);
| Modifier and Type | Method and Description |
|---|---|
static javax.net.ssl.KeyManager |
createClientKeyManager(java.io.File storePath,
java.lang.String storePass)
Create a client key manager which returns a particular key.
|
static javax.net.ssl.KeyManager |
createClientKeyManager(java.io.File storePath,
java.lang.String storePass,
java.lang.String keyAlias)
Create a client key manager which returns a particular key.
|
static javax.net.ssl.KeyManager |
createClientKeyManager(java.security.KeyStore ks,
java.lang.String keyAlias,
java.lang.String keyPass)
Create a client key manager which returns a particular key.
|
static javax.net.ssl.KeyManager |
createClientKeyManager(java.lang.String storeType,
java.io.File storePath,
java.lang.String storePass,
java.lang.String keyAlias,
java.lang.String keyPass)
Create a client key manager which returns a particular key.
|
public static javax.net.ssl.KeyManager createClientKeyManager(java.security.KeyStore ks,
java.lang.String keyAlias,
java.lang.String keyPass)
throws java.security.GeneralSecurityException
ks - the keystore to usekeyAlias - the alias of the key to use, may be null in which case the first key entry alias is usedkeyPass - the password of the key to usejava.security.GeneralSecurityException - if there is a problem creating the keystorepublic static javax.net.ssl.KeyManager createClientKeyManager(java.lang.String storeType,
java.io.File storePath,
java.lang.String storePass,
java.lang.String keyAlias,
java.lang.String keyPass)
throws java.io.IOException,
java.security.GeneralSecurityException
storeType - the type of the keyStore, e.g. "JKS"storePath - the path to the keyStorestorePass - the keyStore passwordkeyAlias - the alias of the key to use, may be null in which case the first key entry alias is usedkeyPass - the password of the key to usejava.security.GeneralSecurityException - if there is a problem creating the keystorejava.io.IOException - if there is a problem creating the keystorepublic static javax.net.ssl.KeyManager createClientKeyManager(java.io.File storePath,
java.lang.String storePass,
java.lang.String keyAlias)
throws java.io.IOException,
java.security.GeneralSecurityException
storePath - the path to the keyStorestorePass - the keyStore passwordkeyAlias - the alias of the key to use, may be null in which case the first key entry alias is usedjava.io.IOException - if there is a problem creating the keystorejava.security.GeneralSecurityException - if there is a problem creating the keystorepublic static javax.net.ssl.KeyManager createClientKeyManager(java.io.File storePath,
java.lang.String storePass)
throws java.io.IOException,
java.security.GeneralSecurityException
storePath - the path to the keyStorestorePass - the keyStore passwordjava.io.IOException - if there is a problem creating the keystorejava.security.GeneralSecurityException - if there is a problem creating the keystore