/**
* Gets parameters of LDAP server to connect to
* @return LdapServerProperties object representing connection parameters
*/
public LdapServerProperties getLdapServerProperties() {
LdapServerProperties ldapServerProperties = new LdapServerProperties();
ldapServerProperties.setPrimaryUrl(properties.getProperty(
LDAP_PRIMARY_URL_KEY, LDAP_PRIMARY_URL_DEFAULT));
ldapServerProperties.setSecondaryUrl(properties.getProperty(
LDAP_SECONDARY_URL_KEY));
ldapServerProperties.setUseSsl("true".equalsIgnoreCase(properties.
getProperty(LDAP_USE_SSL_KEY)));
ldapServerProperties.setAnonymousBind("true".
equalsIgnoreCase(properties.getProperty(LDAP_BIND_ANONYMOUSLY_KEY,
LDAP_BIND_ANONYMOUSLY_DEFAULT)));
ldapServerProperties.setManagerDn(properties.getProperty(
LDAP_MANAGER_DN_KEY));
String ldapPasswd = readPasswordFromStore(properties
.getProperty(LDAP_MANAGER_PASSWORD_KEY));
if (ldapPasswd != null) {
ldapServerProperties.setManagerPassword(ldapPasswd);
} else {
ldapServerProperties.setManagerPassword(properties.getProperty
(LDAP_MANAGER_PASSWORD_KEY));
}
ldapServerProperties.setBaseDN(properties.getProperty
(LDAP_BASE_DN_KEY, LDAP_BASE_DN_DEFAULT));
ldapServerProperties.setUsernameAttribute(properties.
getProperty(LDAP_USERNAME_ATTRIBUTE_KEY, LDAP_USERNAME_ATTRIBUTE_DEFAULT));
ldapServerProperties.setGroupBase(properties.
getProperty(LDAP_GROUP_BASE_KEY, LDAP_GROUP_BASE_DEFAULT));
ldapServerProperties.setGroupObjectClass(properties.
getProperty(LDAP_GROUP_OBJECT_CLASS_KEY, LDAP_GROUP_OBJECT_CLASS_DEFAULT));
ldapServerProperties.setGroupMembershipAttr(properties.getProperty(
LDAP_GROUP_MEMEBERSHIP_ATTR_KEY, LDAP_GROUP_MEMBERSHIP_ATTR_DEFAULT));
ldapServerProperties.setGroupNamingAttr(properties.
getProperty(LDAP_GROUP_NAMING_ATTR_KEY, LDAP_GROUP_NAMING_ATTR_DEFAULT));
ldapServerProperties.setAdminGroupMappingRules(properties.getProperty(
LDAP_ADMIN_GROUP_MAPPING_RULES_KEY, LDAP_ADMIN_GROUP_MAPPING_RULES_DEFAULT));
ldapServerProperties.setGroupSearchFilter(properties.getProperty(
LDAP_GROUP_SEARCH_FILTER_KEY, LDAP_GROUP_SEARCH_FILTER_DEFAULT));
if (properties.containsKey(LDAP_GROUP_BASE_KEY) ||
properties.containsKey(LDAP_GROUP_OBJECT_CLASS_KEY) ||
properties.containsKey(LDAP_GROUP_MEMEBERSHIP_ATTR_KEY) ||
properties.containsKey(LDAP_GROUP_NAMING_ATTR_KEY) ||
properties.containsKey(LDAP_ADMIN_GROUP_MAPPING_RULES_KEY) ||
properties.containsKey(LDAP_GROUP_SEARCH_FILTER_KEY)) {
ldapServerProperties.setGroupMappingEnabled(true);
}
return ldapServerProperties;
}