shiro吧 关注:321贴子:9,475
  • 5回复贴,共1

shiro多realm下登陆只抛出AuthenticationException

只看楼主收藏回复

大佬们 有人遇到shiro多realm下登陆只抛出AuthenticationException,不抛出其他异常的问题吗。。。


1楼2018-07-27 11:01回复
    楼主解决了吗


    IP属地:浙江2楼2019-01-15 09:38
    收起回复
      shiro认证的时候从数据库查出的用户密码为空,楼主知道怎么解决么


      IP属地:湖南来自Android客户端3楼2019-09-01 11:54
      回复
        楼主解决了吗~


        IP属地:北京4楼2020-03-06 19:40
        回复
          重写 ModularRealmAuthenticator 的 doMultiRealmAuthentication 方法
          @Override
          protected AuthenticationInfo doMultiRealmAuthentication(Collection<Realm> realms,
          AuthenticationToken token) throws AuthenticationException {
          AuthenticationStrategy strategy = getAuthenticationStrategy();
          AuthenticationInfo aggregate = strategy.beforeAllAttempts(realms, token);
          if (log.isTraceEnabled()) {
          log.trace("Iterating through {} realms for PAM authentication", realms.size());
          }
          AuthenticationException authenticationException = null;
          for (Realm realm : realms) {
          aggregate = strategy.beforeAttempt(realm, token, aggregate);
          if (realm.supports(token)) {
          log.trace("Attempting to authenticate token [{}] using realm [{}]", token, realm);
          AuthenticationInfo info = null;
          try {
          info = realm.getAuthenticationInfo(token);
          } catch (AuthenticationException e) {
          authenticationException = e;
          if (log.isDebugEnabled()) {
          String msg = "Realm [" + realm + "] threw an exception during a multi-realm authentication attempt:";
          log.debug(msg, e);
          }
          }
          aggregate = strategy.afterAttempt(realm, token, info, aggregate, authenticationException);
          } else {
          log.debug("Realm [{}] does not support token {}. Skipping realm.", realm, token);
          }
          }
          if(authenticationException != null){
          throw authenticationException;
          }
          aggregate = strategy.afterAllAttempts(token, aggregate);
          return aggregate;
          }


          IP属地:黑龙江5楼2020-12-03 09:02
          回复