public final class KeyManagers extends Object
Modifier and Type | Method and Description |
---|---|
static X509KeyManager |
useJvmDefaultKeyStore()
Creates a new
X509KeyManager which will use the JVM's default keystore for retrieving certificates. |
static X509KeyManager |
useKeyStoreFile(String file)
Creates a new
X509KeyManager which will use the named key store
file for retrieving certificates. |
static X509KeyManager |
useKeyStoreFile(String file,
char[] password,
String format)
Creates a new
X509KeyManager which will use the named key store
file for retrieving certificates. |
static X509KeyManager |
useKeyStoreFile(String keyStoreFile,
char[] password,
String format,
String provider)
Creates a new
X509KeyManager which will use the named key store
file for retrieving certificates. |
static X509KeyManager |
usePKCS11Token(char[] password)
Creates a new
X509KeyManager which will use a PKCS#11 token for
retrieving certificates. |
static X509KeyManager |
useSingleCertificate(String alias,
X509KeyManager keyManager)
Returns a new
X509KeyManager which selects the named certificate
from the provided X509KeyManager . |
public static X509KeyManager useKeyStoreFile(String file) throws GeneralSecurityException, IOException
X509KeyManager
which will use the named key store
file for retrieving certificates. It will use the default key store
format for the JVM (e.g. JKS
) and will not use a password to open
the key store.file
- The key store file name.X509KeyManager
which will use the named key store
file for retrieving certificates.GeneralSecurityException
- If the key store could not be loaded, perhaps due to
incorrect format, or missing algorithms.IOException
- If the key store file could not be found or could not be
read.NullPointerException
- If file
was null
.public static X509KeyManager useKeyStoreFile(String file, char[] password, String format) throws GeneralSecurityException, IOException
X509KeyManager
which will use the named key store
file for retrieving certificates. It will use the provided key store
format and password.file
- The key store file name.password
- The key store password, which may be null
.format
- The key store format, which may be null
to indicate
that the default key store format for the JVM (e.g.
JKS
) should be used.X509KeyManager
which will use the named key store
file for retrieving certificates.GeneralSecurityException
- If the key store could not be loaded, perhaps due to
incorrect format, or missing algorithms.IOException
- If the key store file could not be found or could not be
read.NullPointerException
- If file
was null
.public static X509KeyManager useKeyStoreFile(String keyStoreFile, char[] password, String format, String provider) throws GeneralSecurityException, IOException
X509KeyManager
which will use the named key store
file for retrieving certificates. It will use the provided key store
format and password.keyStoreFile
- The key store file name.password
- The key store password, which may be null
.format
- The key store format, which may be null
to indicate that the default key store format for the
JVM (e.g. JKS
) should be used.provider
- The key store provider, which may be null
to indicate that the default key store provider for
the JVM should be used.X509KeyManager
which will use the named key store file for retrieving certificates.GeneralSecurityException
- If the key store could not be loaded, perhaps due to incorrect format, or missing algorithms.IOException
- If the key store file could not be found or could not be read.NullPointerException
- If file
was null
.public static X509KeyManager usePKCS11Token(char[] password) throws GeneralSecurityException, IOException
X509KeyManager
which will use a PKCS#11 token for
retrieving certificates.password
- The password to use for accessing the PKCS#11 token, which may
be null
if no password is required.X509KeyManager
which will use a PKCS#11 token for
retrieving certificates.GeneralSecurityException
- If the PKCS#11 token could not be accessed, perhaps due to
incorrect password, or missing algorithms.IOException
- If the PKCS#11 token could not be found or could not be read.public static X509KeyManager useJvmDefaultKeyStore() throws GeneralSecurityException, IOException
X509KeyManager
which will use the JVM's default keystore for retrieving certificates.X509KeyManager
which will use the JVM's default keystore for retrieving certificates or
null
if the necessary JVM settings are missing.GeneralSecurityException
- If the key store could not be loaded, perhaps due to incorrect format, or missing algorithms.IOException
- If the key store file could not be found or could not be read.public static X509KeyManager useSingleCertificate(String alias, X509KeyManager keyManager)
X509KeyManager
which selects the named certificate
from the provided X509KeyManager
.alias
- The nickname of the certificate that should be selected for
operations involving this key manager.keyManager
- The key manager to be filtered.NullPointerException
- If keyManager
or alias
was null
.Copyright 2010-2017 ForgeRock AS.