shiro的认证流程中各个类之间的关系

1:SecurityManager有个默认的认证器:ModularRealmAuthenticator,但是我们可以给SecurityManager设置其他的认证器。

2:认证器ModularRealmAuthenticator有个默认的认证策略:AtLeastOneSuccessfulStrategy,但是我们可以给ModularRealmAuthenticator设置其他认证策略。

3:当调用SecurityManager的setRealm方法设置realm时,实际上最终都会设置到认证器Authenticator上,我们可以直接给Authenticator设置realm,并且可以设置多个realm(只有通过直接给认证器设置realm的方式才能设置多个realm)

4:没有继承AuthenticatingRealm的realm,账号和密码的比对都有realm自己完成,所以用不到CredentialsMatcher;继承AuthenticatingRealm的realm,在realm内部只比对账号,密码的比对交给CredentialsMatcher完成。

5:AuthenticatingRealm内部有个默认的CredentialsMatcher:SimpleCredentialsMatcher,用于比对明文密码,可以通过改变realm的CredentialsMatcher,来做到对别的类型的密码进行比对,例如:md5加盐的密文密码。

原文地址:https://www.cnblogs.com/hzcya1995/p/13302479.html