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
public 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 useIOException
GeneralSecurityException
public 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
GeneralSecurityException
public static KeyManager createClientKeyManager(File storePath, String storePass) throws IOException, GeneralSecurityException
storePath
- the path to the keyStorestorePass
- the keyStore passwordIOException
GeneralSecurityException
Copyright © 2001-2016 The Apache Software Foundation. All Rights Reserved.