Class AbstractPbeReplacer

java.lang.Object
com.hazelcast.config.replacer.AbstractPbeReplacer
All Implemented Interfaces:
ConfigReplacer
Direct Known Subclasses:
EncryptionReplacer

public abstract class AbstractPbeReplacer
extends Object
implements ConfigReplacer
The common parent for ConfigReplacer implementations which allow to mask values by encrypting the value. This parent class contains shared methods responsible for encryption/decryption. The implementing classes have to provide getPassword() implementation - the password will be used to generate a secret key.
  • Field Details

  • Constructor Details

    • AbstractPbeReplacer

      public AbstractPbeReplacer()
  • Method Details

    • init

      public void init​(Properties properties)
      Description copied from interface: ConfigReplacer
      Initialization method called before first usage of the config replacer.
      Specified by:
      init in interface ConfigReplacer
      Parameters:
      properties - properties configured (not null)
    • getPassword

      protected abstract char[] getPassword()
      Provides password for a chosen SecretKeyFactory.
      Returns:
      password must not be null or empty
    • getReplacement

      public String getReplacement​(String variable)
      Description copied from interface: ConfigReplacer
      Provides String which should be used as a variable replacement for given masked value.
      Specified by:
      getReplacement in interface ConfigReplacer
      Parameters:
      variable - the masked value
      Returns:
      either not null String to be used as a replacement for the variable; or null when this replacer is not able to handle the masked value.
    • encrypt

      protected String encrypt​(String secretStr, int iterations) throws Exception
      Encrypts given string with key generated from getPassword() with given iteration count and return the masked value (to be used as the variable).
      Parameters:
      secretStr - sensitive string to be protected by encryption
      iterations - iteration count
      Returns:
      the encrypted value.
      Throws:
      Exception - in case of any exceptional case
    • decrypt

      protected String decrypt​(String encryptedStr) throws Exception
      Decrypts given encrypted variable.
      Parameters:
      encryptedStr - the encrypted value
      Returns:
      the decrypted value
      Throws:
      Exception - in case of any exceptional case