Package rs.baselib.crypto
Class DefaultCryptingDelegateFactory
java.lang.Object
rs.baselib.crypto.DefaultCryptingDelegateFactory
- All Implemented Interfaces:
ICryptingDelegateFactory
Creates a crypting delegator.
This class finds its configuration via classpath. You can give java argument -Dencryption.config=path
which will then load the config from this path. The default location is encryption-config.xml.
- Author:
- ralph
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Creates and initializes the crypting delegate.Returns the algorithm.protected XMLConfiguration
Returns the configuration.Returns a crypting delegate.protected String
Returns the name of the delegate class.static ICryptingDelegateFactory
Returns the crypting delegate factory.protected String
Returns the public key alias in key store.Returns the keyPair.protected char[]
Return the public key passwordprotected byte[]
Return the public key salt.protected KeyStore
Returns the key store.protected SubnodeConfiguration
Returns the configuration for the keystore.protected char[]
Return the key store passwordprotected String
Returns the key store path.protected String
Returns the key store path.Returns the paramSpec.char[]
Alternatively provide a passphrase for encryption usage.protected char[]
getPassword
(String type) Asks the respective callback to deliver a password.protected IPasswordCallback
getPasswordCallback
(String type) Returns a callback for the given type.protected SubnodeConfiguration
Returns the configuration for the password callback.byte[]
getSalt()
Provide a salt for encryption usage.protected byte[]
Asks the respective callback to deliver a salt.protected void
init()
Initializes this factory.protected String
loadAlgorithm
(Configuration config) Returns the algorithm definition from the configprotected AlgorithmParameterSpec
loadParamSpec
(Configuration config) Currently only default PBE spec.protected void
loadSpec()
Loads the spec params (lazily).void
setAlgorithm
(String algorithm) Sets the algorithm.void
setKeyPair
(KeyPair keyPair) Sets the keyPair.void
setParamSpec
(AlgorithmParameterSpec paramSpec) Sets the paramSpec.
-
Field Details
-
INSTANCE
-
-
Method Details
-
getInstance
Returns the crypting delegate factory.- Returns:
- the factory
-
init
protected void init()Initializes this factory. -
loadSpec
protected void loadSpec()Loads the spec params (lazily). -
getConfiguration
Returns the configuration.- Returns:
- the configuration
-
getDelegateClassName
Returns the name of the delegate class.- Returns:
- the name of delegate class
-
getPasswordCallback
Returns a callback for the given type.- Parameters:
type
- type of password callback- Returns:
- the password callback
-
getPasswordCallbackConfig
Returns the configuration for the password callback.- Parameters:
type
- type of callback- Returns:
- classname
-
getPassword
Asks the respective callback to deliver a password.- Parameters:
type
- type of callback- Returns:
- password or null if no callback exists.
-
getKeySalt
protected byte[] getKeySalt()Return the public key salt.- Returns:
- key salt
-
getSalt
public byte[] getSalt()Provide a salt for encryption usage.- Specified by:
getSalt
in interfaceICryptingDelegateFactory
- Returns:
- salt
-
getSalt
Asks the respective callback to deliver a salt.- Parameters:
type
- type of callback- Returns:
- salt or null if no callback exists.
-
getKeyStoreConfig
Returns the configuration for the keystore.- Returns:
- classname
-
getKeyStore
Returns the key store.- Returns:
- the key store
- Throws:
IOException
- when key store cannot be opened
-
getKeyStoreType
Returns the key store path.- Returns:
- key store path
-
getKeyStorePath
Returns the key store path.- Returns:
- key store path
-
getKeyStorePassword
protected char[] getKeyStorePassword()Return the key store password- Returns:
- key store password
-
getKeyAlias
Returns the public key alias in key store.- Returns:
- key alias
-
getKeyPassword
protected char[] getKeyPassword()Return the public key password- Returns:
- key password
-
getPassphrase
public char[] getPassphrase()Alternatively provide a passphrase for encryption usage.- Specified by:
getPassphrase
in interfaceICryptingDelegateFactory
- Returns:
- passphrase
-
getCryptingDelegate
Returns a crypting delegate.- Specified by:
getCryptingDelegate
in interfaceICryptingDelegateFactory
- Returns:
- a delegate
-
createCryptingDelegate
protected void createCryptingDelegate()Creates and initializes the crypting delegate. -
getKeyPair
Returns the keyPair.- Specified by:
getKeyPair
in interfaceICryptingDelegateFactory
- Returns:
- the keyPair
-
setKeyPair
Sets the keyPair.- Parameters:
keyPair
- the keyPair to set
-
getAlgorithm
Returns the algorithm.- Specified by:
getAlgorithm
in interfaceICryptingDelegateFactory
- Returns:
- the algorithm
-
setAlgorithm
Sets the algorithm.- Parameters:
algorithm
- the algorithm to set
-
loadAlgorithm
Returns the algorithm definition from the config- Parameters:
config
- the config- Returns:
- the algorithm
-
getParamSpec
Returns the paramSpec.- Specified by:
getParamSpec
in interfaceICryptingDelegateFactory
- Returns:
- the paramSpec
-
setParamSpec
Sets the paramSpec.- Parameters:
paramSpec
- the paramSpec to set
-
loadParamSpec
Currently only default PBE spec.- Parameters:
config
- configuration to load from- Returns:
- the param spec
-