java.lang.Object
de.cuioss.tools.net.ssl.KeyStoreProvider
- All Implemented Interfaces:
Serializable
Provides instances of
KeyStore defined by either given file /
storePassword combination or one or more KeyMaterialHolder containing
key-material as a byte-array.
Some words on the String-representation of passwords
No it is not (much) more secure to store them in a char[] because of not being part of the string-pool:- If an attacker is on your machine debugging the string-pool you are doomed anyway.
- In most frameworks / user-land code there are some places where input / configuration data is represented as String on the way to the more secure "give me a char[]" parts. So it is usually in the String pool anyway.
So: In theory the statements made by the Java Cryptography Architecture guide ("...") are correct but in our scenarios they will increase security only a small amount and introduce potential bugs and will therefore be ignored for this keyStoreType.
It is more important to avoid accidental printing on logs and such, what is handled by this keyStoreType.
Therefore, this class uses String-based handling of credentials, for simplification and provide shortcuts for creating char[], seegetStorePasswordAsCharArray() and
getKeyPasswordAsCharArray()- Author:
- Oliver Wolff, Nikola Marijan
- See Also:
-
Constructor Details
-
KeyStoreProvider
public KeyStoreProvider()
-
-
Method Details
-
resolveKeyStore
Instantiates aKeyStoreaccording to the given parameter. In case of#getKeys()and#getLocation()being present theKeyStorewill only be created from the#getKeys(). The file will be ignored.- Returns:
- an
Optionalon aKeyStorecreated from the configured parameter. In case of#getKeysand#getLocation()beingnull/ empty it will returnOptional.empty() - Throws:
IllegalStateException- in case the location-file is not null but not readable or of the key-store creation did fail.
-
getStorePasswordAsCharArray
- Returns:
- NPE-safe char-array representation of
#getStorePassword(). If storePassword isnullor empty it returns an empty char[], nevernull
-
getKeyPasswordAsCharArray
- Returns:
- NPE-safe char-array representation of
#getKeyPassword(). If keyPassword isnullor empty it returns an empty char[], nevernull
-
getKeyOrStorePassword
In case of accessing data on theKeyStoresometimes it is needed to access the defined key-password. If not present the api needs the store-password instead. This is method is a convenience method for dealing with that case.- Returns:
- the keyPassword, if set or the store-password otherwise
-