Jasypt plugin: How do I get an encrypter for manual encryption?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Jasypt plugin: How do I get an encrypter for manual encryption?

Sven Kiesewetter-3
Hi all,

I'm using grails 2.2.2 and the jasypt plugin 1.1.0 to encrypt some account information.

example:

class Account {
String accountNumber

static mapping = {
        accountNumber type: GormEncryptedStringType
    }
}


Now, I want to search all accounts for any with a given accountNumber '12345'. 
Account.findAllByAccountNumber('12345') won't work, because findAll will apparently only see the encrypted values.

I'd like to encrypt '12345' manually, so i can call findAll with the encrypted searchTerm.

How can I do that?
I.e., how do i get the encryptor that jasypt uses here?

Many thanks,
Sven
Reply | Threaded
Open this post in threaded view
|

Re: Jasypt plugin: How do I get an encrypter for manual encryption?

Sven Kiesewetter-3
Hi all,

I think I found a solution.

By moving the Jasypt config from the config.groovy to resources.groovy (and defining an encrypter bean there), I am able to access the encrypter via the applicationContext.

To be able to query for encrypted values, I'd also need to change the saltGenerator for the encrypter to a static salt generator.

Issue solved. 
Bye,
Sven
:-)



2013/8/28 Sven Kiesewetter <[hidden email]>
Hi all,

I'm using grails 2.2.2 and the jasypt plugin 1.1.0 to encrypt some account information.

example:

class Account {
String accountNumber

static mapping = {
        accountNumber type: GormEncryptedStringType
    }
}


Now, I want to search all accounts for any with a given accountNumber '12345'. 
Account.findAllByAccountNumber('12345') won't work, because findAll will apparently only see the encrypted values.

I'd like to encrypt '12345' manually, so i can call findAll with the encrypted searchTerm.

How can I do that?
I.e., how do i get the encryptor that jasypt uses here?

Many thanks,
Sven

Reply | Threaded
Open this post in threaded view
|

Re: Jasypt plugin: How do I get an encrypter for manual encryption?

apolon
hi

I  did what you said in my code :


resources.groovy :

hibernateStringEncryptor(org.jasypt.hibernate.encryptor.HibernatePBEStringEncryptor) {
        registeredName = "gormEncryptor"
        providerName = "BC"
        algorithm = "PBEWITHSHA256AND128BITAES-CBC-BC"
        keyObtentionIterations = 1000
        password = "t0rk@man3da"
    }

config.groovy:

jasypt {
         encryptorRegisteredName = "gormEncryptor"
     }


I got this Exception :
org.jasypt.exceptions.EncryptionInitializationException
No string encryptor registered for hibernate with name "gormEncryptor"

any comment???




Sven Kiesewetter-3 wrote
Hi all,

I think I found a solution.

By moving the Jasypt config from the config.groovy to resources.groovy (and
defining an encrypter bean there), I am able to access the encrypter via
the applicationContext.

To be able to query for encrypted values, I'd also need to change the
saltGenerator for the encrypter to a static salt generator.

Issue solved.
Bye,
Sven
:-)



2013/8/28 Sven Kiesewetter <[hidden email]>

> Hi all,
>
> I'm using grails 2.2.2 and the jasypt plugin 1.1.0 to encrypt some account
> information.
>
> example:
>
> class Account {
> String accountNumber
>
> static mapping = {
>         accountNumber type: GormEncryptedStringType
>     }
> }
>
>
> Now, I want to search all accounts for any with a given accountNumber
> '12345'.
> Account.findAllByAccountNumber('12345') won't work, because findAll will
> apparently only see the encrypted values.
>
> I'd like to encrypt '12345' manually, so i can call findAll with the
> encrypted searchTerm.
>
> How can I do that?
> I.e., how do i get the encryptor that jasypt uses here?
>
> Many thanks,
> Sven
>
Reply | Threaded
Open this post in threaded view
|

Re: Jasypt plugin: How do I get an encrypter for manual encryption?

EdgarTrejo
Hello,

Did You find a solution?