context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); context.setAuthenticationStrategy(tlsAuthenticationStrategy); break;
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); context.setAuthenticationStrategy(tlsAuthenticationStrategy); break;
void setTls(LdapContextSource ldapContextSource) { // set tls logger.debug("Ldap TLS enabled."); DefaultTlsDirContextAuthenticationStrategy tls = new DefaultTlsDirContextAuthenticationStrategy(); tls.setHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }); tls.setSslSocketFactory(new DummySSLSocketFactory()); ldapContextSource.setAuthenticationStrategy(tls); }
protected void setAdditionalContextSourceProperties(LdapContextSource ctx, final String dnsName) { DigestMd5DirContextAuthenticationStrategy authenticationStrategy = new DigestMd5DirContextAuthenticationStrategy(); // authenticationStrategy.setHostnameVerifier(new HostnameVerifier() { // public boolean verify(String hostname, SSLSession session) { // return hostname.equals(dnsName); // } // }); ctx.setAuthenticationStrategy(authenticationStrategy); ctx.setPooled(false); } }
protected void setAdditionalContextSourceProperties(LdapContextSource ctx, final String dnsName) { DefaultTlsDirContextAuthenticationStrategy authenticationStrategy = new DefaultTlsDirContextAuthenticationStrategy(); authenticationStrategy.setHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return hostname.equals(dnsName); } }); ctx.setAuthenticationStrategy(authenticationStrategy); ctx.setPooled(false); } }
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); context.setAuthenticationStrategy(tlsAuthenticationStrategy); break;
/** * Creates an LdapContext from a configuration object. * * @param ldapConfig */ public static LdapContextSource createLdapContext(LDAPBaseSecurityServiceConfig ldapConfig) { LdapContextSource ldapContext = new DefaultSpringSecurityContextSource(ldapConfig.getServerURL()); ldapContext.setCacheEnvironmentProperties(false); ldapContext.setAuthenticationSource(new SpringSecurityAuthenticationSource()); if (ldapConfig.isUseTLS()) { // TLS does not play nicely with pooled connections ldapContext.setPooled(false); DefaultTlsDirContextAuthenticationStrategy tls = new DefaultTlsDirContextAuthenticationStrategy(); tls.setHostnameVerifier( new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }); ldapContext.setAuthenticationStrategy(tls); } return ldapContext; }
context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); break; case LDAPS: context.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy()); context.setAuthenticationStrategy(tlsAuthenticationStrategy); break;