mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-957: Use guacamole.properties alone for LDAP configuration if ldap-servers.yml is empty.
This commit is contained in:
@@ -67,8 +67,11 @@ public class ConfigurationService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The cached copy of the configuration read from {@link #LDAP_SERVERS_YML}.
|
* The cached copy of the configuration read from {@link #LDAP_SERVERS_YML}.
|
||||||
|
* If the current set of LDAP servers has not yet been read from the YAML
|
||||||
|
* configuration file, or if guacamole.properties is being used instead,
|
||||||
|
* this will be null.
|
||||||
*/
|
*/
|
||||||
private Collection<JacksonLDAPConfiguration> cachedConfigurations = Collections.emptyList();
|
private Collection<JacksonLDAPConfiguration> cachedConfigurations = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Guacamole server environment.
|
* The Guacamole server environment.
|
||||||
@@ -90,7 +93,7 @@ public class ConfigurationService {
|
|||||||
*/
|
*/
|
||||||
public Collection<? extends LDAPConfiguration> getLDAPConfigurations() throws GuacamoleException {
|
public Collection<? extends LDAPConfiguration> getLDAPConfigurations() throws GuacamoleException {
|
||||||
|
|
||||||
// Read configuration from YAML, if available
|
// Read/refresh configuration from YAML, if available
|
||||||
File ldapServers = new File(environment.getGuacamoleHome(), LDAP_SERVERS_YML);
|
File ldapServers = new File(environment.getGuacamoleHome(), LDAP_SERVERS_YML);
|
||||||
if (ldapServers.exists()) {
|
if (ldapServers.exists()) {
|
||||||
|
|
||||||
@@ -105,9 +108,15 @@ public class ConfigurationService {
|
|||||||
logger.debug("Reading updated LDAP configuration from \"{}\"...", ldapServers);
|
logger.debug("Reading updated LDAP configuration from \"{}\"...", ldapServers);
|
||||||
Collection<JacksonLDAPConfiguration> configs = mapper.readValue(ldapServers, new TypeReference<Collection<JacksonLDAPConfiguration>>() {});
|
Collection<JacksonLDAPConfiguration> configs = mapper.readValue(ldapServers, new TypeReference<Collection<JacksonLDAPConfiguration>>() {});
|
||||||
|
|
||||||
logger.debug("Reading LDAP configuration defaults from guacamole.properties...");
|
if (configs != null) {
|
||||||
LDAPConfiguration defaultConfig = new EnvironmentLDAPConfiguration(environment);
|
logger.debug("Reading LDAP configuration defaults from guacamole.properties...");
|
||||||
configs.forEach((config) -> config.setDefaults(defaultConfig));
|
LDAPConfiguration defaultConfig = new EnvironmentLDAPConfiguration(environment);
|
||||||
|
configs.forEach((config) -> config.setDefaults(defaultConfig));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.debug("Using only guacamole.properties for "
|
||||||
|
+ "LDAP server definitions as \"{}\" is "
|
||||||
|
+ "empty.", ldapServers);
|
||||||
|
|
||||||
cachedConfigurations = configs;
|
cachedConfigurations = configs;
|
||||||
|
|
||||||
@@ -119,13 +128,15 @@ public class ConfigurationService {
|
|||||||
else
|
else
|
||||||
logger.debug("Using cached LDAP configuration from \"{}\".", ldapServers);
|
logger.debug("Using cached LDAP configuration from \"{}\".", ldapServers);
|
||||||
|
|
||||||
return cachedConfigurations;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use guacamole.properties if not using YAML
|
// Use guacamole.properties if not using YAML
|
||||||
logger.debug("Reading LDAP configuration from guacamole.properties...");
|
if (cachedConfigurations == null) {
|
||||||
return Collections.singletonList(new EnvironmentLDAPConfiguration(environment));
|
logger.debug("Reading LDAP configuration from guacamole.properties...");
|
||||||
|
return Collections.singletonList(new EnvironmentLDAPConfiguration(environment));
|
||||||
|
}
|
||||||
|
|
||||||
|
return cachedConfigurations;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user