I have a custom user type that encrypts values to store passwords and
other sensitive information in the database, but I also have an
auditing feature using event listeners similar to this example:
http://ayende.com/Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp-ipreinserteventlistener.aspx.

This combination means that the audit log can now track changes to
user passwords, which I don’t think is a good idea.  We need the tech
support staff to use the audit log to see the changes our users make,
but I don’t want them to see the user’s passwords.

I was hoping to use the ILoggableUserType interface to control how
values get audited but it doesn’t seem to work and my suspicion is
that it isn’t meant to be used this way.  I added the interface to my
encrypted user type and implemented the ToLoggableString method.

public string ToLoggableString(object value,
ISessionFactoryImplementor factory) {
    return "<Encrypted Value>";
}

Then in the auditing event listener where I persist to the audit log,
I use this to try and get the ToLoggableString value, which should be
for the encrypted user type “<Encrypted Value>”.

for (int i = 0; i < updateEvent.OldState.Length; i++) {
   System.Diagnostics.Debug.WriteLine(
      updateEvent.Persister.PropertyTypes[i].ToLoggableString(
         updateEvent.OldState[i],
         updateEvent.Session.Factory));
}

But this writes out the unencrypted password and the ToLoggableString
method in the encrypted user type isn’t called.

What am I missing in the ILoggableUserType interface and getting the
ToLoggableString method?

Is there another way to not audit the encrypted values?

Thanks
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to