• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JASYPT library usage for where clause

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using JASYPT library from APACHE (http://www.jasypt.org) for my database encryption/decryption.
I am using EJB3(annotations) for my table mappings and Hibernate.
As per the documentation given for the library we need to add @TypeDef annotation having password, algorithm, providername as parameters to it. Below is my code snippet for this configuration:

@TypeDef(
name="encryptedString",
typeClass=EncryptedStringType.class,
parameters= {
@Parameter(name = "password", value = "password"),
@Parameter(name = "providerName", value = "BC"),
@Parameter(name = "algorithm", value = "PBEWITHSHA256AND128BITAES-CBC-BC"),
@Parameter(name = "keyObtentionIterations", value = "1000")
}
)

and we need to use "encryptedString" @TypeDef name for all our column config for which encryption/decryption should apply.
Below is my code snippet of 1 column definition.
@Column(name = "EMAIL", length = 45)
@Type(type="encryptedString")
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}

When we insert the record, library will automatically choose the algorithm given and apply the encryption to it.
When we retrieve the record from primary key and display the record using getEmail() method, it will automatically decrypt and give us proper value.

I am facing a problem when i am querying the record on this encrypted data.
I will be passing the email value from request parameter and query the DB on this.

The query is not returning any result for this. But if i retrieve all the data from DB without any WHERE CLAUSE and display the object, it is displaying properly.

I googled in net and not found any proper response.

If anyone help me in retrieving the record based on encrypted data in where clause, that would be of great help.

Thanks and Regards,
Sujit Joshi
reply
    Bookmark Topic Watch Topic
  • New Topic