org.jasypt.hibernate.encryptor

## Class HibernatePBEBigDecimalEncryptor

- Object
- - org.jasypt.hibernate.encryptor.HibernatePBEBigDecimalEncryptor

- Deprecated.
  Will be removed in 1.11. Package org.jasypt.hibernate.connectionprovider has been renamed as org.jasypt.hibernate3.connectionprovider.

      public final class HibernatePBEBigDecimalEncryptor
      extends Object

  Placeholder class for `PBEBigDecimalEncryptor` objects which are eligible for use from Hibernate.

  This class acts as a wrapper on a `PBEBigDecimalEncryptor`, allowing to be set a registered name (see `setRegisteredName(String)`) and performing the needed registry operations against the `HibernatePBEEncryptorRegistry`.

  It is not mandatory that a `PBEBigDecimalEncryptor` be explicitly set with `setEncryptor(PBEBigDecimalEncryptor)`. If not, a `StandardPBEBigDecimalEncryptor` object will be created internally and it will be configurable with the `setPassword(String)`/`setPasswordCharArray(char[])`, `setAlgorithm(String)`, `setKeyObtentionIterations(int)`, `setSaltGenerator(SaltGenerator)` and `setConfig(PBEConfig)` methods.

  This class is mainly intended for use from Spring Framework or some other IoC container (if you are not using a container of this kind, please see `HibernatePBEEncryptorRegistry`). The steps to be performed are the following:

  1. Create an object of this class (declaring it).
  2. Set its `registeredName` and, either its wrapped `encryptor` or its `password`, `algorithm`, `keyObtentionIterations`, `saltGenerator` and `config` properties.
  3. Declare a typedef in a Hibernate mapping giving its `encryptorRegisteredName` parameter the same value specified to this object in `registeredName`.

  This in a Spring config file would look like:

        ...
        <-- Optional, as the hibernateEncryptor could be directly set an     -->
        <-- algorithm and password.                                          -->
        <bean id="bigDecimalEncryptor"
          class="org.jasypt.encryption.pbe.StandardPBEBigDecimalEncryptor">
          <property name="algorithm">
              <value>PBEWithMD5AndDES</value>
          </property>
          <property name="password">
              <value>XXXXX</value>
          </property>
        </bean>

        <bean id="hibernateEncryptor"
          class="org.jasypt.hibernate.encryptor.HibernatePBEBigDecimalEncryptor">
          <property name="registeredName">
              <value>myHibernateBigDecimalEncryptor</value>
          </property>
          <property name="encryptor">
              <ref bean="bigDecimalEncryptor" />
          </property>
        </bean>
        ...

  And then in the Hibernate mapping file:

          <typedef name="encrypted" class="org.jasypt.hibernate.type.EncryptedBigDecimalType">
            <param name="encryptorRegisteredName">myHibernateBigDecimalEncryptor</param>
            <param name="decimalScale">2</param>
          </typedef>

  An important thing to note is that, when using `HibernatePBEBigDecimalEncryptor` objects this way to wrap `PBEBigDecimalEncryptor`s, it is not necessary to deal with `HibernatePBEEncryptorRegistry`, because `HibernatePBEBigDecimalEncryptor` objects get automatically registered in the encryptor registry when their `setRegisteredName(String)` method is called.

  Since:
    1.2
  Author:
    Daniel Fernández

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HibernatePBEBigDecimalEncryptor()` Deprecated. Creates a new instance of `HibernatePBEBigDecimalEncryptor` It also creates a `StandardPBEBigDecimalEncryptor` for internal use, which can be overriden by calling `setEncryptor(...)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `BigDecimal` | `decrypt(BigDecimal encryptedMessage)` Deprecated. Decypts a message, delegating to wrapped encryptor
    `BigDecimal` | `encrypt(BigDecimal message)` Deprecated. Encrypts a message, delegating to wrapped encryptor.
    `org.jasypt.encryption.pbe.PBEBigDecimalEncryptor` | `getEncryptor()` Deprecated. Returns the encryptor which this object wraps.
    `String` | `getRegisteredName()` Deprecated. Returns the name with which the wrapped encryptor is registered at the registry.
    `void` | `setAlgorithm(String algorithm)` Deprecated. Sets the algorithm to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`
    `void` | `setConfig(org.jasypt.encryption.pbe.config.PBEConfig config)` Deprecated. Sets the PBEConfig to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`
    `void` | `setEncryptor(org.jasypt.encryption.pbe.PBEBigDecimalEncryptor encryptor)` Deprecated. Sets the `PBEBigDecimalEncryptor` to be held (wrapped) by this object.
    `void` | `setKeyObtentionIterations(int keyObtentionIterations)` Deprecated. Sets the key obtention iterations to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`
    `void` | `setPassword(String password)` Deprecated. Sets the password to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`
    `void` | `setPasswordCharArray(char[] password)` Deprecated. Sets the password to be used by the internal encryptor (as a char[]), if a specific encryptor has not been set with `setEncryptor(...)`
    `void` | `setRegisteredName(String registeredName)` Deprecated. Sets the registered name of the encryptor and adds it to the registry.
    `void` | `setSaltGenerator(org.jasypt.salt.SaltGenerator saltGenerator)` Deprecated. Sets the salt generator to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`

    - ### Methods inherited from class Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HibernatePBEBigDecimalEncryptor

          public HibernatePBEBigDecimalEncryptor()

      Deprecated.
      Creates a new instance of `HibernatePBEBigDecimalEncryptor` It also creates a `StandardPBEBigDecimalEncryptor` for internal use, which can be overriden by calling `setEncryptor(...)`.

  - ### Method Detail

    - #### getEncryptor

          public org.jasypt.encryption.pbe.PBEBigDecimalEncryptor getEncryptor()

      Deprecated.
      Returns the encryptor which this object wraps.
      Returns:
        the encryptor.

    - #### setEncryptor

          public void setEncryptor(org.jasypt.encryption.pbe.PBEBigDecimalEncryptor encryptor)

      Deprecated.
      Sets the `PBEBigDecimalEncryptor` to be held (wrapped) by this object. This method is optional and can be only called once.
      Parameters:
        `encryptor` - the encryptor.

    - #### setPassword

          public void setPassword(String password)

      Deprecated.
      Sets the password to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`.
      Parameters:
        `password` - the password to be set for the internal encryptor

    - #### setPasswordCharArray

          public void setPasswordCharArray(char[] password)

      Deprecated.
      Sets the password to be used by the internal encryptor (as a char[]), if a specific encryptor has not been set with `setEncryptor(...)`.
      Parameters:
        `password` - the password to be set for the internal encryptor
      Since:
        1.8

    - #### setAlgorithm

          public void setAlgorithm(String algorithm)

      Deprecated.
      Sets the algorithm to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`.
      Parameters:
        `algorithm` - the algorithm to be set for the internal encryptor

    - #### setKeyObtentionIterations

          public void setKeyObtentionIterations(int keyObtentionIterations)

      Deprecated.
      Sets the key obtention iterations to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`.
      Parameters:
        `keyObtentionIterations` - to be set for the internal encryptor

    - #### setSaltGenerator

          public void setSaltGenerator(org.jasypt.salt.SaltGenerator saltGenerator)

      Deprecated.
      Sets the salt generator to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`.
      Parameters:
        `saltGenerator` - the salt generator to be set for the internal encryptor.

    - #### setConfig

          public void setConfig(org.jasypt.encryption.pbe.config.PBEConfig config)

      Deprecated.
      Sets the PBEConfig to be used by the internal encryptor, if a specific encryptor has not been set with `setEncryptor(...)`.
      Parameters:
        `config` - the PBEConfig to be set for the internal encryptor

    - #### encrypt

          public BigDecimal encrypt(BigDecimal message)

      Deprecated.
      Encrypts a message, delegating to wrapped encryptor.
      Parameters:
        `message` - the message to be encrypted.
      Returns:
        the encryption result.

    - #### decrypt

          public BigDecimal decrypt(BigDecimal encryptedMessage)

      Deprecated.
      Decypts a message, delegating to wrapped encryptor
      Parameters:
        `encryptedMessage` - the message to be decrypted.
      Returns:
        the result of decryption.

    - #### setRegisteredName

          public void setRegisteredName(String registeredName)

      Deprecated.
      Sets the registered name of the encryptor and adds it to the registry.
      Parameters:
        `registeredName` - the name with which the encryptor will be registered.

    - #### getRegisteredName

          public String getRegisteredName()

      Deprecated.
      Returns the name with which the wrapped encryptor is registered at the registry.
      Returns:
        the registered name.

Copyright © 2019 The JASYPT team. All rights reserved.