mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1373: Move property/attribute logic into ModeledConnection and ModeledConnectionGroup.
This commit is contained in:
@@ -62,7 +62,7 @@ import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermis
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermissionSet;
|
import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermissionSet;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionService;
|
import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionService;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
|
import org.glyptodon.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.tunnel.ConfigurableGuacamoleTunnelService;
|
import org.glyptodon.guacamole.auth.jdbc.tunnel.RestrictedGuacamoleTunnelService;
|
||||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||||
import org.mybatis.guice.MyBatisModule;
|
import org.mybatis.guice.MyBatisModule;
|
||||||
import org.mybatis.guice.datasource.builtin.PooledDataSourceProvider;
|
import org.mybatis.guice.datasource.builtin.PooledDataSourceProvider;
|
||||||
@@ -153,7 +153,7 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
|
|||||||
bind(ConnectionGroupService.class);
|
bind(ConnectionGroupService.class);
|
||||||
bind(ConnectionPermissionService.class);
|
bind(ConnectionPermissionService.class);
|
||||||
bind(ConnectionService.class);
|
bind(ConnectionService.class);
|
||||||
bind(GuacamoleTunnelService.class).to(ConfigurableGuacamoleTunnelService.class);
|
bind(GuacamoleTunnelService.class).to(RestrictedGuacamoleTunnelService.class);
|
||||||
bind(PasswordEncryptionService.class).to(SHA256PasswordEncryptionService.class);
|
bind(PasswordEncryptionService.class).to(SHA256PasswordEncryptionService.class);
|
||||||
bind(SaltService.class).to(SecureRandomSaltService.class);
|
bind(SaltService.class).to(SecureRandomSaltService.class);
|
||||||
bind(SystemPermissionService.class);
|
bind(SystemPermissionService.class);
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.auth.jdbc.JDBCEnvironment;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.base.ModeledGroupedDirectoryObject;
|
import org.glyptodon.guacamole.auth.jdbc.base.ModeledGroupedDirectoryObject;
|
||||||
import org.glyptodon.guacamole.form.Field;
|
import org.glyptodon.guacamole.form.Field;
|
||||||
import org.glyptodon.guacamole.form.Form;
|
import org.glyptodon.guacamole.form.Form;
|
||||||
@@ -88,6 +89,12 @@ public class ModeledConnection extends ModeledGroupedDirectoryObject<ConnectionM
|
|||||||
CONCURRENCY_LIMITS
|
CONCURRENCY_LIMITS
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The environment of the Guacamole server.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private JDBCEnvironment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for managing connections.
|
* Service for managing connections.
|
||||||
*/
|
*/
|
||||||
@@ -200,4 +207,53 @@ public class ModeledConnection extends ModeledGroupedDirectoryObject<ConnectionM
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of connections that should be allowed to this
|
||||||
|
* connection overall. If no limit applies, zero is returned.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The maximum number of connections that should be allowed to this
|
||||||
|
* connection overall, or zero if no limit applies.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the concurrency limit properties
|
||||||
|
* specified within guacamole.properties.
|
||||||
|
*/
|
||||||
|
public int getMaxConnections() throws GuacamoleException {
|
||||||
|
|
||||||
|
// Pull default from environment if connection limit is unset
|
||||||
|
Integer value = getModel().getMaxConnections();
|
||||||
|
if (value == null)
|
||||||
|
return environment.getDefaultMaxConnections();
|
||||||
|
|
||||||
|
// Otherwise use defined value
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of connections that should be allowed to this
|
||||||
|
* connection for any individual user. If no limit applies, zero is
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The maximum number of connections that should be allowed to this
|
||||||
|
* connection for any individual user, or zero if no limit applies.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the concurrency limit properties
|
||||||
|
* specified within guacamole.properties.
|
||||||
|
*/
|
||||||
|
public int getMaxConnectionsPerUser() throws GuacamoleException {
|
||||||
|
|
||||||
|
// Pull default from environment if per-user connection limit is unset
|
||||||
|
Integer value = getModel().getMaxConnectionsPerUser();
|
||||||
|
if (value == null)
|
||||||
|
return environment.getDefaultMaxConnectionsPerUser();
|
||||||
|
|
||||||
|
// Otherwise use defined value
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.Set;
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionService;
|
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionService;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.auth.jdbc.JDBCEnvironment;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.base.ModeledGroupedDirectoryObject;
|
import org.glyptodon.guacamole.auth.jdbc.base.ModeledGroupedDirectoryObject;
|
||||||
import org.glyptodon.guacamole.form.Field;
|
import org.glyptodon.guacamole.form.Field;
|
||||||
import org.glyptodon.guacamole.form.Form;
|
import org.glyptodon.guacamole.form.Form;
|
||||||
@@ -86,6 +87,12 @@ public class ModeledConnectionGroup extends ModeledGroupedDirectoryObject<Connec
|
|||||||
CONCURRENCY_LIMITS
|
CONCURRENCY_LIMITS
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The environment of the Guacamole server.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private JDBCEnvironment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for managing connections.
|
* Service for managing connections.
|
||||||
*/
|
*/
|
||||||
@@ -186,4 +193,55 @@ public class ModeledConnectionGroup extends ModeledGroupedDirectoryObject<Connec
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of connections that should be allowed to this
|
||||||
|
* connection group overall. If no limit applies, zero is returned.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The maximum number of connections that should be allowed to this
|
||||||
|
* connection group overall, or zero if no limit applies.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the concurrency limit properties
|
||||||
|
* specified within guacamole.properties.
|
||||||
|
*/
|
||||||
|
public int getMaxConnections() throws GuacamoleException {
|
||||||
|
|
||||||
|
// Pull default from environment if connection limit is unset
|
||||||
|
Integer value = getModel().getMaxConnections();
|
||||||
|
if (value == null)
|
||||||
|
return environment.getDefaultMaxGroupConnections();
|
||||||
|
|
||||||
|
// Otherwise use defined value
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of connections that should be allowed to this
|
||||||
|
* connection group for any individual user. If no limit applies, zero is
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The maximum number of connections that should be allowed to this
|
||||||
|
* connection group for any individual user, or zero if no limit
|
||||||
|
* applies.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the concurrency limit properties
|
||||||
|
* specified within guacamole.properties.
|
||||||
|
*/
|
||||||
|
public int getMaxConnectionsPerUser() throws GuacamoleException {
|
||||||
|
|
||||||
|
// Pull default from environment if per-user connection limit is unset
|
||||||
|
Integer value = getModel().getMaxConnectionsPerUser();
|
||||||
|
if (value == null)
|
||||||
|
return environment.getDefaultMaxGroupConnectionsPerUser();
|
||||||
|
|
||||||
|
// Otherwise use defined value
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
package org.glyptodon.guacamole.auth.jdbc.tunnel;
|
package org.glyptodon.guacamole.auth.jdbc.tunnel;
|
||||||
|
|
||||||
import com.google.common.collect.ConcurrentHashMultiset;
|
import com.google.common.collect.ConcurrentHashMultiset;
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -33,7 +32,6 @@ import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
|
import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleResourceConflictException;
|
import org.glyptodon.guacamole.GuacamoleResourceConflictException;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.JDBCEnvironment;
|
|
||||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
||||||
|
|
||||||
|
|
||||||
@@ -46,15 +44,9 @@ import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
|||||||
* @author Michael Jumper
|
* @author Michael Jumper
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ConfigurableGuacamoleTunnelService
|
public class RestrictedGuacamoleTunnelService
|
||||||
extends AbstractGuacamoleTunnelService {
|
extends AbstractGuacamoleTunnelService {
|
||||||
|
|
||||||
/**
|
|
||||||
* The Guacamole server environment.
|
|
||||||
*/
|
|
||||||
@Inject
|
|
||||||
private JDBCEnvironment environment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of all currently-active user/connection pairs (seats).
|
* Set of all currently-active user/connection pairs (seats).
|
||||||
*/
|
*/
|
||||||
@@ -148,23 +140,14 @@ public class ConfigurableGuacamoleTunnelService
|
|||||||
// Return the first unreserved connection
|
// Return the first unreserved connection
|
||||||
for (ModeledConnection connection : sortedConnections) {
|
for (ModeledConnection connection : sortedConnections) {
|
||||||
|
|
||||||
// Determine per-user limits on this connection
|
|
||||||
Integer connectionMaxConnectionsPerUser = connection.getModel().getMaxConnectionsPerUser();
|
|
||||||
if (connectionMaxConnectionsPerUser == null)
|
|
||||||
connectionMaxConnectionsPerUser = environment.getDefaultMaxConnectionsPerUser();
|
|
||||||
|
|
||||||
// Determine overall limits on this connection
|
|
||||||
Integer connectionMaxConnections = connection.getModel().getMaxConnections();
|
|
||||||
if (connectionMaxConnections == null)
|
|
||||||
connectionMaxConnections = environment.getDefaultMaxConnections();
|
|
||||||
|
|
||||||
// Attempt to aquire connection according to per-user limits
|
// Attempt to aquire connection according to per-user limits
|
||||||
Seat seat = new Seat(username, connection.getIdentifier());
|
Seat seat = new Seat(username, connection.getIdentifier());
|
||||||
if (tryAdd(activeSeats, seat, connectionMaxConnectionsPerUser)) {
|
if (tryAdd(activeSeats, seat,
|
||||||
|
connection.getMaxConnectionsPerUser())) {
|
||||||
|
|
||||||
// Attempt to aquire connection according to overall limits
|
// Attempt to aquire connection according to overall limits
|
||||||
if (tryAdd(activeConnections, connection.getIdentifier(),
|
if (tryAdd(activeConnections, connection.getIdentifier(),
|
||||||
connectionMaxConnections))
|
connection.getMaxConnections()))
|
||||||
return connection;
|
return connection;
|
||||||
|
|
||||||
// Acquire failed - retry with next connection
|
// Acquire failed - retry with next connection
|
||||||
@@ -200,24 +183,14 @@ public class ConfigurableGuacamoleTunnelService
|
|||||||
// Get username
|
// Get username
|
||||||
String username = user.getUser().getIdentifier();
|
String username = user.getUser().getIdentifier();
|
||||||
|
|
||||||
// Determine per-user limits on this connection group
|
|
||||||
Integer connectionGroupMaxConnectionsPerUser = connectionGroup.getModel().getMaxConnectionsPerUser();
|
|
||||||
if (connectionGroupMaxConnectionsPerUser == null)
|
|
||||||
connectionGroupMaxConnectionsPerUser = environment.getDefaultMaxGroupConnectionsPerUser();
|
|
||||||
|
|
||||||
// Determine overall limits on this connection group
|
|
||||||
Integer connectionGroupMaxConnections = connectionGroup.getModel().getMaxConnections();
|
|
||||||
if (connectionGroupMaxConnections == null)
|
|
||||||
connectionGroupMaxConnections = environment.getDefaultMaxGroupConnections();
|
|
||||||
|
|
||||||
// Attempt to aquire connection group according to per-user limits
|
// Attempt to aquire connection group according to per-user limits
|
||||||
Seat seat = new Seat(username, connectionGroup.getIdentifier());
|
Seat seat = new Seat(username, connectionGroup.getIdentifier());
|
||||||
if (tryAdd(activeGroupSeats, seat,
|
if (tryAdd(activeGroupSeats, seat,
|
||||||
connectionGroupMaxConnectionsPerUser)) {
|
connectionGroup.getMaxConnectionsPerUser())) {
|
||||||
|
|
||||||
// Attempt to aquire connection group according to overall limits
|
// Attempt to aquire connection group according to overall limits
|
||||||
if (tryAdd(activeGroups, connectionGroup.getIdentifier(),
|
if (tryAdd(activeGroups, connectionGroup.getIdentifier(),
|
||||||
connectionGroupMaxConnections))
|
connectionGroup.getMaxConnections()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Acquire failed
|
// Acquire failed
|
Reference in New Issue
Block a user