Jasypt Users Forum

Jasypt + Hibernate3 integration + decrypt

View: New views
4 Messages — Rating Filter:   Alert me  

Jasypt + Hibernate3 integration + decrypt

by jmirmon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

I would like to encrypt some attributes of an entity in a transparent way when I persist it into database using Hibernate. I've followed the guide: http://www.jasypt.org/hibernate3.html and it works like a charm.

The problem is that when I want to get back the entity from database I would like to get the entity with all attributes decryted. I don't know if I am missing something important but I get the attributes encrypted.

I've followed all the steps of the guide. Any ideas?.

Thanks in advance.

Re: Jasypt + Hibernate3 integration + decrypt

by jmirmon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Solved.

Everything works well doing some executions, I initialize Spring container (is a web app) 5 or 6 times and then...

Caused by: org.jasypt.exceptions.EncryptionInitializationException: No string encryptor registered for hibernate with name "strongHibernateStringEncryptor"
        at org.jasypt.hibernate.type.AbstractEncryptedAsStringType.checkInitialization(AbstractEncryptedAsStringType.java:250)
        at org.jasypt.hibernate.type.AbstractEncryptedAsStringType.nullSafeGet(AbstractEncryptedAsStringType.java:142)
        at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105)
        at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)

Any ideas?.

jmiranda wrote:
Hi!

I would like to encrypt some attributes of an entity in a transparent way when I persist it into database using Hibernate. I've followed the guide: http://www.jasypt.org/hibernate3.html and it works like a charm.

The problem is that when I want to get back the entity from database I would like to get the entity with all attributes decryted. I don't know if I am missing something important but I get the attributes encrypted.

I've followed all the steps of the guide. Any ideas?.

Thanks in advance.

Re: Jasypt + Hibernate3 integration + decrypt

by bornleo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You need to make an entry of strongHibernateStringEncryptor in your spring context i.e. applicationConext.xml in my case.

Something like this.

<bean id="strongHibernateStringEncryptor"
            class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
            <property name="algorithm">
                <value>PBEWithMD5AndTripleDES</value>
            </property>
            <property name="password">
                <value>jasypt</value>
            </property>
        </bean>

Hope this helps.

Leo.


Solved.

Everything works well doing some executions, I initialize Spring container (is a web app) 5 or 6 times and then...

Caused by: org.jasypt.exceptions.EncryptionInitializationException: No string encryptor registered for hibernate with name "strongHibernateStringEncryptor"
        at org.jasypt.hibernate.type.AbstractEncryptedAsStringType.checkInitialization(AbstractEncryptedAsStringType.java:250)
        at org.jasypt.hibernate.type.AbstractEncryptedAsStringType.nullSafeGet(AbstractEncryptedAsStringType.java:142)
        at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105)
        at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)

Any ideas?.

jmiranda wrote:
Hi!

I would like to encrypt some attributes of an entity in a transparent way when I persist it into database using Hibernate. I've followed the guide: http://www.jasypt.org/hibernate3.html and it works like a charm.

The problem is that when I want to get back the entity from database I would like to get the entity with all attributes decryted. I don't know if I am missing something important but I get the attributes encrypted.

I've followed all the steps of the guide. Any ideas?.

Thanks in advance.


Re: Jasypt + Hibernate3 integration + decrypt

by jmirmon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Leo, yes I had this piece of configuration.  Maybe I was missing something. At the end I've created a spring bean and inside I've used jasypt to encrypt/decrypt, then I have to get the bean and call decrypt/encrypt everytime I want to get/update my entity but doesn't matter, is just in one time and it does not supose a big headchache :)

Thanks for your help.



You need to make an entry of strongHibernateStringEncryptor in your spring context i.e. applicationConext.xml in my case.

Something like this.

<bean id="strongHibernateStringEncryptor"
            class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
            <property name="algorithm">
                <value>PBEWithMD5AndTripleDES</value>
            </property>
            <property name="password">
                <value>jasypt</value>
            </property>
        </bean>

Hope this helps.

Leo.

jmiranda wrote:
Solved.

Everything works well doing some executions, I initialize Spring container (is a web app) 5 or 6 times and then...

Caused by: org.jasypt.exceptions.EncryptionInitializationException: No string encryptor registered for hibernate with name "strongHibernateStringEncryptor"
        at org.jasypt.hibernate.type.AbstractEncryptedAsStringType.checkInitialization(AbstractEncryptedAsStringType.java:250)
        at org.jasypt.hibernate.type.AbstractEncryptedAsStringType.nullSafeGet(AbstractEncryptedAsStringType.java:142)
        at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105)
        at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)

Any ideas?.

jmiranda wrote:
Hi!

I would like to encrypt some attributes of an entity in a transparent way when I persist it into database using Hibernate. I've followed the guide: http://www.jasypt.org/hibernate3.html and it works like a charm.

The problem is that when I want to get back the entity from database I would like to get the entity with all attributes decryted. I don't know if I am missing something important but I get the attributes encrypted.

I've followed all the steps of the guide. Any ideas?.

Thanks in advance.