I managed to implement an automatic encrypted field in my NHibernate mapping project following this snippet: https://gist.github.com/jfromaniello/1941179
I added a custom type def in ED named "Encrypted", and assigned it to the property I want to store in encrypted format ("SmtpPassword") through the "User Converter Type" in the Properties window, because I need the type of the class property to remains a string.
Yuo can refer also to http://nhibernate.info/blog/2009/02/21/ ... rnate.html
The generated code was:
"MyProjectName.hbm.xml":
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping schema="dbo" assembly="MyAssemblyName" namespace="MyNameSpace" xmlns="urn:nhibernate-mapping-2.2">
<typedef name="Encrypted" class="MyNameSpace.EncryptedString, MyAssemblyName">
<param name="encryptor">MyNameSpace.AESEncryptor, MyAssemblyName</param>
<param name="encryptionKey">my_strong_password</param>
</typedef>
</hibernate-mapping>
Code: Select all
<property name="SmtpPassword" type="Encrypted">
<column name="SmtpPassword" not-null="false" length="100" sql-type="NVARCHAR(100)" />
</property>
If I move the typedef node in MyClass.hbm.xml file, immediately before the "class" node, it works perfectly."Could not determine type for: MyNameSpace.EncryptedString, MyAssemblyName, for columns: NHibernate.Mapping.Column(SmtpPassword)"
Is this a bug or I'm missing something?
I'm using ED version 5.8.846
Please note: I don't want to specify the class full qualifier name in the "type" property of the "SmtpPassword" field because in this way I can't make use of the additional parameters defined in typedef.
Thank you.