package com.eactive.eai.custom.kjb.common.spring;

import com.eactive.ext.kjb.safedb.SafeDBWrapper;
import org.springframework.security.crypto.password.PasswordEncoder;


public class KjbSafedbPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        SafeDBWrapper safedb = SafeDBWrapper.getInstance();
        return safedb.encryptPswd(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        SafeDBWrapper safedb = SafeDBWrapper.getInstance();
        String encoded = safedb.encryptPswd(rawPassword.toString());
        return encoded.equals(encodedPassword);
    }
}
