GUACAMOLE-5: Use ActiveConnectionRecord as the basis for sharing. TrackedActiveConnection is really only meant for interchange via the ActiveConnection Directory.

This commit is contained in:
Michael Jumper
2016-07-24 14:34:22 -07:00
parent 16fce2931f
commit b201eac617
4 changed files with 17 additions and 32 deletions

View File

@@ -50,6 +50,12 @@ public class TrackedActiveConnection extends RestrictedObject implements ActiveC
*/ */
private String identifier; private String identifier;
/**
* The actual connection record from which this ActiveConnection derives its
* data.
*/
private ActiveConnectionRecord connectionRecord;
/** /**
* The connection being actively used or shared. * The connection being actively used or shared.
*/ */
@@ -75,13 +81,6 @@ public class TrackedActiveConnection extends RestrictedObject implements ActiveC
*/ */
private String username; private String username;
/**
* The connection ID of the connection as determined by guacd, not to be
* confused with the connection identifier determined by the database. This
* is the ID that must be supplied to guacd if joining this connection.
*/
private String connectionID;
/** /**
* The underlying GuacamoleTunnel. * The underlying GuacamoleTunnel.
*/ */
@@ -111,10 +110,10 @@ public class TrackedActiveConnection extends RestrictedObject implements ActiveC
boolean includeSensitiveInformation) { boolean includeSensitiveInformation) {
super.init(currentUser); super.init(currentUser);
this.connectionRecord = activeConnectionRecord;
// Copy all non-sensitive data from given record // Copy all non-sensitive data from given record
this.connection = activeConnectionRecord.getConnection(); this.connection = activeConnectionRecord.getConnection();
this.connectionID = activeConnectionRecord.getConnectionID();
this.sharingProfileIdentifier = activeConnectionRecord.getSharingProfileIdentifier(); this.sharingProfileIdentifier = activeConnectionRecord.getSharingProfileIdentifier();
this.identifier = activeConnectionRecord.getUUID().toString(); this.identifier = activeConnectionRecord.getUUID().toString();
this.startDate = activeConnectionRecord.getStartDate(); this.startDate = activeConnectionRecord.getStartDate();
@@ -150,19 +149,6 @@ public class TrackedActiveConnection extends RestrictedObject implements ActiveC
return connection; return connection;
} }
/**
* Returns the connection ID of the in-progress connection as determined by
* guacd, not to be confused with the connection identifier determined by
* the database. This is the ID that must be supplied to guacd if joining
* this connection.
*
* @return
* The ID of the in-progress connection, as determined by guacd.
*/
public String getConnectionID() {
return connectionID;
}
@Override @Override
public String getConnectionIdentifier() { public String getConnectionIdentifier() {
return connection.getIdentifier(); return connection.getIdentifier();
@@ -189,7 +175,7 @@ public class TrackedActiveConnection extends RestrictedObject implements ActiveC
public UserCredentials getSharingCredentials(String identifier) public UserCredentials getSharingCredentials(String identifier)
throws GuacamoleException { throws GuacamoleException {
return sharingService.generateTemporaryCredentials(getCurrentUser(), return sharingService.generateTemporaryCredentials(getCurrentUser(),
this, identifier); connectionRecord, identifier);
} }
@Override @Override

View File

@@ -25,9 +25,9 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.guacamole.auth.jdbc.user.AuthenticatedUser; import org.apache.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleSecurityException; import org.apache.guacamole.GuacamoleSecurityException;
import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile; import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileService; import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileService;
import org.apache.guacamole.auth.jdbc.tunnel.ActiveConnectionRecord;
import org.apache.guacamole.form.Field; import org.apache.guacamole.form.Field;
import org.apache.guacamole.net.auth.AuthenticationProvider; import org.apache.guacamole.net.auth.AuthenticationProvider;
import org.apache.guacamole.net.auth.Credentials; import org.apache.guacamole.net.auth.Credentials;
@@ -98,7 +98,7 @@ public class ConnectionSharingService {
* If permission to share the given connection is denied. * If permission to share the given connection is denied.
*/ */
public UserCredentials generateTemporaryCredentials(AuthenticatedUser user, public UserCredentials generateTemporaryCredentials(AuthenticatedUser user,
TrackedActiveConnection activeConnection, ActiveConnectionRecord activeConnection,
String sharingProfileIdentifier) throws GuacamoleException { String sharingProfileIdentifier) throws GuacamoleException {
// Pull sharing profile (verifying access) // Pull sharing profile (verifying access)

View File

@@ -19,8 +19,8 @@
package org.apache.guacamole.auth.jdbc.sharing; package org.apache.guacamole.auth.jdbc.sharing;
import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile; import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.auth.jdbc.tunnel.ActiveConnectionRecord;
/** /**
* Defines the semantics/restrictions of a shared connection by associating an * Defines the semantics/restrictions of a shared connection by associating an
@@ -35,7 +35,7 @@ public class SharedConnectionDefinition {
/** /**
* The active connection being shared. * The active connection being shared.
*/ */
private final TrackedActiveConnection activeConnection; private final ActiveConnectionRecord activeConnection;
/** /**
* The sharing profile which dictates the level of access provided to a user * The sharing profile which dictates the level of access provided to a user
@@ -63,7 +63,7 @@ public class SharedConnectionDefinition {
* @param shareKey * @param shareKey
* The unique key with which a user may access the shared connection. * The unique key with which a user may access the shared connection.
*/ */
public SharedConnectionDefinition(TrackedActiveConnection activeConnection, public SharedConnectionDefinition(ActiveConnectionRecord activeConnection,
ModeledSharingProfile sharingProfile, String shareKey) { ModeledSharingProfile sharingProfile, String shareKey) {
this.activeConnection = activeConnection; this.activeConnection = activeConnection;
this.sharingProfile = sharingProfile; this.sharingProfile = sharingProfile;
@@ -71,13 +71,13 @@ public class SharedConnectionDefinition {
} }
/** /**
* Returns the TrackedActiveConnection of the actual in-progress connection * Returns the ActiveConnectionRecord of the actual in-progress connection
* being shared. * being shared.
* *
* @return * @return
* The TrackedActiveConnection being shared. * The ActiveConnectionRecord being shared.
*/ */
public TrackedActiveConnection getActiveConnection() { public ActiveConnectionRecord getActiveConnection() {
return activeConnection; return activeConnection;
} }

View File

@@ -21,7 +21,6 @@ package org.apache.guacamole.auth.jdbc.tunnel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
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.auth.jdbc.sharingprofile.ModeledSharingProfile; import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
@@ -184,7 +183,7 @@ public class ActiveConnectionRecord implements ConnectionRecord {
* shared connection, this value may NOT be null. * shared connection, this value may NOT be null.
*/ */
public ActiveConnectionRecord(RemoteAuthenticatedUser user, public ActiveConnectionRecord(RemoteAuthenticatedUser user,
TrackedActiveConnection activeConnection, ActiveConnectionRecord activeConnection,
ModeledSharingProfile sharingProfile) { ModeledSharingProfile sharingProfile) {
this(user, null, activeConnection.getConnection(), sharingProfile); this(user, null, activeConnection.getConnection(), sharingProfile);
this.connectionID = activeConnection.getConnectionID(); this.connectionID = activeConnection.getConnectionID();