Class KeyStoreWrapper
java.lang.Object
de.captaingoldfish.scim.sdk.client.keys.KeyStoreWrapper
author Pascal Knueppel
created at: 09.12.2019 - 08:20
this class will be used to have the usage of a keystore wrapped in a single place. Means we will hold the password of the keystore, the aliases and the key passwords within this wrapper
created at: 09.12.2019 - 08:20
this class will be used to have the usage of a keystore wrapped in a single place. Means we will hold the password of the keystore, the aliases and the key passwords within this wrapper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classused as data holder to hold the key-passwords for any alias -
Constructor Summary
ConstructorsConstructorDescriptionKeyStoreWrapper(byte[] keyStore, KeyStoreSupporter.KeyStoreType keyStoreType, String keystorePassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymoreKeyStoreWrapper(byte[] keyStore, KeyStoreSupporter.KeyStoreType keyStoreType, String keystorePassword, KeyStoreWrapper.AliasPasswordPair aliasPasswordPair, KeyStoreWrapper.AliasPasswordPair... aliasPasswordPairs) constructor to befill the entries for this classKeyStoreWrapper(byte[] keyStore, String keystorePassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore
The keystore is expected to be of type JKSKeyStoreWrapper(File keyStore, String keystorePassword, KeyStoreWrapper.AliasPasswordPair aliasPasswordPair, KeyStoreWrapper.AliasPasswordPair... aliasPasswordPairs) constructor to befill the entries for this classKeyStoreWrapper(InputStream keyStore, KeyStoreSupporter.KeyStoreType keyStoreType, String keystorePassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymoreKeyStoreWrapper(InputStream keyStore, String keystorePassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore
The keystore is expected to be of type JKSKeyStoreWrapper(KeyStore keyStore, String privateKeyPassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore for the keystore.KeyStoreWrapper(KeyStore keyStore, String keystorePassword, KeyStoreWrapper.AliasPasswordPair aliasPasswordPair, KeyStoreWrapper.AliasPasswordPair... aliasPasswordPairs) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanwill return all aliases as list.getCertificate(String alias) will read the certificate from the given aliasthe keystore that is the main object of this classa list of aliases within the keystore that have a matching key-password entrythe password to access the keystoregetPrivateKey(String alias) will extract the private key for the given aliasgetPrivateKey(String alias, String password) this method will extract a private key with the given alias and the given passwordinthashCode()voidsetKeyStore(KeyStore keyStore) the keystore that is the main object of this classvoidsetKeystoreEntries(Map<String, KeyStoreWrapper.AliasPasswordPair> keystoreEntries) a list of aliases within the keystore that have a matching key-password entryvoidsetKeystorePassword(String keystorePassword) the password to access the keystoretoString()
-
Constructor Details
-
KeyStoreWrapper
constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore for the keystore.- Parameters:
keyStore- the keystore that should be accessibleprivateKeyPassword- the password used to access the private keys (the keystore is expected to contain a single entry)
-
KeyStoreWrapper
constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore
The keystore is expected to be of type JKS- Parameters:
keyStore- the keystore that should be accessiblekeystorePassword- the keystore to open the keystore
-
KeyStoreWrapper
public KeyStoreWrapper(byte[] keyStore, KeyStoreSupporter.KeyStoreType keyStoreType, String keystorePassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore- Parameters:
keyStore- the keystore that should be accessiblekeyStoreType- the type of the keystorekeystorePassword- the keystore to open the keystore
-
KeyStoreWrapper
constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore
The keystore is expected to be of type JKS- Parameters:
keyStore- the keystore that should be accessiblekeystorePassword- the keystore to open the keystore
-
KeyStoreWrapper
public KeyStoreWrapper(InputStream keyStore, KeyStoreSupporter.KeyStoreType keyStoreType, String keystorePassword) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore- Parameters:
keyStore- the keystore that should be accessiblekeyStoreType- the type of the keystorekeystorePassword- the keystore to open the keystore
-
KeyStoreWrapper
public KeyStoreWrapper(KeyStore keyStore, String keystorePassword, KeyStoreWrapper.AliasPasswordPair aliasPasswordPair, KeyStoreWrapper.AliasPasswordPair... aliasPasswordPairs) constructor to befill the entries for this class
it is expected that the keystore-password has already been entered into the keystore object therefore we wont need it anymore- Parameters:
keyStore- the keystore that should be accessiblekeystorePassword- the keystore to open the keystorealiasPasswordPair- a single alias key-password pair to access at least a single entry within the keystorealiasPasswordPairs- a list of alias key-password pairs to access other entreies as well
-
KeyStoreWrapper
public KeyStoreWrapper(byte[] keyStore, KeyStoreSupporter.KeyStoreType keyStoreType, String keystorePassword, KeyStoreWrapper.AliasPasswordPair aliasPasswordPair, KeyStoreWrapper.AliasPasswordPair... aliasPasswordPairs) constructor to befill the entries for this class- Parameters:
keyStore- the keystore that should be accessiblekeyStoreType- to resolve the given keystore into its appropriate typekeystorePassword- the password to access the keystore if necessaryaliasPasswordPair- a single alias key-password pair to access at least a single entry within the keystorealiasPasswordPairs- a list of alias key-password pairs to access other entreies as well
-
KeyStoreWrapper
public KeyStoreWrapper(File keyStore, String keystorePassword, KeyStoreWrapper.AliasPasswordPair aliasPasswordPair, KeyStoreWrapper.AliasPasswordPair... aliasPasswordPairs) constructor to befill the entries for this class- Parameters:
keyStore- the keystore that should be accessible. It is necessary for the keystore to have an appropriate file ending like 'jks', 'jceks', 'p12' or 'pfx'!keystorePassword- the password to access the keystore if necessaryaliasPasswordPair- a single alias key-password pair to access at least a single entry within the keystorealiasPasswordPairs- a list of alias key-password pairs to access other entreies as well
-
-
Method Details
-
getPrivateKey
will extract the private key for the given alias- Parameters:
alias- the keystore entry to get the private key from- Returns:
- the private key of the alias
-
getPrivateKey
this method will extract a private key with the given alias and the given password- Parameters:
alias- the alias that holds the private keypassword- the password to access the private key- Returns:
- the private key or null if no entry was found
-
getCertificate
will read the certificate from the given alias- Parameters:
alias- the keystore entry to read- Returns:
- the certificate under the given keystore entry
-
getAliasesAsList
will return all aliases as list.
this is just a convenience method to prevent handling withKeyStoreException -
getKeyStore
the keystore that is the main object of this class -
getKeystorePassword
the password to access the keystore -
getKeystoreEntries
a list of aliases within the keystore that have a matching key-password entry -
setKeyStore
the keystore that is the main object of this class -
setKeystorePassword
the password to access the keystore -
setKeystoreEntries
a list of aliases within the keystore that have a matching key-password entry -
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-