public DirContextAuthenticationStrategy getAuthenticationStrategy() throws ClassNotFoundException, NoSuchAlgorithmException, IllegalAccessException, InstantiationException, KeyManagementException { if (!hasText(tlsConfig)) { tlsConfig = NONE; } AbstractTlsDirContextAuthenticationStrategy tlsStrategy; switch (tlsConfig) { case NONE: return new SimpleDirContextAuthenticationStrategy(); case SIMPLE: tlsStrategy = new DefaultTlsDirContextAuthenticationStrategy(); break; case EXTERNAL: tlsStrategy = new ExternalTlsDirContextAuthenticationStrategy(); break; default: throw new IllegalArgumentException(tlsConfig); } tlsStrategy.setHostnameVerifier(new AllowAllHostnameVerifier()); tlsStrategy.setSslSocketFactory(getSSLSocketFactory()); return tlsStrategy; } }
@Override @SuppressWarnings("rawtypes") public void setupEnvironment(Hashtable env, String dn, String password) { super.setupEnvironment(env, dn, password); // Remove the pooling flag unless we are authenticating as the 'manager' // user. if (!DefaultSpringSecurityContextSource.this.userDn.equals(dn) && env.containsKey(SUN_LDAP_POOLING_FLAG)) { DefaultSpringSecurityContextSource.this.logger .debug("Removing pooling flag for user " + dn); env.remove(SUN_LDAP_POOLING_FLAG); } } });
@Test public void testProcessContextAfterCreation() { Hashtable env = new Hashtable(); tested.processContextAfterCreation(null, "cn=John Doe", "pw"); assertThat(env.isEmpty()).isTrue(); }
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());
@Override @SuppressWarnings("unchecked") public void setupEnvironment(Hashtable env, String dn, String password) { super.setupEnvironment(env, dn, password); // Remove the pooling flag unless we are authenticating as the 'manager' user. if (!userDn.equals(dn) && env.containsKey(SUN_LDAP_POOLING_FLAG)) { logger.debug("Removing pooling flag for user " + dn); env.remove(SUN_LDAP_POOLING_FLAG); } } });
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());
@Override @SuppressWarnings("rawtypes") public void setupEnvironment(Hashtable env, String dn, String password) { super.setupEnvironment(env, dn, password); // Remove the pooling flag unless we are authenticating as the 'manager' // user. if (!DefaultSpringSecurityContextSource.this.userDn.equals(dn) && env.containsKey(SUN_LDAP_POOLING_FLAG)) { DefaultSpringSecurityContextSource.this.logger .debug("Removing pooling flag for user " + dn); env.remove(SUN_LDAP_POOLING_FLAG); } } });
@Before public void setUp() throws Exception { tested = new SimpleDirContextAuthenticationStrategy(); }
@Test public void testSetupEnvironment() { Hashtable env = new Hashtable(); tested.setupEnvironment(env, "cn=John Doe", "pw"); assertThat(env.get(Context.SECURITY_AUTHENTICATION)).isEqualTo("simple"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isEqualTo("cn=John Doe"); assertThat(env.get(Context.SECURITY_CREDENTIALS)).isEqualTo("pw"); }
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());