public final class KeyManagerUtils extends 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 KeyManager |
createClientKeyManager(File storePath,
String storePass)
Create a client key manager which returns a particular key.
|
static KeyManager |
createClientKeyManager(File storePath,
String storePass,
String keyAlias)
Create a client key manager which returns a particular key.
|
static KeyManager |
createClientKeyManager(KeyStore ks,
String keyAlias,
String keyPass)
Create a client key manager which returns a particular key.
|
static KeyManager |
createClientKeyManager(String storeType,
File storePath,
String storePass,
String keyAlias,
String keyPass)
Create a client key manager which returns a particular key.
|
public static KeyManager createClientKeyManager(KeyStore ks, String keyAlias, String keyPass) throws 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 useGeneralSecurityException
- if there is a problem creating the keystorepublic static KeyManager createClientKeyManager(String storeType, File storePath, String storePass, String keyAlias, String keyPass) throws IOException, 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 useGeneralSecurityException
- if there is a problem creating the keystoreIOException
- if there is a problem creating the keystorepublic static KeyManager createClientKeyManager(File storePath, String storePass, String keyAlias) throws IOException, 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 usedIOException
- if there is a problem creating the keystoreGeneralSecurityException
- if there is a problem creating the keystorepublic static KeyManager createClientKeyManager(File storePath, String storePass) throws IOException, GeneralSecurityException
storePath
- the path to the keyStorestorePass
- the keyStore passwordIOException
- if there is a problem creating the keystoreGeneralSecurityException
- if there is a problem creating the keystoreCopyright © 2001–2017 The Apache Software Foundation. All rights reserved.