From 688ff5310cf59e6b5c85ee692dcdb4a36fe04311 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 1 Nov 2020 20:21:09 -0800 Subject: [PATCH] GUACAMOLE-221: Add client support for the "required" instruction. --- .../src/main/webapp/modules/Client.js | 16 ++++++++++++++++ .../protocol/GuacamoleProtocolCapability.java | 11 ++++++++++- .../protocol/GuacamoleProtocolVersion.java | 9 ++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Client.js b/guacamole-common-js/src/main/webapp/modules/Client.js index ed8085d29..18d8412a6 100644 --- a/guacamole-common-js/src/main/webapp/modules/Client.js +++ b/guacamole-common-js/src/main/webapp/modules/Client.js @@ -713,6 +713,18 @@ Guacamole.Client = function(tunnel) { * @param {String} name The name of the pipe. */ this.onpipe = null; + + /** + * Fired when a "required" instruction is received. A required instruction + * indicates that additional parameters are required for the connection to + * continue, such as user credentials. + * + * @event + * @param {String[]} parameters + * The names of the connection parameters that are required to be + * provided for the connection to continue. + */ + this.onrequired = null; /** * Fired whenever a sync instruction is received from the server, indicating @@ -1337,6 +1349,10 @@ Guacamole.Client = function(tunnel) { display.rect(layer, x, y, w, h); }, + + "required": function required(parameters) { + if (guac_client.onrequired) guac_client.onrequired(parameters); + }, "reset": function(parameters) { diff --git a/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolCapability.java b/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolCapability.java index 79f73f813..5cad8a280 100644 --- a/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolCapability.java +++ b/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolCapability.java @@ -40,7 +40,16 @@ public enum GuacamoleProtocolCapability { * {@link GuacamoleProtocolVersion#VERSION_1_1_0}. */ PROTOCOL_VERSION_DETECTION(GuacamoleProtocolVersion.VERSION_1_1_0), - + + /** + * Support for the "required" instruction. The "required" instruction + * allows the server to explicitly request connection parameters from the + * client without which the connection cannot continue, such as user + * credentials. Support for this instruction was introduced in + * {@link GuacamoleProtocolVersion#VERSION_1_3_0}. + */ + REQUIRED_INSTRUCTION(GuacamoleProtocolVersion.VERSION_1_3_0), + /** * Support for the "timezone" handshake instruction. The "timezone" * instruction allows the client to request that the server forward their diff --git a/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolVersion.java b/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolVersion.java index c1d50baca..3ceda3b1a 100644 --- a/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolVersion.java +++ b/guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleProtocolVersion.java @@ -46,11 +46,18 @@ public class GuacamoleProtocolVersion { */ public static final GuacamoleProtocolVersion VERSION_1_1_0 = new GuacamoleProtocolVersion(1, 1, 0); + /** + * Protocol version 1.3.0, which introduces the "required" instruction + * allowing the server to explicitly request connection parameters from the + * client. + */ + public static final GuacamoleProtocolVersion VERSION_1_3_0 = new GuacamoleProtocolVersion(1, 3, 0); + /** * The most recent version of the Guacamole protocol at the time this * version of GuacamoleProtocolVersion was built. */ - public static final GuacamoleProtocolVersion LATEST = VERSION_1_1_0; + public static final GuacamoleProtocolVersion LATEST = VERSION_1_3_0; /** * A regular expression that matches the VERSION_X_Y_Z pattern, where