private void initializeAuthenticator(DefaultSecurityManager dsm) { //((AbstractAuthenticator) dsm.getAuthenticator()).setAuthenticationListeners(authenticationListeners); if(dsm.getAuthenticator() instanceof ModularRealmAuthenticator) { ((ModularRealmAuthenticator) dsm.getAuthenticator()).setAuthenticationStrategy(new FirstSuccessfulStrategy()); } }
private void initializeAuthenticator(DefaultSecurityManager dsm) { if(dsm.getAuthenticator() instanceof ModularRealmAuthenticator) { ((ModularRealmAuthenticator) dsm.getAuthenticator()).setAuthenticationStrategy(new FirstSuccessfulStrategy()); } }
/** * Shiro默认提供了三种 AuthenticationStrategy 实现: * AtLeastOneSuccessfulStrategy :其中一个通过则成功。 * FirstSuccessfulStrategy :其中一个通过则成功,但只返回第一个通过的Realm提供的验证信息。 * AllSuccessfulStrategy :凡是配置到应用中的Realm都必须全部通过。 * authenticationStrategy * */ @Bean(name = "authenticationStrategy") public AuthenticationStrategy authenticationStrategy() { return new FirstSuccessfulStrategy(); }