Shiro身份验证最详细的代码流转分析

Shiro身份验证流转分析

【冯立雄】的身份验证流转分析,一步步debug下来的
1.ShiroHandler.login(token);
2.DelegatingSubject.login(token);
3.securityManager.login(this, token);
4.DefaultSecurityManager.login(subject,token);
5.AuthenticatingSecurityManager.authenticate(token);
6.AbstractAuthenticator.authenticate(token);
----------------------------------------------------
7.ModularRealmAuthenticator.doAuthenticate(token);
    Collection<Realm> realms = getRealms();
    if (realms.size() == 1) {
        return doSingleRealmAuthentication(realms.iterator().next(), authenticationToken);
    } else {
        return doMultiRealmAuthentication(realms, authenticationToken);
    }
8.ModularRealmAuthenticator.doMultiRealmAuthentication
  for (Realm realm : realms) {
     aggregate = strategy.beforeAttempt(realm, token, aggregate);
      if (realm.supports(token)) {
          AuthenticationInfo info = realm.getAuthenticationInfo(token);
      9.AuthenticatingRealm.getAuthenticationInfo(token)
    AuthenticationInfo info = getCachedAuthenticationInfo(token);
    if (info == null) {
        info = doGetAuthenticationInfo(token);
        if (token != null && info != null) {
            cacheAuthenticationInfoIfPossible(token, info);
        }
    }
    if (info != null) {
        assertCredentialsMatch(token, info);
    } else {
        log.debug("No AuthenticationInfo found for submitted AuthenticationToken [{}].  Returning null.", token);
    }
10.ShiroRealm.doGetAuthenticationInfo(token)  
11.AuthenticatingRealm.assertCredentialsMatch(token,info)
  CredentialsMatcher cm = getCredentialsMatcher();
  if (cm != null) {
      if (!cm.doCredentialsMatch(token, info)) {
          String msg = "Submitted credentials for token [" + token + "] did not match the expected credentials.";
          throw new IncorrectCredentialsException(msg);
      }
  } else {
      throw new AuthenticationException("A CredentialsMatcher must be configured in order to verify " +
              "credentials during authentication.  If you do not wish for credentials to be examined, you " +
              "can configure an " + AllowAllCredentialsMatcher.class.getName() + " instance.");
  }
12.HashedCredentialsMatcher.doCredentialsMatch(token,info)
  Object tokenHashedCredentials = hashProvidedCredentials(token, info);
  Object accountCredentials = getCredentials(info);
  return equals(tokenHashedCredentials, accountCredentials);
13.AbstractAuthenticator.authenticate(token);--->6
-------------------------------------------------------------------------------
14.AbstractAuthenticator.notifySuccess(token, info);  
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花生糖葫芦侠

创作不易,请多多支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值