zoukankan      html  css  js  c++  java
  • 整合shiro+jwt大体思路

    springboot整合shiro大体上的思路:

    1.自定义一个类Realm extends AuthorizingRealm{}

    主要是对token授权和认证

    重写2个方法

    doGetAuthorizationInfo  //授权
    doGetAuthenticationInfo  //认证
    认证 代码中手动加上对token校验的判断

    2.自定义一个@Configuration类ShiroConfig

    ShiroConfig类主要做3个事情

    将自定义的Realm注册bean

    将realm对象与securityManager对象关联  

    securityManager.setRealm(realm);

    将securityManager对象与ShiroFilterFactoryBean对象关联

    shiroFilterFactoryBean.setSecurityManager(getDefaultWebSecurityManager);

    3.整合jwt

    先定义公共类JwtUtils

    其中定义三个方法 作用分别为token生成  token校验  token是否过期

    在realm类的认证doGetAuthenticationInfo方法中调用JwtUtils解析token和登录用户是否满足条件

    满足则返回AuthenticationInfo对象 对象中包含profile token name

    (只需要定义个profile就好了  profile就是登录的用户信息  可以再定义一个用户实体类  把用户信息放入实体类中那这个对象类就是profile)

    边学边整理思路  详细的得边敲边看代码






  • 相关阅读:
    20171121
    20171117
    20171106
    20171031
    20171024
    20170924
    20170721
    商品的分类
    会员价格的修改
    会员价格删除
  • 原文地址:https://www.cnblogs.com/hbhb/p/14212184.html
Copyright © 2011-2022 走看看