调用自定义Realm之后
执行方法:doGetAuthenticationInfo()方法后返回AuthenticationInfo
Realm是shiro中进行认证和授权的组件,自带了几种实现。自定义Realm继承
AuthorizingRealm,分别实现认证和授权的方法
doGetAuthenticationInfo
(AuthenticationToken t
oken
)是认证的方法,当用户登陆的时候会调用
doGetAuthorizationInfo
(AuthenticationToken t
oken
)是授权的方法,在拦截器中进行权限校验的时候会调用。
1.密码比对:在认证的方法中
doGetAuthenticationInfo
(AuthenticationToken t
oken
)把获取到的账号密码封装到SimpleAuthenticationInfo对象中返回。密码的比对:通过 AuthenticatingRealm 的 credentialsMatcher 属性来进行的密码的比对,默认的凭证匹配器是
SimpleCredentialsMatcher。
代码:
1.自定义Realm的