mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-957: Add support for configuring the general network timeout for LDAP.
This commit is contained in:
@@ -197,6 +197,11 @@ public class ConnectedLDAPConfiguration implements LDAPConfiguration, AutoClosea
|
|||||||
return config.getOperationTimeout();
|
return config.getOperationTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNetworkTimeout() throws GuacamoleException {
|
||||||
|
return config.getNetworkTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAttributes() throws GuacamoleException {
|
public List<String> getAttributes() throws GuacamoleException {
|
||||||
return config.getAttributes();
|
return config.getAttributes();
|
||||||
|
@@ -67,6 +67,10 @@ public class LDAPConnectionService {
|
|||||||
* The encryption method that should be used to communicate with the
|
* The encryption method that should be used to communicate with the
|
||||||
* LDAP server.
|
* LDAP server.
|
||||||
*
|
*
|
||||||
|
* @param timeout
|
||||||
|
* The maximum number of milliseconds to wait for a response from the
|
||||||
|
* LDAP server.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* A new instance of LdapNetworkConnection which uses the given
|
* A new instance of LdapNetworkConnection which uses the given
|
||||||
* encryption method to communicate with the LDAP server at the given
|
* encryption method to communicate with the LDAP server at the given
|
||||||
@@ -77,11 +81,13 @@ public class LDAPConnectionService {
|
|||||||
* bug).
|
* bug).
|
||||||
*/
|
*/
|
||||||
private LdapNetworkConnection createLDAPConnection(String host, int port,
|
private LdapNetworkConnection createLDAPConnection(String host, int port,
|
||||||
EncryptionMethod encryptionMethod) throws GuacamoleException {
|
EncryptionMethod encryptionMethod, int timeout)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
LdapConnectionConfig config = new LdapConnectionConfig();
|
LdapConnectionConfig config = new LdapConnectionConfig();
|
||||||
config.setLdapHost(host);
|
config.setLdapHost(host);
|
||||||
config.setLdapPort(port);
|
config.setLdapPort(port);
|
||||||
|
config.setTimeout(timeout);
|
||||||
|
|
||||||
// Map encryption method to proper connection and socket factory
|
// Map encryption method to proper connection and socket factory
|
||||||
switch (encryptionMethod) {
|
switch (encryptionMethod) {
|
||||||
@@ -140,7 +146,8 @@ public class LDAPConnectionService {
|
|||||||
return createLDAPConnection(
|
return createLDAPConnection(
|
||||||
config.getServerHostname(),
|
config.getServerHostname(),
|
||||||
config.getServerPort(),
|
config.getServerPort(),
|
||||||
config.getEncryptionMethod());
|
config.getEncryptionMethod(),
|
||||||
|
config.getNetworkTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,7 +216,8 @@ public class LDAPConnectionService {
|
|||||||
if (port < 1)
|
if (port < 1)
|
||||||
port = encryptionMethod.DEFAULT_PORT;
|
port = encryptionMethod.DEFAULT_PORT;
|
||||||
|
|
||||||
return createLDAPConnection(host, port, encryptionMethod);
|
return createLDAPConnection(host, port, encryptionMethod,
|
||||||
|
config.getNetworkTimeout());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,6 +125,11 @@ public class DefaultLDAPConfiguration implements LDAPConfiguration {
|
|||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNetworkTimeout() {
|
||||||
|
return 30000;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAttributes() {
|
public List<String> getAttributes() {
|
||||||
return Collections.<String>emptyList();
|
return Collections.<String>emptyList();
|
||||||
|
@@ -193,6 +193,14 @@ public class EnvironmentLDAPConfiguration implements LDAPConfiguration {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNetworkTimeout() throws GuacamoleException {
|
||||||
|
return environment.getProperty(
|
||||||
|
LDAPGuacamoleProperties.LDAP_NETWORK_TIMEOUT,
|
||||||
|
DEFAULT.getNetworkTimeout()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAttributes() throws GuacamoleException {
|
public List<String> getAttributes() throws GuacamoleException {
|
||||||
return environment.getProperty(
|
return environment.getProperty(
|
||||||
|
@@ -165,6 +165,13 @@ public class JacksonLDAPConfiguration implements LDAPConfiguration {
|
|||||||
@JsonProperty("operation-timeout")
|
@JsonProperty("operation-timeout")
|
||||||
private Integer operationTimeout;
|
private Integer operationTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw YAML value of {@link LDAPGuacamoleProperties#LDAP_NETWORK_TIMEOUT}.
|
||||||
|
* If not set within the YAML, this will be null.
|
||||||
|
*/
|
||||||
|
@JsonProperty("network-timeout")
|
||||||
|
private Integer networkTimeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw YAML value of {@link LDAPGuacamoleProperties#LDAP_USER_ATTRIBUTES}.
|
* The raw YAML value of {@link LDAPGuacamoleProperties#LDAP_USER_ATTRIBUTES}.
|
||||||
* If not set within the YAML, this will be null.
|
* If not set within the YAML, this will be null.
|
||||||
@@ -364,6 +371,11 @@ public class JacksonLDAPConfiguration implements LDAPConfiguration {
|
|||||||
return withDefault(operationTimeout, defaultConfig.getOperationTimeout());
|
return withDefault(operationTimeout, defaultConfig.getOperationTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNetworkTimeout() throws GuacamoleException {
|
||||||
|
return withDefault(networkTimeout, defaultConfig.getNetworkTimeout());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAttributes() throws GuacamoleException {
|
public List<String> getAttributes() throws GuacamoleException {
|
||||||
return withDefault(userAttributes, defaultConfig.getAttributes());
|
return withDefault(userAttributes, defaultConfig.getAttributes());
|
||||||
|
@@ -255,6 +255,19 @@ public interface LDAPConfiguration {
|
|||||||
*/
|
*/
|
||||||
ExprNode getGroupSearchFilter() throws GuacamoleException;
|
ExprNode getGroupSearchFilter() throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of milliseconds to wait for a response when
|
||||||
|
* communicating with the LDAP server.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The maximum number of milliseconds to wait for responses from the
|
||||||
|
* LDAP server.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If the LDAP network timeout cannot be retrieved.
|
||||||
|
*/
|
||||||
|
int getNetworkTimeout() throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum number of seconds to wait for LDAP operations.
|
* Returns the maximum number of seconds to wait for LDAP operations.
|
||||||
*
|
*
|
||||||
|
@@ -254,6 +254,17 @@ public class LDAPGuacamoleProperties {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of milliseconds to wait for responses from the LDAP server.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty LDAP_NETWORK_TIMEOUT =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "ldap-network-timeout"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom attribute or attributes to query from Guacamole user's record in
|
* Custom attribute or attributes to query from Guacamole user's record in
|
||||||
* the LDAP directory.
|
* the LDAP directory.
|
||||||
|
Reference in New Issue
Block a user