shiro mgt包下AuthenticatingSecurityManager类

2021SC@SDUSC

AuthenticatingSecurityManager继承于RealmSecurityManagerRealmSecurityManager继承于CachingSecurityManagerCachingSecurityManager实现了SecurityManager接口

AuthenticatingSecurityManager RealmSecurityManager CachingSecurityManager «interface» SecurityManager

Shiro 支持 SecurityManager 类层次结构,该类层次结构将所有身份验证操作委托给包装的 Authenticator 实例。
也就是说,这个类实现SecurityManager 接口中的所有 Authenticator
方法,但实际上,这些方法只是对底层“真实”Authenticator 实例的传递调用。

含有变量

private Authenticator authenticator

含有方法

  • public AuthenticatingSecurityManager
  • public AuthenticatorgetAuthenticator
  • public void setAuthenticator(Authenticator authenticator)
  • protected void afterRealmsSet()
  • public AuthenticationInfo authenticate(AuthenticationToken token)
  • public void destroy()

变量分析

authenticator
此 SecurityManager 实例将用于执行所有身份验证操作的内部 Authenticator mdelegate 实例。

方法分析

AuthenticatingSecurityManager

public AuthenticatingSecurityManager() {
super();
this.authenticator = new ModularRealmAuthenticator();
}
默认的构造方法

AuthenticatorgetAuthenticator

public Authenticator getAuthenticator() {
return authenticator;
}
获得变量authenticator

setAuthenticator

public void setAuthenticator(Authenticator authenticator) throws IllegalArgumentException {
if (authenticator == null) {
String msg = “Authenticator argument cannot be null.”;
throw new IllegalArgumentException(msg);
}
this.authenticator = authenticator;
}
手动设置变量authenticator

afterRealmsSet

protected void afterRealmsSet() {
super.afterRealmsSet();
if (this.authenticator instanceof ModularRealmAuthenticator) {
((ModularRealmAuthenticator) this.authenticator).setRealms(getRealms());
}
}
将realm传递给内部委托 Authenticator 实例,以便它可以在身份验证尝试期间使用它们。

authenticate

public AuthenticationInfo authenticate(AuthenticationToken token) throws AuthenticationException {
return this.authenticator.authenticate(token);
}
委托包装好的 Authenticator 进行身份验证。

destroy

public void destroy() {
LifecycleUtils.destroy(getAuthenticator());
this.authenticator = null;
super.destroy();
}
销毁authenticator对象

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值