Jasypt Users Forum

 « Return to Thread: jasypt 1.5 + hibernate 3 annotations

Re: jasypt 1.5 + hibernate 3 annotations

by bornleo :: Rate this Message:

Reply to Author | View in Thread

Hi
can you post more information on what is your application architecture? Are you using hibernate alone or is it in conjunction with Spring or Struts ?

Leo.

Hi,

Did you manage to get this working?  I'm having the same problem.  I'm having to use the Spring method of encrypting the data, by injecting a HibernateSpringEncryptor into my bean and using that to do the encryption before setting it onto my domain object but I'd prefer to be able to get the Hibernate Annotation version working.


cassey wrote:
hi. i used the jasypt but the password wasn't encrypted when saved to the table
dont know what's wrong. please help.

here's my code

import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.jasypt.hibernate.type.EncryptedStringType;

@Table(name = "STAFF")
@TypeDef(
                name="encryptedString",
                typeClass=EncryptedStringType.class,
                parameters= {
                        @Parameter(name="encryptorRegisteredName", value="strongHibernateStringEncryptor")
                        }
                )
public class Staff {

// other attributes ommited

        @Column(name = "PASSWORD", nullable = false)
        private String password;

       @Type(type="encryptedString")
        public String getPassword() {
                return password;
        }

        public void setPassword(String password) {
                this.password = password;
        }
}

 « Return to Thread: jasypt 1.5 + hibernate 3 annotations