Spring不会使用多个
AuthenticationProvider身份验证请求,因此第一个(支持中的
ArrayList)
AuthenticationProvider支持
Authentication对象并成功身份验证请求的将是唯一使用的对象。在你的情况是
activeDirectoryLdapAuthenticationProvider。
ActiveDirectoryLdapAuthenticationProvider可以使用自定义AuthenticationProvider委托给LDAP并进行其他检查,而不是使用:
CustomerAuthenticationProvider implements AuthenticationProvider{ privtae ActiveDirectoryLdapAuthenticationProvider delegate; // add additional methods to initialize delegate during your configuration @Override public Authentication authenticate(Authentication auth) throws AuthenticationException { Authentication authentication= delegate.authenticate(auth); additionalChecks(authentication);return auth;} @Override public boolean supports(Class<?> authentication) { return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication); } public void additionalCheck(Authentication authentication){ // throw AuthenticationException when it's not allowed } }


