Encrypted properties in businees object?
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Encrypted properties in businees object? Expand / Collapse
Author
Message
Posted 2008-06-11 14:17:09
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2008-06-15 10:39:00
Posts: 5, Visits: 6
Hi there,

Is that possible to implement encrypted properties in class?

What i mean is - We have a class like this one:

class User

{

public string Name{

get{};

set{};

}

}

On object level property Name will be string, but on DB level it will be encripted with some symmetric Key. Each time I read/write User.Name property it will encrypted/decrypted automaticaly by ECO engine.

Is that possible?

Thanks

Post #133
Posted 2008-06-11 17:51:45
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 16:25:35
Posts: 137, Visits: 411
Good question.
My opinion is - you have to do something with PMP. Try PMP sources.
Encrypt/Decrypt is the DB responsibility

Might be I am wrong.

Regards,
Alex
Post #136
Posted 2008-06-12 01:08:04
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2009-12-21 19:09:25
Posts: 111, Visits: 839
Hi nikulin_andrey,

You could achieve that by creating a custom PersistenceMapper.

This can be done by adding a new item int the PMP.cs > PersistenceMapperSqlServer > SqlDataBaseConfig > PersistenceMappers witch is a collection. This is a collection of PersistenceMapperDefinition objects. Each object holds a Name and a Type for an specific persistence mapper.

You will notice that there is one to Strings, Integers, DateTimes, etc. You can add a EncryptedString for instance.

Than, go to %PROGRAMFILES%\CapableObjects\ECO\4.0\source\Persistence\DefaultAttributeMappers.cs and take a look / copy the StringAsVarChar Mapper.

After customizing the mapper, adding the .cs file to your project, adding an entry to the PersistenceMappers Collection of your persistence mapper component, all you will need is to go to the model and change the PMapper property of the attribute you intend to encrypt to the one you just created.

I hope that this will help you.


--
Pedro Brown
pedro@tectrilha.com.br
Tectrilha Software - Borland Learning Partner
Post #137
Posted 2008-06-12 08:48:30
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 16:25:35
Posts: 137, Visits: 411
My colleague advised this:

1. Create crypt/decrypt dll
2. Add any methods to your class in ModelMaker. Generate code for this method
3. Write code to use your dll in this method. You can crypt/decrypt User.Name
4. ECO will save/load value

Something like this

Regards,
Alex
Post #138
Posted 2008-06-13 16:23:59
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2009-12-21 19:09:25
Posts: 111, Visits: 839
You can do that to.

I haven't thought that, but you can simply mark your attribute as 'Has user Code' and the put the encryption/decryption code in the get{} set{} methods.

Regards

--
Pedro Brown
pedro@tectrilha.com.br
Tectrilha Software - Borland Learning Partner

Post #141
Posted 2008-06-13 16:39:45
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2008-06-15 10:39:00
Posts: 5, Visits: 6
Hi all,

I have already found solution. Thanks to Pedro Brown for idea of custom percistance mapper.

I think I made quite interisting thing. I have got a class with some data which should be secure and only user created it can see data. So I encrypt secure properties and use user password as key for TripleDES algorithm. In the same time I dont store password in DB. I store login and encrypted login in DB. When user login in app I use password to decrypt login from DB to compare with entered login. If they are the same - success login etc.

Reason for that is nobody can access data except user saved it. Even developer and DB admin. But if you loose password you loose you data.

Nice!

Post #142
Posted 2008-06-13 17:52:26
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 16:25:35
Posts: 137, Visits: 411
Suggestion:

You can add private question/answer for users who forgot password
Post #143
Posted 2008-06-13 18:54:16
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2009-12-21 19:09:25
Posts: 111, Visits: 839
What would happend if the user decides to change his password?

Would you drill down your data and decrypt/re-encrypt all of it?

I see that the custom persistence mapper idea is too much, but it seems to me that the encryption/decryption code in the get{} set{} methods using a fixed key would be better.

Regards

--
Pedro Brown
pedro@tectrilha.com.br
Tectrilha Software - Borland Learning Partner

Post #144
Posted 2008-06-15 10:42:17
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2008-06-15 10:39:00
Posts: 5, Visits: 6
pedro_brown (2008-06-13)
What would happend if the user decides to change his password?

Would you drill down your data and decrypt/re-encrypt all of it?

Exactly.

I see that the custom persistence mapper idea is too much, but it seems to me that the encryption/decryption code in the get{} set{} methods using a fixed key would be better.

Regards

This method will make it possible for developer\db admin\any person who knows the key decrypt data and use it\sell it. Right?

In case with password as encryption key no one but user only can encrypt his data!

This is main point of application - total secure data!

Post #152
Posted 2008-06-15 10:43:33
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2008-06-15 10:39:00
Posts: 5, Visits: 6
guest00 (2008-06-13)
Suggestion:

You can add private question/answer for users who forgot password

It is impossible in my case because password is not saved in DB and some of user data is encrypted using password as a key!

Post #153
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: HansKarlsen, Jonas Hogstrom, PeterMorris

Permissions Expand / Collapse

All times are GMT +1:00, Time now is 11:53

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0,328. 7 queries. Compression Disabled.