今天看了下shiro 的代码
1)pom.xml的引入
2)web.xml的引入路径,在web.xml里面配置权限页面路径
3)跟着路径找到applicationContext-shiro.xml
4)进入applicationContext-shiro.xml
然后进入到自己写的realms的相关类里面,该类继承了AuthorizingRealm类,重写里面的方法
doGetAuthorizationInfo 是为用户加Role、permission的
1、检查提交的进行认证的令牌信息
2、根据令牌信息从数据源(数据库)中获取用户信息
3、对用户信息进行匹配验证
4、验证通过将返回一个封装了用户信息的AuthenticationInfo实例
5、验证失败则抛出AuthenticationException异常信息
doGetAuthenticationInfo 是为认证用户的正确性,如登陆认证
这个方法里面有个SimpleAuthenticationInfo后面跟着三个参数,最后一个参数如下解释
-
返回:
-
the (application-unique) name assigned to this
Realm
-
- 我断点运行代码得到的getName()的结果是 com.gatz.discovery.core.security.SecurityRealm_0