These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to encrypt properties before persisting to database
PostPosted: Tue Sep 12, 2006 9:53 am 
Newbie

Joined: Tue Sep 12, 2006 8:48 am
Posts: 2
Hello,
In my entity, there are several properties which I want to encrypt in the database. After loading the entity back from the database, the properties should be "automatically" decrypted, transparent for the UI and Business Layer.

I tried to use ILifecycle.OnLoad() to decrypt and ILifecycle.OnSave() / OnUpdate() to encrypt. Decrypting is not a problem and works fine.

However, if I encrypt the data using

LifecycleVeto ILifecycle.OnUpdate(ISession s) {
this.Password = CryptographyHelpers.Encrypt(this.Password); // "Password" is a string property in my entity
}


the encrypted string doesn't get persisted in the database. Instead, if I look at the database table, the Password column still has the cleartext value.

Is there any alternative approach? I'm not very experienced in using NHibernate so forgive if I overlook the obvious...

Thanks for any help
Urs


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 2:55 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
I've seen other systems where the password property is not mapped to the database but an "encrypted_password" property is. You should be able to assign the encrypted value to that (private) property on save/update. I haven't seen any that decrypt the password (all the ones I've seen use one-way encryption) but it seems you've got that handled anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 11:25 am 
Newbie

Joined: Tue Jul 10, 2007 11:23 am
Posts: 1
I have the same issue and according to the debugger, my breakpoints within Save and Update are not being hit. This is a problem with the ILifecycle interface, rather than encryption.

Is anyone familiar with the ILifecycle interface who may be able to tell us what we're doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 29, 2008 3:55 pm 
Newbie

Joined: Fri Jan 18, 2008 7:45 pm
Posts: 18
Location: Eugene, OR
Use IInterceptor

http://forum.hibernate.org/viewtopic.php?p=2365882#2365882

_________________
Woil / Will Shaver / http://primedigit.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.