在代码中,实际上已经将用户输入的密码与从数据库中查询的该用户的密码进行了比较认证。这一步是通过构建SimpleAuthenticationInfo对象时传入的参数完成的:

new SimpleAuthenticationInfo( user, //principal 身份 user.getPassword(),//hashedCredentials 已加密的密码 credentialsSalt,//credentialsSalt this.getName());//realmName

其中,第二个参数user.getPassword()就是从数据库中查询到的该用户的密码,而第一个参数user则是用户对象,会在后续的授权操作中使用。SimpleAuthenticationInfo对象的构建完成后,会被交给认证管理器(SecurityManager)进行认证。在认证过程中,认证管理器会比较用户输入的密码和SimpleAuthenticationInfo中的已加密密码是否一致,如果一致则认证通过,否则认证失败。

Override	protected AuthenticationInfo doGetAuthenticationInfo			AuthenticationToken token throws AuthenticationException 		1获取用户端输入的用户信息		UsernamePasswordToken upToken=UsernamePasswordToken token;		St

原文地址: https://www.cveoy.top/t/topic/fZFN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录