GUACAMOLE-5: Store SharedConnectionDefinition directly, rather than passing around its contents.

This commit is contained in:
Michael Jumper
2016-07-22 16:53:40 -07:00
parent d334aa97d6
commit 16fce2931f
3 changed files with 24 additions and 31 deletions

View File

@@ -26,9 +26,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
import org.apache.guacamole.auth.jdbc.connectiongroup.RootConnectionGroup; import org.apache.guacamole.auth.jdbc.connectiongroup.RootConnectionGroup;
import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService; import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
import org.apache.guacamole.net.GuacamoleTunnel; import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.net.auth.Connection;
@@ -64,15 +62,10 @@ public class SharedConnection implements Connection {
private SharedConnectionUser user; private SharedConnectionUser user;
/** /**
* The active connection being shared. * The SharedConnectionDefinition dictating the connection being shared and
* any associated restrictions.
*/ */
private TrackedActiveConnection activeConnection; private SharedConnectionDefinition definition;
/**
* The sharing profile which dictates the level of access provided to a user
* of the shared connection.
*/
private ModeledSharingProfile sharingProfile;
/** /**
* Creates a new SharedConnection which can be used to join the connection * Creates a new SharedConnection which can be used to join the connection
@@ -88,8 +81,7 @@ public class SharedConnection implements Connection {
*/ */
public void init(SharedConnectionUser user, SharedConnectionDefinition definition) { public void init(SharedConnectionUser user, SharedConnectionDefinition definition) {
this.user = user; this.user = user;
this.activeConnection = definition.getActiveConnection(); this.definition = definition;
this.sharingProfile = definition.getSharingProfile();
} }
@Override @Override
@@ -104,7 +96,7 @@ public class SharedConnection implements Connection {
@Override @Override
public String getName() { public String getName() {
return sharingProfile.getName(); return definition.getSharingProfile().getName();
} }
@Override @Override
@@ -124,9 +116,15 @@ public class SharedConnection implements Connection {
@Override @Override
public GuacamoleConfiguration getConfiguration() { public GuacamoleConfiguration getConfiguration() {
// Pull the connection being shared
Connection primaryConnection = definition.getActiveConnection().getConnection();
// Construct a skeletal configuration that exposes only the protocol in use
GuacamoleConfiguration config = new GuacamoleConfiguration(); GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol(activeConnection.getConnection().getConfiguration().getProtocol()); config.setProtocol(primaryConnection.getConfiguration().getProtocol());
return config; return config;
} }
@Override @Override
@@ -137,8 +135,7 @@ public class SharedConnection implements Connection {
@Override @Override
public GuacamoleTunnel connect(GuacamoleClientInformation info) public GuacamoleTunnel connect(GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
return tunnelService.getGuacamoleTunnel(user, activeConnection, return tunnelService.getGuacamoleTunnel(user, definition, info);
sharingProfile, info);
} }
@Override @Override

View File

@@ -42,7 +42,6 @@ import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleResourceNotFoundException; import org.apache.guacamole.GuacamoleResourceNotFoundException;
import org.apache.guacamole.GuacamoleSecurityException; import org.apache.guacamole.GuacamoleSecurityException;
import org.apache.guacamole.auth.jdbc.JDBCEnvironment; import org.apache.guacamole.auth.jdbc.JDBCEnvironment;
import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
import org.apache.guacamole.auth.jdbc.connection.ConnectionMapper; import org.apache.guacamole.auth.jdbc.connection.ConnectionMapper;
import org.apache.guacamole.environment.Environment; import org.apache.guacamole.environment.Environment;
import org.apache.guacamole.net.GuacamoleSocket; import org.apache.guacamole.net.GuacamoleSocket;
@@ -56,6 +55,7 @@ import org.apache.guacamole.token.StandardTokens;
import org.apache.guacamole.token.TokenFilter; import org.apache.guacamole.token.TokenFilter;
import org.mybatis.guice.transactional.Transactional; import org.mybatis.guice.transactional.Transactional;
import org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper; import org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper;
import org.apache.guacamole.auth.jdbc.sharing.SharedConnectionDefinition;
import org.apache.guacamole.auth.jdbc.sharing.SharedConnectionUser; import org.apache.guacamole.auth.jdbc.sharing.SharedConnectionUser;
import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile; import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterMapper; import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterMapper;
@@ -467,7 +467,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
// Verify that the connection ID is known // Verify that the connection ID is known
String connectionID = activeConnection.getConnectionID(); String connectionID = activeConnection.getConnectionID();
if (!activeConnection.isActive() || connectionID == null) if (connectionID == null)
throw new GuacamoleResourceNotFoundException("No existing connection to be joined."); throw new GuacamoleResourceNotFoundException("No existing connection to be joined.");
// Build configuration from the sharing profile and the ID of // Build configuration from the sharing profile and the ID of
@@ -681,13 +681,14 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
@Override @Override
@Transactional @Transactional
public GuacamoleTunnel getGuacamoleTunnel(SharedConnectionUser user, public GuacamoleTunnel getGuacamoleTunnel(SharedConnectionUser user,
TrackedActiveConnection activeConnection, SharedConnectionDefinition definition,
ModeledSharingProfile sharingProfile,
GuacamoleClientInformation info) GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
// Connect to shared connection // Connect to shared connection
return assignGuacamoleTunnel(new ActiveConnectionRecord(user, activeConnection, sharingProfile), info); return assignGuacamoleTunnel(
new ActiveConnectionRecord(user, definition.getActiveConnection(),
definition.getSharingProfile()), info);
} }

View File

@@ -24,9 +24,8 @@ import org.apache.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.apache.guacamole.auth.jdbc.connection.ModeledConnection; import org.apache.guacamole.auth.jdbc.connection.ModeledConnection;
import org.apache.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup; import org.apache.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection; import org.apache.guacamole.auth.jdbc.sharing.SharedConnectionDefinition;
import org.apache.guacamole.auth.jdbc.sharing.SharedConnectionUser; import org.apache.guacamole.auth.jdbc.sharing.SharedConnectionUser;
import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.net.GuacamoleTunnel; import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.net.auth.Connection;
import org.apache.guacamole.net.auth.ConnectionGroup; import org.apache.guacamole.net.auth.ConnectionGroup;
@@ -158,12 +157,9 @@ public interface GuacamoleTunnelService {
* @param user * @param user
* The user for whom the connection is being established. * The user for whom the connection is being established.
* *
* @param activeConnection * @param definition
* The active connection the user is joining. * The SharedConnectionDefinition dictating the connection being shared
* * and any associated restrictions.
* @param sharingProfile
* The sharing profile whose associated parameters dictate the level
* of access granted to the user joining the connection.
* *
* @param info * @param info
* Information describing the Guacamole client connecting to the given * Information describing the Guacamole client connecting to the given
@@ -178,8 +174,7 @@ public interface GuacamoleTunnelService {
* rules. * rules.
*/ */
GuacamoleTunnel getGuacamoleTunnel(SharedConnectionUser user, GuacamoleTunnel getGuacamoleTunnel(SharedConnectionUser user,
TrackedActiveConnection activeConnection, SharedConnectionDefinition definition,
ModeledSharingProfile sharingProfile,
GuacamoleClientInformation info) GuacamoleClientInformation info)
throws GuacamoleException; throws GuacamoleException;