AuthenticationStrategy接口源码解析

AuthenticationStrategy认证策略接口主要是实现各种认证的策略,目前所有的认证策略包括(FirstSuccessfulStrategy(只要有一个Realm验证成功即可,只返回第一个Realm身份验证成功的认证信息,其他的忽略);AtLeastOneSuccessfulStrategy(只要有一个Realm验证成功即可,和FirstSuccessfulStrategy不同,返回所有Realm身份验证成功的认证信息);AllSuccessfulStrategy(所有Realm验证成功才算成功,且返回所有Realm身份验证成功的认证信息,如果有一个失败就失败了)),先对其解析如下:

1.所有的认证之前的操作

AuthenticationInfo beforeAllAttempts(Collection<? extends Realm> realms, AuthenticationToken token) throws AuthenticationException;

2.某一个realm认证之前的操作

AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException;

3.某一个realm认证之后的操作

AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t)
            throws AuthenticationException;

4.所有的认证之后的操作

AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException;

猜你喜欢

转载自yansxjl.iteye.com/blog/2333953
今日推荐