Page 1 of 1

Encrypted System Setting

PostPosted: Thu May 27, 2021 9:38 am
by pricerc
If I want to encrypt a system setting in a plugin, where do I encrypt the text?

I can mask the UI in FormatCell, and Decrypt in ReadData, but where would I *Encrypt* the text before it saves to the DB?

As I'm asking this, I'm figuring I'll need to popup a dialog to prompt for a new password, and then not bother with the decryption in ReadData - i.e. leave no way for the user to see the current password, which is not necessarily a bad thing for the scenario I'm working with.

Re: Encrypted System Setting

PostPosted: Sat May 29, 2021 12:27 am
by SBarnes
Hi Ryan,

Unless I am missing what you are asking why not do a form plugin on JiwaFinancials.Jiwa.JiwaSystemSettingsUI.frmMain its business logic property is JiwaFinancials.Jiwa.JiwaApplication.SystemSettings.SystemSettings and hook onto its save start event and simply do it there?

Re: Encrypted System Setting

PostPosted: Mon May 31, 2021 10:52 am
by pricerc
SBarnes wrote:Hi Ryan,

Unless I am missing what you are asking why not do a form plugin on JiwaFinancials.Jiwa.JiwaSystemSettingsUI.frmMain its business logic property is JiwaFinancials.Jiwa.JiwaApplication.SystemSettings.SystemSettings and hook onto its save start event and simply do it there?


Hmmm. I hadn't thought about it from that direction - but since my plugin doesn't already attach to an existing form that could work.

I might still raise a suggestion for allowing, say, 'Password' as a system setting type - JiwaEncryption provides all the necessary hooks, and it would make it easier to 'obfuscate' what's happening.

Re: Encrypted System Setting

PostPosted: Mon May 31, 2021 1:19 pm
by pricerc
SBarnes wrote:simply do it there?


So I had a bit of a play with this idea. I suppose it's reasonably 'simple'. But it's not very obvious, and a bit 'clunky'.

If you hook into JiwaSystemSettingsUI.frmMain, you're hooking into *every* system setting on the system, not just *your* plugin's settings.

So within your intercepted read/save methods, you need to find 'your' settings, and then find the field you're wanting to intercept. And then you need to modify 'Contents', which will trigger a PropertyChanged event. And it would also mean that there is an 'unencrypted' password lurking around in memory (I don't think that's a real-world problem for my scenario, but it is a thing that people worry about).

Being able to intercept the 'Save' inside SystemSettingPlugin would be much cleaner.

So I'm going to stick with popping up a dialog from inside SystemSettingPlugin.

Re: Encrypted System Setting  Topic is solved

PostPosted: Mon May 31, 2021 3:16 pm
by Mike.Sheen
pricerc wrote:Being able to intercept the 'Save' inside SystemSettingPlugin would be much cleaner.


Logged as improvement DEV-8740

Re: Encrypted System Setting

PostPosted: Mon May 31, 2021 3:27 pm
by pricerc
Mike.Sheen wrote:
pricerc wrote:Being able to intercept the 'Save' inside SystemSettingPlugin would be much cleaner.


Logged as improvement DEV-8740


Thanks Mike.