Spring Security, How do I grab the attempted username trying to log in?

限于喜欢 提交于 2019-12-02 16:53:36

问题


I have this class:

public class CustomPasswordEncoder implements PasswordEncoder {

@Autowired 
private JdbcTemplate jdbcTemplate;

@Inject
private PasswordEncoder passwordEncoder;

public String encode(CharSequence rawPassword) {

    String hashedPass;
    String userLogin;
    String encryptedPassword;

    sql = "select PasswordHash('?','?') from dual";

    hashedPass = (String)getJdbcTemplate().queryForObject(
        sql, new Object[] { userLogin,rawPassword }, String.class);

    encryptedPassword = passwordEncoder.encode(hashedPass);

    return encryptedPassword;
 }
}

What I need to do is get the USERNAME from the form and have it in the userLogin variable. I am finding it quite difficult to get the username from the form into this customized PasswordEncoder

来源:https://stackoverflow.com/questions/38136228/spring-security-how-do-i-grab-the-attempted-username-trying-to-log-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!