mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-830: Add new concurrency properties. Warn of deprecation and suggest alternatives in the logs.
This commit is contained in:
@@ -34,6 +34,8 @@ import org.glyptodon.guacamole.auth.jdbc.tunnel.ConfigurableGuacamoleTunnelServi
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.user.UserContextService;
|
import org.glyptodon.guacamole.auth.jdbc.user.UserContextService;
|
||||||
import org.glyptodon.guacamole.environment.Environment;
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a MySQL based implementation of the AuthenticationProvider
|
* Provides a MySQL based implementation of the AuthenticationProvider
|
||||||
@@ -44,6 +46,11 @@ import org.glyptodon.guacamole.environment.LocalEnvironment;
|
|||||||
*/
|
*/
|
||||||
public class MySQLAuthenticationProvider implements AuthenticationProvider {
|
public class MySQLAuthenticationProvider implements AuthenticationProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger for this class.
|
||||||
|
*/
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(MySQLAuthenticationProvider.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injector which will manage the object graph of this authentication
|
* Injector which will manage the object graph of this authentication
|
||||||
* provider.
|
* provider.
|
||||||
@@ -75,28 +82,75 @@ public class MySQLAuthenticationProvider implements AuthenticationProvider {
|
|||||||
int connectionGroupDefaultMaxConnectionsPerUser;
|
int connectionGroupDefaultMaxConnectionsPerUser;
|
||||||
|
|
||||||
// Read legacy concurrency-related properties
|
// Read legacy concurrency-related properties
|
||||||
boolean disallowSimultaneous = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DISALLOW_SIMULTANEOUS_CONNECTIONS, false);
|
Boolean disallowSimultaneous = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DISALLOW_SIMULTANEOUS_CONNECTIONS);
|
||||||
boolean disallowDuplicate = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DISALLOW_DUPLICATE_CONNECTIONS, true);
|
Boolean disallowDuplicate = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DISALLOW_DUPLICATE_CONNECTIONS);
|
||||||
|
|
||||||
// Legacy properties to not affect max connections per group
|
|
||||||
connectionGroupDefaultMaxConnections = 0;
|
|
||||||
|
|
||||||
// Legacy "simultaneous" property dictates only the maximum number of
|
// Legacy "simultaneous" property dictates only the maximum number of
|
||||||
// connections per connection
|
// connections per connection
|
||||||
if (disallowSimultaneous)
|
if (disallowSimultaneous != null) {
|
||||||
connectionDefaultMaxConnections = 1;
|
|
||||||
else
|
// Translate legacy property
|
||||||
connectionDefaultMaxConnections = 0;
|
if (disallowSimultaneous) {
|
||||||
|
connectionDefaultMaxConnections = 1;
|
||||||
|
connectionGroupDefaultMaxConnections = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
connectionDefaultMaxConnections = 0;
|
||||||
|
connectionGroupDefaultMaxConnections = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn of deprecation
|
||||||
|
logger.warn("The \"{}\" property is deprecated. Use \"{}\" and \"{}\" instead.",
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DISALLOW_SIMULTANEOUS_CONNECTIONS.getName(),
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_CONNECTIONS.getName(),
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS.getName());
|
||||||
|
|
||||||
|
// Inform of new equivalent
|
||||||
|
logger.info("To achieve the same result of setting \"{}\" to \"{}\", set \"{}\" to \"{}\" and \"{}\" to \"{}\".",
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DISALLOW_SIMULTANEOUS_CONNECTIONS.getName(), disallowSimultaneous,
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_CONNECTIONS.getName(), connectionDefaultMaxConnections,
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS.getName(), connectionGroupDefaultMaxConnections);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// If legacy property is not specified, use new property
|
||||||
|
else {
|
||||||
|
connectionDefaultMaxConnections = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_CONNECTIONS, 0);
|
||||||
|
connectionGroupDefaultMaxConnections = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Legacy "duplicate" property dictates whether connections and groups
|
// Legacy "duplicate" property dictates whether connections and groups
|
||||||
// may be used concurrently only by different users
|
// may be used concurrently only by different users
|
||||||
if (disallowDuplicate) {
|
if (disallowDuplicate != null) {
|
||||||
connectionDefaultMaxConnectionsPerUser = 1;
|
|
||||||
connectionGroupDefaultMaxConnectionsPerUser = 1;
|
// Translate legacy property
|
||||||
|
if (disallowDuplicate) {
|
||||||
|
connectionDefaultMaxConnectionsPerUser = 1;
|
||||||
|
connectionGroupDefaultMaxConnectionsPerUser = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
connectionDefaultMaxConnectionsPerUser = 0;
|
||||||
|
connectionGroupDefaultMaxConnectionsPerUser = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn of deprecation
|
||||||
|
logger.warn("The \"{}\" property is deprecated. Use \"{}\" and \"{}\" instead.",
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DISALLOW_DUPLICATE_CONNECTIONS.getName(),
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_CONNECTIONS_PER_USER.getName(),
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS.getName());
|
||||||
|
|
||||||
|
// Inform of new equivalent
|
||||||
|
logger.info("To achieve the same result of setting \"{}\" to \"{}\", set \"{}\" to \"{}\" and \"{}\" to \"{}\".",
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DISALLOW_DUPLICATE_CONNECTIONS.getName(), disallowDuplicate,
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_CONNECTIONS_PER_USER.getName(), connectionDefaultMaxConnectionsPerUser,
|
||||||
|
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER.getName(), connectionGroupDefaultMaxConnectionsPerUser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If legacy property is not specified, use new property
|
||||||
else {
|
else {
|
||||||
connectionDefaultMaxConnectionsPerUser = 0;
|
connectionDefaultMaxConnectionsPerUser = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_CONNECTIONS_PER_USER, 1);
|
||||||
connectionGroupDefaultMaxConnectionsPerUser = 0;
|
connectionGroupDefaultMaxConnectionsPerUser = environment.getProperty(MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return service configured for specified default limits
|
// Return service configured for specified default limits
|
||||||
|
@@ -107,5 +107,57 @@ public class MySQLGuacamoleProperties {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection. Zero denotes unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
MYSQL_DEFAULT_MAX_CONNECTIONS =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "mysql-default-max-connections"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection group. Zero denotes unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "mysql-default-max-group-connections"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection by an individual user. Zero denotes unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
MYSQL_DEFAULT_MAX_CONNECTIONS_PER_USER =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "mysql-default-max-connections-per-user"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection group by an individual user. Zero denotes
|
||||||
|
* unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "mysql-default-max-group-connections-per-user"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,8 @@ import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.user.UserContextService;
|
import org.glyptodon.guacamole.auth.jdbc.user.UserContextService;
|
||||||
import org.glyptodon.guacamole.environment.Environment;
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a PostgreSQL-based implementation of the AuthenticationProvider
|
* Provides a PostgreSQL-based implementation of the AuthenticationProvider
|
||||||
@@ -44,6 +46,11 @@ import org.glyptodon.guacamole.environment.LocalEnvironment;
|
|||||||
*/
|
*/
|
||||||
public class PostgreSQLAuthenticationProvider implements AuthenticationProvider {
|
public class PostgreSQLAuthenticationProvider implements AuthenticationProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger for this class.
|
||||||
|
*/
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PostgreSQLAuthenticationProvider.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injector which will manage the object graph of this authentication
|
* Injector which will manage the object graph of this authentication
|
||||||
* provider.
|
* provider.
|
||||||
@@ -75,28 +82,75 @@ public class PostgreSQLAuthenticationProvider implements AuthenticationProvider
|
|||||||
int connectionGroupDefaultMaxConnectionsPerUser;
|
int connectionGroupDefaultMaxConnectionsPerUser;
|
||||||
|
|
||||||
// Read legacy concurrency-related properties
|
// Read legacy concurrency-related properties
|
||||||
boolean disallowSimultaneous = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_SIMULTANEOUS_CONNECTIONS, false);
|
Boolean disallowSimultaneous = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_SIMULTANEOUS_CONNECTIONS);
|
||||||
boolean disallowDuplicate = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_DUPLICATE_CONNECTIONS, true);
|
Boolean disallowDuplicate = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_DUPLICATE_CONNECTIONS);
|
||||||
|
|
||||||
// Legacy properties to not affect max connections per group
|
|
||||||
connectionGroupDefaultMaxConnections = 0;
|
|
||||||
|
|
||||||
// Legacy "simultaneous" property dictates only the maximum number of
|
// Legacy "simultaneous" property dictates only the maximum number of
|
||||||
// connections per connection
|
// connections per connection
|
||||||
if (disallowSimultaneous)
|
if (disallowSimultaneous != null) {
|
||||||
connectionDefaultMaxConnections = 1;
|
|
||||||
else
|
// Translate legacy property
|
||||||
connectionDefaultMaxConnections = 0;
|
if (disallowSimultaneous) {
|
||||||
|
connectionDefaultMaxConnections = 1;
|
||||||
|
connectionGroupDefaultMaxConnections = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
connectionDefaultMaxConnections = 0;
|
||||||
|
connectionGroupDefaultMaxConnections = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn of deprecation
|
||||||
|
logger.warn("The \"{}\" property is deprecated. Use \"{}\" and \"{}\" instead.",
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_SIMULTANEOUS_CONNECTIONS.getName(),
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_CONNECTIONS.getName(),
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS.getName());
|
||||||
|
|
||||||
|
// Inform of new equivalent
|
||||||
|
logger.info("To achieve the same result of setting \"{}\" to \"{}\", set \"{}\" to \"{}\" and \"{}\" to \"{}\".",
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_SIMULTANEOUS_CONNECTIONS.getName(), disallowSimultaneous,
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_CONNECTIONS.getName(), connectionDefaultMaxConnections,
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS.getName(), connectionGroupDefaultMaxConnections);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// If legacy property is not specified, use new property
|
||||||
|
else {
|
||||||
|
connectionDefaultMaxConnections = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_CONNECTIONS, 0);
|
||||||
|
connectionGroupDefaultMaxConnections = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Legacy "duplicate" property dictates whether connections and groups
|
// Legacy "duplicate" property dictates whether connections and groups
|
||||||
// may be used concurrently only by different users
|
// may be used concurrently only by different users
|
||||||
if (disallowDuplicate) {
|
if (disallowDuplicate != null) {
|
||||||
connectionDefaultMaxConnectionsPerUser = 1;
|
|
||||||
connectionGroupDefaultMaxConnectionsPerUser = 1;
|
// Translate legacy property
|
||||||
|
if (disallowDuplicate) {
|
||||||
|
connectionDefaultMaxConnectionsPerUser = 1;
|
||||||
|
connectionGroupDefaultMaxConnectionsPerUser = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
connectionDefaultMaxConnectionsPerUser = 0;
|
||||||
|
connectionGroupDefaultMaxConnectionsPerUser = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn of deprecation
|
||||||
|
logger.warn("The \"{}\" property is deprecated. Use \"{}\" and \"{}\" instead.",
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_DUPLICATE_CONNECTIONS.getName(),
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_CONNECTIONS_PER_USER.getName(),
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS.getName());
|
||||||
|
|
||||||
|
// Inform of new equivalent
|
||||||
|
logger.info("To achieve the same result of setting \"{}\" to \"{}\", set \"{}\" to \"{}\" and \"{}\" to \"{}\".",
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DISALLOW_DUPLICATE_CONNECTIONS.getName(), disallowDuplicate,
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_CONNECTIONS_PER_USER.getName(), connectionDefaultMaxConnectionsPerUser,
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER.getName(), connectionGroupDefaultMaxConnectionsPerUser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If legacy property is not specified, use new property
|
||||||
else {
|
else {
|
||||||
connectionDefaultMaxConnectionsPerUser = 0;
|
connectionDefaultMaxConnectionsPerUser = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_CONNECTIONS_PER_USER, 1);
|
||||||
connectionGroupDefaultMaxConnectionsPerUser = 0;
|
connectionGroupDefaultMaxConnectionsPerUser = environment.getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return service configured for specified default limits
|
// Return service configured for specified default limits
|
||||||
|
@@ -124,4 +124,57 @@ public class PostgreSQLGuacamoleProperties {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection. Zero denotes unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
POSTGRESQL_DEFAULT_MAX_CONNECTIONS =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "postgresql-default-max-connections"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection group. Zero denotes unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "postgresql-default-max-group-connections"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection by an individual user. Zero denotes unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
POSTGRESQL_DEFAULT_MAX_CONNECTIONS_PER_USER =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "postgresql-default-max-connections-per-user"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of concurrent connections to allow to any one
|
||||||
|
* connection group by an individual user. Zero denotes
|
||||||
|
* unlimited.
|
||||||
|
*/
|
||||||
|
public static final IntegerGuacamoleProperty
|
||||||
|
POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER =
|
||||||
|
new IntegerGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "postgresql-default-max-group-connections-per-user"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user