Class KeyStoreWrapper
- java.lang.Object
-
- de.captaingoldfish.scim.sdk.client.keys.KeyStoreWrapper
-
public class KeyStoreWrapper extends Object
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyStoreWrapper.AliasPasswordPairused as data holder to hold the key-passwords for any alias
-
Constructor Summary
Constructors Constructor Description 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 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)List<String>getAliasesAsList()will return all aliases as list.Optional<X509Certificate>getCertificate(String alias)will read the certificate from the given aliasKeyStoregetKeyStore()the keystore that is the main object of this classMap<String,KeyStoreWrapper.AliasPasswordPair>getKeystoreEntries()a list of aliases within the keystore that have a matching key-password entryStringgetKeystorePassword()the password to access the keystoreOptional<PrivateKey>getPrivateKey(String alias)will extract the private key for the given aliasOptional<PrivateKey>getPrivateKey(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 keystoreStringtoString()
-
-
-
Constructor Detail
-
KeyStoreWrapper
public KeyStoreWrapper(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.- 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
public KeyStoreWrapper(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 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
public KeyStoreWrapper(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 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 Detail
-
getPrivateKey
public Optional<PrivateKey> getPrivateKey(String alias)
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
public Optional<PrivateKey> getPrivateKey(String alias, String password)
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
public Optional<X509Certificate> getCertificate(String alias)
will read the certificate from the given alias- Parameters:
alias- the keystore entry to read- Returns:
- the certificate under the given keystore entry
-
getAliasesAsList
public List<String> getAliasesAsList()
will return all aliases as list.
this is just a convenience method to prevent handling withKeyStoreException
-
getKeyStore
public KeyStore getKeyStore()
the keystore that is the main object of this class
-
getKeystorePassword
public String getKeystorePassword()
the password to access the keystore
-
getKeystoreEntries
public Map<String,KeyStoreWrapper.AliasPasswordPair> getKeystoreEntries()
a list of aliases within the keystore that have a matching key-password entry
-
setKeyStore
public void setKeyStore(KeyStore keyStore)
the keystore that is the main object of this class
-
setKeystorePassword
public void setKeystorePassword(String keystorePassword)
the password to access the keystore
-
setKeystoreEntries
public void setKeystoreEntries(Map<String,KeyStoreWrapper.AliasPasswordPair> keystoreEntries)
a list of aliases within the keystore that have a matching key-password entry
-
canEqual
protected boolean canEqual(Object other)
-
-