抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

shiro有个AbstractAuthenticator类,作为验证器的基类。它有一个方法作为鉴权方法

1
2
protected abstract AuthenticationInfo doAuthenticate(AuthenticationToken token)
throws AuthenticationException;

ModularRealmAuthenticator继承AbstractAuthenticator类,负责多Realm的鉴权策略选择。

1
2
3
4
5
6
7
8
9
protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationToken) throws AuthenticationException {
assertRealmsConfigured();
Collection<Realm> realms = getRealms();
if (realms.size() == 1) {
return doSingleRealmAuthentication(realms.iterator().next(), authenticationToken);
} else {
return doMultiRealmAuthentication(realms, authenticationToken);
}
}

shiro通过继承AuthorizingRealm来实现一个Realm,作为鉴权数据类。例如DbShiroRealm extends AuthorizingRealm,实现数据库鉴权类。JWTShiroRealm extends AuthorizingRealm实现JWT鉴权类。

评论