Class DefaultCryptingDelegateFactory

java.lang.Object
rs.baselib.crypto.DefaultCryptingDelegateFactory
All Implemented Interfaces:
ICryptingDelegateFactory

public class DefaultCryptingDelegateFactory extends Object implements 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 Details

  • Method Details

    • getInstance

      public static ICryptingDelegateFactory 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

      protected XMLConfiguration getConfiguration()
      Returns the configuration.
      Returns:
      the configuration
    • getDelegateClassName

      protected String getDelegateClassName()
      Returns the name of the delegate class.
      Returns:
      the name of delegate class
    • getPasswordCallback

      protected IPasswordCallback getPasswordCallback(String type)
      Returns a callback for the given type.
      Parameters:
      type - type of password callback
      Returns:
      the password callback
    • getPasswordCallbackConfig

      protected SubnodeConfiguration getPasswordCallbackConfig(String type)
      Returns the configuration for the password callback.
      Parameters:
      type - type of callback
      Returns:
      classname
    • getPassword

      protected char[] getPassword(String type)
      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 interface ICryptingDelegateFactory
      Returns:
      salt
    • getSalt

      protected byte[] getSalt(String type)
      Asks the respective callback to deliver a salt.
      Parameters:
      type - type of callback
      Returns:
      salt or null if no callback exists.
    • getKeyStoreConfig

      protected SubnodeConfiguration getKeyStoreConfig()
      Returns the configuration for the keystore.
      Returns:
      classname
    • getKeyStore

      protected KeyStore getKeyStore() throws IOException
      Returns the key store.
      Returns:
      the key store
      Throws:
      IOException - when key store cannot be opened
    • getKeyStoreType

      protected String getKeyStoreType()
      Returns the key store path.
      Returns:
      key store path
    • getKeyStorePath

      protected String getKeyStorePath()
      Returns the key store path.
      Returns:
      key store path
    • getKeyStorePassword

      protected char[] getKeyStorePassword()
      Return the key store password
      Returns:
      key store password
    • getKeyAlias

      protected String 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 interface ICryptingDelegateFactory
      Returns:
      passphrase
    • getCryptingDelegate

      public ICryptingDelegate getCryptingDelegate()
      Returns a crypting delegate.
      Specified by:
      getCryptingDelegate in interface ICryptingDelegateFactory
      Returns:
      a delegate
    • createCryptingDelegate

      protected void createCryptingDelegate()
      Creates and initializes the crypting delegate.
    • getKeyPair

      public KeyPair getKeyPair()
      Returns the keyPair.
      Specified by:
      getKeyPair in interface ICryptingDelegateFactory
      Returns:
      the keyPair
    • setKeyPair

      public void setKeyPair(KeyPair keyPair)
      Sets the keyPair.
      Parameters:
      keyPair - the keyPair to set
    • getAlgorithm

      public String getAlgorithm()
      Returns the algorithm.
      Specified by:
      getAlgorithm in interface ICryptingDelegateFactory
      Returns:
      the algorithm
    • setAlgorithm

      public void setAlgorithm(String algorithm)
      Sets the algorithm.
      Parameters:
      algorithm - the algorithm to set
    • loadAlgorithm

      protected String loadAlgorithm(Configuration config)
      Returns the algorithm definition from the config
      Parameters:
      config - the config
      Returns:
      the algorithm
    • getParamSpec

      public AlgorithmParameterSpec getParamSpec()
      Returns the paramSpec.
      Specified by:
      getParamSpec in interface ICryptingDelegateFactory
      Returns:
      the paramSpec
    • setParamSpec

      public void setParamSpec(AlgorithmParameterSpec paramSpec)
      Sets the paramSpec.
      Parameters:
      paramSpec - the paramSpec to set
    • loadParamSpec

      protected AlgorithmParameterSpec loadParamSpec(Configuration config)
      Currently only default PBE spec.
      Parameters:
      config - configuration to load from
      Returns:
      the param spec