您的位置:首页 > 其它

shiro认证过程Authenticator到realm,然后进行认证的过程

2016-11-04 12:58 316 查看
public final AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

AuthenticationInfo info = getCachedAuthenticationInfo(token);
if (info == null) {
//otherwise not cached, perform the lookup:
info = doGetAuthenticationInfo(token);//调用自定义realm认证方法
log.debug("Looked up AuthenticationInfo [{}] from doGetAuthenticationInfo", info);
if (token != null && info != null) {
cacheAuthenticationInfoIfPossible(token, info);
}
} else {
log.debug("Using cached authentication info [{}] to perform credentials matching.", info);
}

if (info != null) {
assertCredentialsMatch(token, info);//对token和info进行信息对比
} else {
log.debug("No AuthenticationInfo found for submitted AuthenticationToken [{}].  Returning null.", token);
}

return info;
}

AuthenticatingRealm抽象类中定义了这段代码显示了Authenticator调用自定义的realm,和realm返回AuthenticationInfo后,Authenticator再将用户提交的token信息和realm查询到的info信息进行对比,如果相同则认证成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: