shrio,org.apache.shiro.authc.UsernamePasswordToken - gcu, rememberMe=false解决

Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - gcu, rememberMe=false].  Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).


 密码的加密方式是MD5,但是此时user的密码是明文密码,所以这样就会报错解决的办法就是将user的密码用MD5加密,就要就不会有问题了

传入密码:

               

public AuthenticationInfo doGetAuthenticationInfo(
			AuthenticationToken token) throws AuthenticationException {
		// TODO Auto-generated method stub
		String username = token.getPrincipal().toString();
		String password = new String((char[]) token.getCredentials());
		logger.info("用户进入登录验证" + username);
		String md5Pwd = ShiroKit.md5Pwd(password, username);
		// 判断用户是否存在
		User user = userService.queryUser(username, password);
		System.out.println(user.getNickname());


加密方式:   

     public static String md5Pwd(String password, String salt) {
        // TODO Auto-generated method stub
        String md5Pwd = new Md5Hash(password, salt).toHex();
        return md5Pwd;
    }


你可能感兴趣的:(shrio,org.apache.shiro.authc.UsernamePasswordToken - gcu, rememberMe=false解决)