Package com.unboundid.util.ssl
Class WrapperKeyManager
java.lang.Object
javax.net.ssl.X509ExtendedKeyManager
com.unboundid.util.ssl.WrapperKeyManager
- All Implemented Interfaces:
KeyManager,X509KeyManager
- Direct Known Subclasses:
KeyStoreKeyManager,PKCS11KeyManager
@NotExtensible
@ThreadSafety(level=INTERFACE_THREADSAFE)
public abstract class WrapperKeyManager
extends X509ExtendedKeyManager
This class provides an SSL key manager that may be used to wrap a provided
set of key managers. It provides the ability to select the desired
certificate based on a given nickname.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWrapperKeyManager(KeyManager[] keyManagers, String certificateAlias) Creates a new instance of this wrapper key manager with the provided information.protectedWrapperKeyManager(X509KeyManager[] keyManagers, String certificateAlias) Creates a new instance of this wrapper key manager with the provided information. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringchooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) Retrieves the nickname of the certificate that a client should use to authenticate to a server.final StringchooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine) Retrieves the nickname of the certificate that a client should use to authenticate to a server.final StringchooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) Retrieves the nickname of the certificate that a server should use to authenticate to a client.final StringchooseServerAlias(String keyType, Principal[] issuers, Socket socket) Retrieves the nickname of the certificate that a server should use to authenticate to a client.Retrieves the nickname of the certificate that should be selected.final X509Certificate[]getCertificateChain(String alias) Retrieves the certificate chain for the certificate with the given nickname.final String[]getClientAliases(String keyType, Principal[] issuers) Retrieves the nicknames of the client certificates of the specified type contained in the key store.final PrivateKeygetPrivateKey(String alias) Retrieves the private key for the specified certificate.final String[]getServerAliases(String keyType, Principal[] issuers) Retrieves the nicknames of the server certificates of the specified type contained in the key store.
-
Constructor Details
-
WrapperKeyManager
Creates a new instance of this wrapper key manager with the provided information.- Parameters:
keyManagers- The set of key managers to be wrapped. It must not benullor empty, and it must contain only X509KeyManager instances.certificateAlias- The nickname of the certificate that should be selected. It may benullif any acceptable certificate found may be used.
-
WrapperKeyManager
protected WrapperKeyManager(@NotNull X509KeyManager[] keyManagers, @Nullable String certificateAlias) Creates a new instance of this wrapper key manager with the provided information.- Parameters:
keyManagers- The set of key managers to be wrapped. It must not benullor empty.certificateAlias- The nickname of the certificate that should be selected. It may benullif any acceptable certificate found may be used.
-
-
Method Details
-
getCertificateAlias
Retrieves the nickname of the certificate that should be selected.- Returns:
- The nickname of the certificate that should be selected, or
nullif any acceptable certificate found in the key store may be used.
-
getClientAliases
@Nullable public final String[] getClientAliases(@NotNull String keyType, @Nullable Principal[] issuers) Retrieves the nicknames of the client certificates of the specified type contained in the key store.- Parameters:
keyType- The key algorithm name for which to retrieve the available certificate nicknames.issuers- The list of acceptable issuer certificate subjects. It may benullif any issuer may be used.- Returns:
- The nicknames of the client certificates, or
nullif none were found in the key store.
-
chooseClientAlias
@Nullable public final String chooseClientAlias(@NotNull String[] keyType, @Nullable Principal[] issuers, @Nullable Socket socket) Retrieves the nickname of the certificate that a client should use to authenticate to a server.- Parameters:
keyType- The list of key algorithm names that may be used.issuers- The list of acceptable issuer certificate subjects. It may benullif any issuer may be used.socket- The socket to be used. It may benullif the certificate may be for any socket.- Returns:
- The nickname of the certificate to use, or
nullif no appropriate certificate is found.
-
chooseEngineClientAlias
@Nullable public final String chooseEngineClientAlias(@NotNull String[] keyType, @Nullable Principal[] issuers, @Nullable SSLEngine engine) Retrieves the nickname of the certificate that a client should use to authenticate to a server.- Overrides:
chooseEngineClientAliasin classX509ExtendedKeyManager- Parameters:
keyType- The list of key algorithm names that may be used.issuers- The list of acceptable issuer certificate subjects. It may benullif any issuer may be used.engine- The SSL engine to be used. It may benullif the certificate may be for any engine.- Returns:
- The nickname of the certificate to use, or
nullif no appropriate certificate is found.
-
getServerAliases
@Nullable public final String[] getServerAliases(@NotNull String keyType, @Nullable Principal[] issuers) Retrieves the nicknames of the server certificates of the specified type contained in the key store.- Parameters:
keyType- The key algorithm name for which to retrieve the available certificate nicknames.issuers- The list of acceptable issuer certificate subjects. It may benullif any issuer may be used.- Returns:
- The nicknames of the server certificates, or
nullif none were found in the key store.
-
chooseServerAlias
@Nullable public final String chooseServerAlias(@NotNull String keyType, @Nullable Principal[] issuers, @Nullable Socket socket) Retrieves the nickname of the certificate that a server should use to authenticate to a client.- Parameters:
keyType- The key algorithm name that may be used.issuers- The list of acceptable issuer certificate subjects. It may benullif any issuer may be used.socket- The socket to be used. It may benullif the certificate may be for any socket.- Returns:
- The nickname of the certificate to use, or
nullif no appropriate certificate is found.
-
chooseEngineServerAlias
@Nullable public final String chooseEngineServerAlias(@NotNull String keyType, @Nullable Principal[] issuers, @Nullable SSLEngine engine) Retrieves the nickname of the certificate that a server should use to authenticate to a client.- Overrides:
chooseEngineServerAliasin classX509ExtendedKeyManager- Parameters:
keyType- The key algorithm name that may be used.issuers- The list of acceptable issuer certificate subjects. It may benullif any issuer may be used.engine- The SSL engine to be used. It may benullif the certificate may be for any engine.- Returns:
- The nickname of the certificate to use, or
nullif no appropriate certificate is found.
-
getCertificateChain
Retrieves the certificate chain for the certificate with the given nickname.- Parameters:
alias- The nickname of the certificate for which to retrieve the certificate chain.- Returns:
- The certificate chain for the certificate with the given nickname,
or
nullif the requested certificate cannot be found.
-
getPrivateKey
Retrieves the private key for the specified certificate.- Parameters:
alias- The nickname of the certificate for which to retrieve the private key.- Returns:
- The private key for the requested certificate, or
nullif the requested certificate cannot be found.
-