SHA 256 Password Encryption - Not Working

Hi,

I am trying to implement Sha 256 password encryption algorithm. As stated in forums followed below steps.

  1. created a bean and implemented below methods.
  2. added bean definition in spring.xml
  3. added the property in app.properties
    cuba.legacyPasswordEncryptionModule = bpd_Sha256EncryptionService
  4. Below is the sample code written in custom bean.

**@Service(Sha256EncryptionService.NAME)
public class Sha256EncryptionServiceBean implements Sha256EncryptionService {

@Override
public HashDescriptor getHash(String content) {
    return  null;
}

@Override
public String getHashMethod() {
    return "bcrypt";
}

@Override
public String getPlainHash(String content) {
    return "$2a$10$vQx8b8B7jzZ0rQmtuK4YDOKp7nkmUCFjPx6DMT.voPtetNHFOsaOu";
}

@Override
public String getHash(String content, String salt) {
    return "$2a$10$vQx8b8B7jzZ0rQmtuK4YDOKp7nkmUCFjPx6DMT.voPtetNHFOsaOu";
}

@Override
public String getPasswordHash(UUID userId, String password) {
    return "$2a$10$vQx8b8B7jzZ0rQmtuK4YDOKp7nkmUCFjPx6DMT.voPtetNHFOsaOu";
}

@Override
public boolean checkPassword(User user, String rawPassword) {
    return true;
}**

facing the below error during startup.

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type ‘com.touchngo.raptor.service.Sha256EncryptionServiceBean’ to required type ‘com.haulmont.cuba.core.sys.encryption.EncryptionModule’ for property ‘legacyEncryptionModule’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘com.touchngo.raptor.service.Sha256EncryptionServiceBean’ to required type ‘com.haulmont.cuba.core.sys.encryption.EncryptionModule’ for property ‘legacyEncryptionModule’: no matching editors or conversion strategy found

Please share the sample project

above issue was resolved by implementing the bean EncryptionModule
public class Sha256EncryptionServiceBean implements EncryptionModule {

Outstanding issue is below property is not chosing the defined encryption bean. by default it’s chosing bcrypt

#cuba.legacyPasswordEncryptionModule = bpd_Sha256EncryptionService
cuba.legacyPasswordEncryptionModule = cuba_Sha1EncryptionModule

Issue resolved after changing the prperty to
cuba.passwordEncryptionModule = bpd_Sha256EncryptionService