javapolymercuba-platform

Encryption method for cuba platform


Cuba has its own backend system to add users. Now I need to write a user registration in the front-end. The Cuba version I am using is 6.9 I know that this version of encryption is SHA1 : https://doc.cuba-platform.com/manual-6.9/login.html Now my question is : I don't know how to set the encrypted password to the database.

I create an entity through the Metadata

User user = metadata.create(User.class);
user.setPassword(passWord);

Solution

  • I'm not sure that's the best option but I used the following code:

    @Inject
    protected PasswordEncryption passwordEncryption;
    
    ...
    
    user.setPassword(passwordEncryption.getPasswordHash(user.getId(), password));