public final class CompositeX509ExtendedKeyManager extends X509ExtendedKeyManager
X509ExtendedKeyManager with most-preferred managers first.
This is necessary because of the fine-print on SSLContext.init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], java.security.SecureRandom):
Only the first instance of a particular key and/or key manager implementation type in the
array is used. (For example, only the first javax.net.ssl.X509KeyManager in the array will be used.)
The KeyManager can be build from one or more of any combination provided within the KeyManagerUtils.KeyManagerBuilder.
This includes:
- Any amount of custom KeyManagers
- Any amount of custom Identities
NOTE:
Please don't use this class directly as it is part of the internal API. Class name and methods can be changed any time.
Instead use the KeyManagerUtils which provides the same functionality
while it has a stable API because it is part of the public API.
| Constructor and Description |
|---|
CompositeX509ExtendedKeyManager(List<? extends X509ExtendedKeyManager> keyManagers)
Creates a new
CompositeX509ExtendedKeyManager. |
CompositeX509ExtendedKeyManager(List<? extends X509ExtendedKeyManager> keyManagers,
Map<String,List<URI>> preferredAliasToHost)
Creates a new
CompositeX509ExtendedKeyManager. |
| Modifier and Type | Method and Description |
|---|---|
default String |
chooseAlias(Supplier<String> preferredAliasSupplier,
Function<X509ExtendedKeyManager,String> aliasExtractor) |
String |
chooseClientAlias(String[] keyType,
Principal[] issuers,
Socket socket)
Chooses the first non-null client alias returned from the delegate
X509ExtendedKeyManager, or null if there are no matches. |
default <T> String |
chooseClientAlias(T object,
Predicate<T> predicate,
Function<T,Map.Entry<String,Integer>> hostToPortExtractor,
Function<X509ExtendedKeyManager,String> aliasExtractor) |
String |
chooseEngineClientAlias(String[] keyTypes,
Principal[] issuers,
SSLEngine sslEngine)
Chooses the first non-null client alias returned from the delegate
X509ExtendedKeyManager, or null if there are no matches. |
String |
chooseEngineServerAlias(String keyType,
Principal[] issuers,
SSLEngine sslEngine)
Chooses the first non-null server alias returned from the delegate
X509ExtendedKeyManager, or null if there are no matches. |
String |
chooseServerAlias(String keyType,
Principal[] issuers,
Socket socket)
Chooses the first non-null server alias returned from the delegate
X509ExtendedKeyManager, or null if there are no matches. |
default <T> String |
chooseServerAlias(T object,
Predicate<T> predicate,
Function<T,SSLSession> sslSessionExtractor,
Function<X509ExtendedKeyManager,String> aliasExtractor) |
default boolean |
containsInetSocketAddress(Socket socket) |
default Map.Entry<String,Integer> |
extractHostAndPort(Socket socket) |
default Map.Entry<String,Integer> |
extractHostAndPort(SSLEngine sslEngine) |
default <T> T |
extractInnerField(Function<X509ExtendedKeyManager,T> keyManagerMapper,
Predicate<T> predicate) |
default String[] |
getAliases(Function<X509ExtendedKeyManager,String[]> aliasExtractor) |
X509Certificate[] |
getCertificateChain(String alias)
Returns the first non-null certificate chain associated with the
given alias, or
null if the alias can't be found. |
String[] |
getClientAliases(String keyType,
Principal[] issuers)
Get all matching aliases for authenticating the client side of a
secure socket, or
null if there are no matches. |
Map<String,List<URI>> |
getIdentityRoute() |
List<X509ExtendedKeyManager> |
getKeyManagers() |
default String |
getPreferredClientAlias(String peerHost,
int peerPort) |
default <T> String |
getPreferredClientAlias(T object,
Predicate<T> predicate,
Function<T,Map.Entry<String,Integer>> hostToPortExtractor) |
default String |
getPreferredServerAlias(Set<String> hostnames) |
default <T> String |
getPreferredServerAlias(T object,
Predicate<T> predicate,
Function<T,SSLSession> sslSessionExtractor) |
PrivateKey |
getPrivateKey(String alias)
Returns the first non-null private key associated with the
given alias, or
null if the alias can't be found. |
String[] |
getServerAliases(String keyType,
Principal[] issuers)
Get all matching aliases for authenticating the server side of a
secure socket, or
null if there are no matches. |
public CompositeX509ExtendedKeyManager(List<? extends X509ExtendedKeyManager> keyManagers)
CompositeX509ExtendedKeyManager.keyManagers - the X509ExtendedKeyManager, ordered with the most-preferred managers first.public CompositeX509ExtendedKeyManager(List<? extends X509ExtendedKeyManager> keyManagers, Map<String,List<URI>> preferredAliasToHost)
CompositeX509ExtendedKeyManager.keyManagers - the X509ExtendedKeyManager, ordered with the most-preferred managers first.preferredAliasToHost - the preferred client alias to be used for the given hostpublic String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket)
X509ExtendedKeyManager, or null if there are no matches.chooseClientAlias in interface X509KeyManagerpublic String chooseEngineClientAlias(String[] keyTypes, Principal[] issuers, SSLEngine sslEngine)
X509ExtendedKeyManager, or null if there are no matches.chooseEngineClientAlias in class X509ExtendedKeyManagerpublic String chooseServerAlias(String keyType, Principal[] issuers, Socket socket)
X509ExtendedKeyManager, or null if there are no matches.chooseServerAlias in interface X509KeyManagerpublic String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine sslEngine)
X509ExtendedKeyManager, or null if there are no matches.chooseEngineServerAlias in class X509ExtendedKeyManagerpublic PrivateKey getPrivateKey(String alias)
null if the alias can't be found.getPrivateKey in interface X509KeyManagerpublic X509Certificate[] getCertificateChain(String alias)
null if the alias can't be found.getCertificateChain in interface X509KeyManagerpublic String[] getClientAliases(String keyType, Principal[] issuers)
null if there are no matches.getClientAliases in interface X509KeyManagerpublic String[] getServerAliases(String keyType, Principal[] issuers)
null if there are no matches.getServerAliases in interface X509KeyManagerpublic List<X509ExtendedKeyManager> getKeyManagers()
public <T> String chooseClientAlias(T object, Predicate<T> predicate, Function<T,Map.Entry<String,Integer>> hostToPortExtractor, Function<X509ExtendedKeyManager,String> aliasExtractor)
public <T> String getPreferredClientAlias(T object, Predicate<T> predicate, Function<T,Map.Entry<String,Integer>> hostToPortExtractor)
public <T> String chooseServerAlias(T object, Predicate<T> predicate, Function<T,SSLSession> sslSessionExtractor, Function<X509ExtendedKeyManager,String> aliasExtractor)
public <T> String getPreferredServerAlias(T object, Predicate<T> predicate, Function<T,SSLSession> sslSessionExtractor)
public String chooseAlias(Supplier<String> preferredAliasSupplier, Function<X509ExtendedKeyManager,String> aliasExtractor)
public boolean containsInetSocketAddress(Socket socket)
public <T> T extractInnerField(Function<X509ExtendedKeyManager,T> keyManagerMapper, Predicate<T> predicate)
public String[] getAliases(Function<X509ExtendedKeyManager,String[]> aliasExtractor)
Copyright © 2022. All rights reserved.