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.UUID;
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.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.auth.Connection;
@@ -64,15 +62,10 @@ public class SharedConnection implements Connection {
private SharedConnectionUser user;
/**
* The active connection being shared.
* The SharedConnectionDefinition dictating the connection being shared and
* any associated restrictions.
*/
private TrackedActiveConnection activeConnection;
/**
* The sharing profile which dictates the level of access provided to a user
* of the shared connection.
*/
private ModeledSharingProfile sharingProfile;
private SharedConnectionDefinition definition;
/**
* 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) {
this.user = user;
this.activeConnection = definition.getActiveConnection();
this.sharingProfile = definition.getSharingProfile();
this.definition = definition;
}
@Override
@@ -104,7 +96,7 @@ public class SharedConnection implements Connection {
@Override
public String getName() {
return sharingProfile.getName();
return definition.getSharingProfile().getName();
}
@Override
@@ -124,9 +116,15 @@ public class SharedConnection implements Connection {
@Override
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();
config.setProtocol(activeConnection.getConnection().getConfiguration().getProtocol());
config.setProtocol(primaryConnection.getConfiguration().getProtocol());
return config;
}
@Override
@@ -137,8 +135,7 @@ public class SharedConnection implements Connection {
@Override
public GuacamoleTunnel connect(GuacamoleClientInformation info)
throws GuacamoleException {
return tunnelService.getGuacamoleTunnel(user, activeConnection,
sharingProfile, info);
return tunnelService.getGuacamoleTunnel(user, definition, info);
}
@Override

View File

@@ -42,7 +42,6 @@ import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleResourceNotFoundException;
import org.apache.guacamole.GuacamoleSecurityException;
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.environment.Environment;
import org.apache.guacamole.net.GuacamoleSocket;
@@ -56,6 +55,7 @@ import org.apache.guacamole.token.StandardTokens;
import org.apache.guacamole.token.TokenFilter;
import org.mybatis.guice.transactional.Transactional;
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.sharingprofile.ModeledSharingProfile;
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
String connectionID = activeConnection.getConnectionID();
if (!activeConnection.isActive() || connectionID == null)
if (connectionID == null)
throw new GuacamoleResourceNotFoundException("No existing connection to be joined.");
// Build configuration from the sharing profile and the ID of
@@ -681,13 +681,14 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
@Override
@Transactional
public GuacamoleTunnel getGuacamoleTunnel(SharedConnectionUser user,
TrackedActiveConnection activeConnection,
ModeledSharingProfile sharingProfile,
SharedConnectionDefinition definition,
GuacamoleClientInformation info)
throws GuacamoleException {
// 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.connectiongroup.ModeledConnectionGroup;
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.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.auth.Connection;
import org.apache.guacamole.net.auth.ConnectionGroup;
@@ -158,12 +157,9 @@ public interface GuacamoleTunnelService {
* @param user
* The user for whom the connection is being established.
*
* @param activeConnection
* The active connection the user is joining.
*
* @param sharingProfile
* The sharing profile whose associated parameters dictate the level
* of access granted to the user joining the connection.
* @param definition
* The SharedConnectionDefinition dictating the connection being shared
* and any associated restrictions.
*
* @param info
* Information describing the Guacamole client connecting to the given
@@ -178,8 +174,7 @@ public interface GuacamoleTunnelService {
* rules.
*/
GuacamoleTunnel getGuacamoleTunnel(SharedConnectionUser user,
TrackedActiveConnection activeConnection,
ModeledSharingProfile sharingProfile,
SharedConnectionDefinition definition,
GuacamoleClientInformation info)
throws GuacamoleException;