How to get a hashed string value in/into a Java action.

0
I am currently working on password management in the app I am working on in Mendix Studio Pro 10.6.9. The following functionality is required: A user's password must expire after 30 days. The new password may not be the same as the user's last 10 passwords.   I have created a new entity that stores the user’s passwords: Entity: PasswordManagement Attribute: PasswordHistory (hashed string) Attribute: CreatedDate Association: System.User   I have created a Java action that is passed the ‘PasswordManagement’ list and a ‘newpassword’ string. The function of the Java action is to compare the ‘newpassword’ string against each ‘PasswordHistory’ hashed string in the ‘PasswordManagement’ to check whether they match or not.   I am using the ‘verifyValue’ method (MendixHashString):   verifyValue  boolean verifyValue(IContext context, String unhashedValue) Returns whether the specified unhashed value matches the value of this attribute. Parameters: context - the context for accessing the attribute unhashedValue - the value to hash and compare against the value of this attribute Returns: true if the value matches; false otherwise   The issue is that the ‘PasswordHistory’ attribute cannot be accessed from within the Java code – as in, when running the debugger in Eclipse, ‘PasswordHistory’ returns ‘empty’.   I think it would help knowing how Mendix executes the ‘authenticate’ method used in the ‘verifyPassword’ Java action.   If anyone has any insights – please share, it will be greatly appreciated!
asked
1 answers
0

Hello Keyoma,

 

Have you checked out the verifypassword java action of the system module and how they do it there?

image.png

image.png

Hope this helps,

 

Good luck!

answered