无名 发表于 2022-5-8 17:02:42

【LSP】shiro认证流程源码分析


http://cdn.u1.huluxia.com/g4/M01/65/82/rBAAdl91St2AS-y1AACt4WdlvYs523.jpg
shiro认证流程源码分析

(1)输入用户名和密码进行登录

UsernamePasswordToken token=new UsernamePasswordToken(username,password);http://cdn.u1.huluxia.com/g4/M01/65/82/rBAAdl91St2ADeINAAASZP4NThE351.png



(2)下一步

subject.login(token);
(3)查看login源码
shiro认证流程源码分析

http://cdn.u1.huluxia.com/g4/M01/65/82/rBAAdl91St6ANbrkAAI1mEtoAeo637.jpg
(6)authenticator.authenticate(认证器)

http://cdn.u1.huluxia.com/g4/M01/65/82/rBAAdl91St6Ac29lAAE7M_kuosM486.jpg
(7)doAuthenticate

在这里完成realm的加载

    protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationToken) throws AuthenticationException {
      this.assertRealmsConfigured();//确认配置了realm
      Collection<Realm> realms = this.getRealms();//或取到所有的realm
      return realms.size() == 1 ? this.doSingleRealmAuthentication((Realm)realms.iterator().next(), authenticationToken) :      this.doMultiRealmAuthentication(realms, authenticationToken);//realms就是认证的时候会执行的realm
    }//一个realm就执行单realm认证,否则执行多realm
页: [1]
查看完整版本: 【LSP】shiro认证流程源码分析