From a59e20eb8d13cd3741fbcec2f42302d6d69ad13a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 10 Aug 2019 15:44:25 -0700 Subject: [PATCH] GUACAMOLE-360: Allow connections to active connections at API level. --- .../guacamole/net/auth/ActiveConnection.java | 33 ++++++++++++++++++- .../activeconnection/APIActiveConnection.java | 19 ++++++++++- .../webapp/app/rest/types/ActiveConnection.js | 8 +++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/ActiveConnection.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/ActiveConnection.java index ad1d6d37d..9bcce3edd 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/ActiveConnection.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/ActiveConnection.java @@ -20,13 +20,18 @@ package org.apache.guacamole.net.auth; import java.util.Date; +import java.util.Map; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.GuacamoleSecurityException; import org.apache.guacamole.net.GuacamoleTunnel; +import org.apache.guacamole.protocol.GuacamoleClientInformation; /** * A pairing of username and GuacamoleTunnel representing an active usage of a * particular connection. */ -public interface ActiveConnection extends Identifiable, Shareable { +public interface ActiveConnection extends Identifiable, Connectable, + Shareable { /** * Returns the identifier of the connection being actively used. Unlike the @@ -136,5 +141,31 @@ public interface ActiveConnection extends Identifiable, Shareable tokens) throws GuacamoleException { + throw new GuacamoleSecurityException("Permission denied."); + } + + @Override + default int getActiveConnections() { + return 0; + } } diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/APIActiveConnection.java b/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/APIActiveConnection.java index 0041a03cb..1634378b4 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/APIActiveConnection.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/APIActiveConnection.java @@ -54,6 +54,11 @@ public class APIActiveConnection { */ private final String username; + /** + * Whether this active connection may be connected to. + */ + private final boolean connectable; + /** * Creates a new APIActiveConnection, copying the information from the given * active connection. @@ -67,6 +72,7 @@ public class APIActiveConnection { this.startDate = connection.getStartDate(); this.remoteHost = connection.getRemoteHost(); this.username = connection.getUsername(); + this.connectable = connection.isConnectable(); } /** @@ -121,5 +127,16 @@ public class APIActiveConnection { public String getIdentifier() { return identifier; } - + + /*** + * Returns whether this active connection may be connected to, just as a + * normal connection. + * + * @return + * true if this active connection may be connected to, false otherwise. + */ + public boolean isConnectable() { + return connectable; + } + } diff --git a/guacamole/src/main/webapp/app/rest/types/ActiveConnection.js b/guacamole/src/main/webapp/app/rest/types/ActiveConnection.js index 6c5aac211..dc0b140fe 100644 --- a/guacamole/src/main/webapp/app/rest/types/ActiveConnection.js +++ b/guacamole/src/main/webapp/app/rest/types/ActiveConnection.js @@ -76,6 +76,14 @@ angular.module('rest').factory('ActiveConnection', [function defineActiveConnect */ this.username = template.username; + /** + * Whether this active connection may be connected to, just as a + * normal connection. + * + * @type Boolean + */ + this.connectable = template.connectable; + }; return ActiveConnection;