Class CustomLoadingKeyManager
java.lang.Object
javax.net.ssl.X509ExtendedKeyManager
de.xima.fc.certificate.provider.internal.CustomLoadingKeyManager
- All Implemented Interfaces:
KeyManager, X509KeyManager
A custom implementation of X509ExtendedKeyManager that loads and manages X.509 certificates and their corresponding
private keys from a KeyStore.
This implementation provides: - Dynamic certificate loading from KeyStore - Caching of server aliases for improved performance - Support for X.509 certificate chains - Thread-safe operations
-
Constructor Summary
ConstructorsConstructorDescriptionCustomLoadingKeyManager(de.xima.fc.certificate.provider.internal.KeyStoreAccess keyStoreAccess, KeyStore ks) Constructs a new CustomLoadingKeyManager and loads certificates from the provided KeyStore backed by fc-certificate. -
Method Summary
Modifier and TypeMethodDescriptionchooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket) Chooses a client alias based on the given parameters.chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine) As this implementation does not use the SSLEngine parameter, it simply callschooseClientAlias(String[], Principal[], Socket)with a null socket.chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) Chooses a server alias based on the given parameters.chooseServerAlias(String keyType, Principal[] issuers, Socket socket) Chooses a server alias based on the given parameters.getCertificateChain(String alias) Returns the certificate chain for the specified alias.String[]getClientAliases(String keyType, Principal[] issuers) Returns the client aliases for a specific key type and set of issuers.getPrivateKey(String alias) Returns the private key for the specified alias.String[]getServerAliases(String keyType, Principal[] issuers) Returns the server aliases for a specific key type and set of issuers.
-
Constructor Details
-
CustomLoadingKeyManager
public CustomLoadingKeyManager(de.xima.fc.certificate.provider.internal.KeyStoreAccess keyStoreAccess, KeyStore ks) throws KeyStoreException Constructs a new CustomLoadingKeyManager and loads certificates from the provided KeyStore backed by fc-certificate.- Parameters:
keyStoreAccess- interface for accessing private keys from the fc-certificate backed KeyStoreks- the KeyStore containing the certificates and private keys- Throws:
KeyStoreException- if there's an error accessing the KeyStore
-
-
Method Details
-
getClientAliases
Returns the client aliases for a specific key type and set of issuers.- Parameters:
keyType- the type of key (e.g., "RSA", "DSA")issuers- the acceptable certificate issuers, or null if any issuer is allowed- Returns:
- an array of matching alias names, or null if none match
-
chooseClientAlias
Chooses a client alias based on the given parameters. Returns the FIRST(!) matching alias for the specified key types and issuers.- Parameters:
keyTypes- array of key types to choose fromissuers- acceptable certificate issuers, or null if any issuer is allowedsocket- this implementation ignores the socket parameter as it does not affect alias selection- Returns:
- the chosen alias, or null if no matching alias exists
-
chooseEngineClientAlias
As this implementation does not use the SSLEngine parameter, it simply callschooseClientAlias(String[], Principal[], Socket)with a null socket. This allows the implementation to select an alias applicable to any engine.- Overrides:
chooseEngineClientAliasin classX509ExtendedKeyManager- Parameters:
keyType- the key algorithm type name(s), ordered with the most-preferred key type first.issuers- the list of acceptable CA issuer subject names or null if it does not matter which issuers are used.engine- This implementation does not use it for alias selection.- Returns:
- the chosen alias, or null if no matching alias exists
-
getServerAliases
Returns the server aliases for a specific key type and set of issuers.- Parameters:
keyType- the key algorithm type nameissuers- the list of acceptable CA issuer subject names or null if it does not matter which issuers are used.- Returns:
- an array of matching alias names, or null if none match
-
chooseServerAlias
Chooses a server alias based on the given parameters.- Parameters:
keyType- the key algorithm type name.issuers- the list of acceptable CA issuer subject names or null if it does not matter which issuers are used.socket- this implementation does not use the socket parameter as it does not affect alias selection.- Returns:
- the chosen alias, or null if no matching alias exists
-
chooseEngineServerAlias
Chooses a server alias based on the given parameters. This implementation does not use the SSLEngine parameter, so it simply callschooseServerAlias(String, Principal[], Socket)with a null socket.- Overrides:
chooseEngineServerAliasin classX509ExtendedKeyManager- Parameters:
keyType- the key algorithm type name.issuers- the list of acceptable CA issuer subject names or null if it does not matter which issuers are used.engine- This implementation does not use it for alias selection.- Returns:
- the chosen alias, or null if no matching alias exists
-
getCertificateChain
Returns the certificate chain for the specified alias.- Parameters:
alias- the alias of the certificate- Returns:
- an array of X509Certificates representing the certificate chain, or null if the alias is null or does not exist
-
getPrivateKey
Returns the private key for the specified alias.- Parameters:
alias- the alias of the private key- Returns:
- the PrivateKey associated with the alias, or null if the alias is null or does not exist
-