Fixed the url settings to only call the toArray. Plus I changed one of the tests to use the single value style

Original commit: elastic/x-pack-elasticsearch@16326d2b6c
This commit is contained in:
c-a-m 2014-10-22 10:33:52 -06:00
parent f517a6a8f3
commit 4b0f7c4379
3 changed files with 2 additions and 13 deletions

View File

@ -48,14 +48,7 @@ public class ActiveDirectoryConnectionFactory extends AbstractComponent implemen
} }
userSearchDN = componentSettings.get(AD_USER_SEARCH_BASEDN_SETTING, buildDnFromDomain(domainName)); userSearchDN = componentSettings.get(AD_USER_SEARCH_BASEDN_SETTING, buildDnFromDomain(domainName));
String[] ldapUrls = componentSettings.getAsArray(URLS_SETTING); String[] ldapUrls = componentSettings.getAsArray(URLS_SETTING, new String[] { "ldaps://" + domainName + ":636"});
if (ldapUrls == null) {
String url = componentSettings.get(URLS_SETTING);
ldapUrls = url == null ? null : new String[]{url};
}
if (ldapUrls == null) {
ldapUrls = new String[] { "ldaps://" + domainName + ":636" };
}
ImmutableMap.Builder<String, Serializable> builder = ImmutableMap.<String, Serializable>builder() ImmutableMap.Builder<String, Serializable> builder = ImmutableMap.<String, Serializable>builder()
.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory") .put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")

View File

@ -48,10 +48,6 @@ public class StandardLdapConnectionFactory extends AbstractComponent implements
throw new ShieldException("Missing required ldap setting [" + USER_DN_TEMPLATES_SETTING + "]"); throw new ShieldException("Missing required ldap setting [" + USER_DN_TEMPLATES_SETTING + "]");
} }
String[] ldapUrls = componentSettings.getAsArray(URLS_SETTING); String[] ldapUrls = componentSettings.getAsArray(URLS_SETTING);
if (ldapUrls == null) {
String url = componentSettings.get(URLS_SETTING);
ldapUrls = url == null ? null : new String[]{url};
}
if (ldapUrls == null) { if (ldapUrls == null) {
throw new ShieldException("Missing required ldap setting [" + URLS_SETTING + "]"); throw new ShieldException("Missing required ldap setting [" + URLS_SETTING + "]");
} }

View File

@ -114,7 +114,7 @@ public class ActiveDirectoryFactoryTests extends ElasticsearchTestCase {
public static Settings buildAdSettings(String ldapUrl, String adDomainName) { public static Settings buildAdSettings(String ldapUrl, String adDomainName) {
return ImmutableSettings.builder() return ImmutableSettings.builder()
.putArray(SETTINGS_PREFIX + ActiveDirectoryConnectionFactory.URLS_SETTING, ldapUrl) .put(SETTINGS_PREFIX + ActiveDirectoryConnectionFactory.URLS_SETTING, ldapUrl)
.put(SETTINGS_PREFIX + ActiveDirectoryConnectionFactory.AD_DOMAIN_NAME_SETTING, adDomainName) .put(SETTINGS_PREFIX + ActiveDirectoryConnectionFactory.AD_DOMAIN_NAME_SETTING, adDomainName)
.build(); .build();
} }