|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Objectorg.jasypt.hibernate4.encryptor.HibernatePBEByteEncryptor
public final class HibernatePBEByteEncryptor
Placeholder class for PBEByteEncryptor objects which are eligible for use from Hibernate.
This class acts as a wrapper on a PBEByteEncryptor, 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 PBEByteEncryptor be explicitly set
with setEncryptor(PBEByteEncryptor). If not, a
StandardPBEByteEncryptor 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:
This in a Spring config file would look like:
...
<-- Optional, as the hibernateEncryptor could be directly set an -->
<-- algorithm and password. -->
<bean id="byteEncryptor"
class="org.jasypt.encryption.pbe.StandardPBEByteEncryptor">
<property name="algorithm">
<value>PBEWithMD5AndDES</value>
</property>
<property name="password">
<value>XXXXX</value>
</property>
</bean>
<bean id="hibernateEncryptor"
class="org.jasypt.hibernate.encryptor.HibernatePBEByteEncryptor">
<property name="registeredName">
<value>myHibernateByteEncryptor</value>
</property>
<property name="encryptor">
<ref bean="byteEncryptor" />
</property>
</bean>
...
And then in the Hibernate mapping file:
<typedef name="encrypted" class="org.jasypt.hibernate.type.EncryptedBinaryType">
<param name="encryptorRegisteredName">myHibernateByteEncryptor</param>
</typedef>
An important thing to note is that, when using HibernatePBEByteEncryptor
objects this way to wrap PBEByteEncryptors, it is not
necessary to deal with HibernatePBEEncryptorRegistry,
because HibernatePBEByteEncryptor objects get automatically registered
in the encryptor registry when their setRegisteredName(String)
method is called.
| Constructor Summary | |
|---|---|
HibernatePBEByteEncryptor()
Creates a new instance of HibernatePBEByteEncryptor It also creates a StandardPBEByteEncryptor for internal use, which can be overriden by calling setEncryptor(...). |
|
| Method Summary | |
|---|---|
byte[] |
decrypt(byte[] encryptedMessage)
Decypts a message, delegating to wrapped encryptor |
byte[] |
encrypt(byte[] message)
Encrypts a message, delegating to wrapped encryptor. |
org.jasypt.encryption.pbe.PBEByteEncryptor |
getEncryptor()
Returns the encryptor which this object wraps. |
String |
getRegisteredName()
Returns the name with which the wrapped encryptor is registered at the registry. |
void |
setAlgorithm(String algorithm)
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)
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.PBEByteEncryptor encryptor)
Sets the PBEByteEncryptor to be held (wrapped) by this object. |
void |
setKeyObtentionIterations(int keyObtentionIterations)
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)
Sets the password to be used by the internal encryptor, if a specific encryptor has not been set with setEncryptor(...). |
void |
setPasswordCharArray(char[] password)
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)
Sets the registered name of the encryptor and adds it to the registry. |
void |
setSaltGenerator(org.jasypt.salt.SaltGenerator saltGenerator)
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 |
|---|
public HibernatePBEByteEncryptor()
| Method Detail |
|---|
public org.jasypt.encryption.pbe.PBEByteEncryptor getEncryptor()
public void setEncryptor(org.jasypt.encryption.pbe.PBEByteEncryptor encryptor)
encryptor - the encryptor.public void setPassword(String password)
password - the password to be set for the internal encryptorpublic void setPasswordCharArray(char[] password)
password - the password to be set for the internal encryptorpublic void setAlgorithm(String algorithm)
algorithm - the algorithm to be set for the internal encryptorpublic void setKeyObtentionIterations(int keyObtentionIterations)
keyObtentionIterations - to be set for the internal encryptorpublic void setSaltGenerator(org.jasypt.salt.SaltGenerator saltGenerator)
saltGenerator - the salt generator to be set for the internal
encryptor.public void setConfig(org.jasypt.encryption.pbe.config.PBEConfig config)
config - the PBEConfig to be set for the internal encryptorpublic byte[] encrypt(byte[] message)
message - the message to be encrypted.
public byte[] decrypt(byte[] encryptedMessage)
encryptedMessage - the message to be decrypted.
public void setRegisteredName(String registeredName)
registeredName - the name with which the encryptor will be
registered.public String getRegisteredName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||