class AuthenticationManagerImpl implements FactoryBean {

    public AuthenticationManager getObject() throws Exception {

        AuthenticationManager authenticationManager = null;

        for (AuthenticationManager authManager : this.authenticationManagers) {

            if (authManager instanceof AuthenticationManagerLdapImpl && ldapProviderEnabled) {
                authenticationManager = authManager;
            }
            if (authManager instanceof AuthenticationManagerDaoImpl && !ldapProviderEnabled) {
                authenticationManager = authManager;
            }
        }

        return authenticationManager;
    }

    public  AuthenticationManagerImpl(boolean ldapProviderEnabled, List<AuthenticationManager> authenticationManagers);

}