GUACAMOLE-102: Create a more global LDAPSearchConstraints in the ConfigurationService.

This commit is contained in:
Nick Couchman
2017-03-19 21:04:32 -04:00
parent b7fd01e02d
commit d1635ce28c

View File

@@ -20,16 +20,24 @@
package org.apache.guacamole.auth.ldap;
import com.google.inject.Inject;
import com.novell.ldap.LDAPSearchConstraints;
import java.util.Collections;
import java.util.List;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.environment.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Service for retrieving configuration information regarding the LDAP server.
*/
public class ConfigurationService {
/**
* Logger for this class.
*/
private final Logger logger = LoggerFactory.getLogger(ConfigurationService.class);
/**
* The Guacamole server environment.
*/
@@ -264,4 +272,30 @@ public class ConfigurationService {
}
/**
* Returns a set of LDAPSearchConstraints to apply globally
* to all LDAP searches rather than having various instances
* dispersed throughout the code. Currently contains the
* maximum number of LDAP results to return in a search, as
* well as whether or not aliases should be dereferenced
* during LDAP operations.
*
* @return
* A LDAPSearchConstraints object containing constraints
* to be applied to all LDAP search operations.
*
* @throws GuacamoleException
* If guacamole.properties cannot be parsed.
*/
public LDAPSearchConstraints getLDAPSearchConstraints() throws GuacamoleException {
LDAPSearchConstraints constraints = new LDAPSearchConstraints();
constraints.setMaxResults(getMaxResults());
constraints.setDereference(getDereferenceAliases());
return constraints;
}
}