Shiro getAuthenticationInfo()中抛出异常, 全局异常处理却收不到自己抛出的异常中, 介绍了通过覆盖AuthenticationStrategy的afterAttempt方法, 更改Shiro的异常抛出逻辑.
本文介绍AuthenticationStrategy在验证过程中到底做了什么
想要弄清Strategy, 就要关注在ModularRealmAuthenticator.doMultiRealmAuthentication()的aggregate
protected AuthenticationInfo doMultiRealmAuthentication(Collection<Realm> realms,
AuthenticationToken token) {
// 获取验证策略
AuthenticationStrategy strategy = getAuthenticationStrategy();
**AuthenticationInfo aggregate = strategy.beforeAllAttempts(realms, token);**
// 循环遍历realm
for (Realm realm : realms) {
//
try {
**aggregate = strategy.beforeAttempt(realm, token, aggregate);**
} catch (ShortCircuitIterationException shortCircuitSignal) {
break;
}
if (realm.supports(token)) {