zoukankan      html  css  js  c++  java
  • 加匹配器到认证策略中

    DefaultWebSecurityManager defaultWebSecurityManager=new DefaultWebSecurityManager();
            //创建凭证匹配器
            HashedCredentialsMatcher matcher=new HashedCredentialsMatcher();
            //设置匹配器加密算法
            matcher.setHashAlgorithmName("md5");
            //设置匹配器迭代次数
            matcher.setHashIterations(2);
            //将匹配器注入到自定义认证策略中
            myRealm.setCredentialsMatcher(matcher);
    

      

     //获取用户信息
            Object principal = token.getPrincipal();
            //根据用户名获取数据库中用户信息
            User user = userService.selUserInfoService((String) principal);
            if(user!=null){
                AuthenticationInfo info = new SimpleAuthenticationInfo(principal, user.getPwd(), ByteSource.Util.bytes(user.getUid()+""),user.getUname());
                return info;
            }
    

      方法是讲前台数据传来的pwd通过md5加密与数据库中用户的加密后的密码进行对比

  • 相关阅读:
    Go语言http之请求接收和处理 代码
    C++之IO流的状态以及使用
    C++之指向函数的指针
    C++之数组类型的形参
    C++之vector类型的形参
    C++之形参
    C++之运算符
    C++之多维数组
    C++之动态数组
    C++之指针
  • 原文地址:https://www.cnblogs.com/vincentmax/p/14355871.html
Copyright © 2011-2022 走看看