diff --git a/.gitignore b/.gitignore
index b45ed795..df239c9a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,9 +32,6 @@
/client/administration/installer/UDSAdminInstaller/MSChart.exe
/client/administration/installer/UDSAdminInstaller/UDSAdminSetup.exe
-# /guacamole-tunnel/
-/guacamole-tunnel/target
-
# /linuxActor/
/linuxActor/udsactor_*
diff --git a/guacamole-tunnel/.gitignore b/guacamole-auth-uds/.gitignore
similarity index 68%
rename from guacamole-tunnel/.gitignore
rename to guacamole-auth-uds/.gitignore
index 8d61509d..acb95da7 100644
--- a/guacamole-tunnel/.gitignore
+++ b/guacamole-auth-uds/.gitignore
@@ -2,8 +2,6 @@
*~
# Generated files
-src/main/webapp/META-INF/
-src/main/webapp/generated/
target/
# IDE-specific configuration
diff --git a/guacamole-auth-uds/pom.xml b/guacamole-auth-uds/pom.xml
new file mode 100644
index 00000000..ff0099a1
--- /dev/null
+++ b/guacamole-auth-uds/pom.xml
@@ -0,0 +1,94 @@
+
+
+ 4.0.0
+ org.openuds.server
+ guacamole-auth-uds
+ jar
+ 2.5.0
+ UDS Integration Extension for Apache Guacamole
+ https://github.com/dkmstr/openuds
+
+
+ UTF-8
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.3
+
+ 1.8
+ 1.8
+
+ -Xlint:all
+ -Werror
+
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ unpack-dependencies
+ prepare-package
+
+ unpack-dependencies
+
+
+ runtime
+ ${project.build.directory}/classes
+
+
+
+
+
+
+
+
+
+
+
+ javax.servlet
+ servlet-api
+ provided
+ 2.5
+
+
+
+
+ javax.ws.rs
+ jsr311-api
+ 1.1.1
+ provided
+
+
+
+
+ org.apache.guacamole
+ guacamole-ext
+ 1.1.0
+ provided
+
+
+
+
+ com.google.inject
+ guice
+ 3.0
+
+
+
+
+
diff --git a/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSAuthenticatedUser.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSAuthenticatedUser.java
new file mode 100644
index 00000000..076731ed
--- /dev/null
+++ b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSAuthenticatedUser.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2020 Virtual Cable S.L.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of Virtual Cable S.L. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.openuds.guacamole;
+
+import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
+import org.apache.guacamole.net.auth.AuthenticatedUser;
+import org.apache.guacamole.net.auth.AuthenticationProvider;
+import org.apache.guacamole.net.auth.Credentials;
+import org.apache.guacamole.protocol.GuacamoleConfiguration;
+
+/**
+ * A Guacamole user that was authenticated by an external UDS service.
+ */
+public class UDSAuthenticatedUser extends AbstractAuthenticatedUser {
+
+ /**
+ * The AuthenticationProvider that authenticated this user.
+ */
+ private final AuthenticationProvider authProvider;
+
+ /**
+ * The credentials provided by this user when they authenticated.
+ */
+ private final Credentials credentials;
+
+ /**
+ * The GuacamoleConfiguration generated from the connection information
+ * returned by the external UDS service when the user authenticated.
+ */
+ private final GuacamoleConfiguration config;
+
+ /**
+ * Creates a new UDSAuthenticatedUser representing a Guacamole user that
+ * was authenticated by an external UDS service.
+ *
+ * @param authProvider
+ * The AuthenticationProvider that authenticated the user.
+ *
+ * @param credentials
+ * The credentials provided by the user when they authenticated.
+ *
+ * @param config
+ * The GuacamoleConfiguration generated from the connection information
+ * returned by the external UDS service when the user authenticated.
+ */
+ public UDSAuthenticatedUser(AuthenticationProvider authProvider,
+ Credentials credentials, GuacamoleConfiguration config) {
+ this.authProvider = authProvider;
+ this.credentials = credentials;
+ this.config = config;
+ }
+
+ @Override
+ public String getIdentifier() {
+ return AuthenticatedUser.ANONYMOUS_IDENTIFIER;
+ }
+
+ @Override
+ public AuthenticationProvider getAuthenticationProvider() {
+ return authProvider;
+ }
+
+ @Override
+ public Credentials getCredentials() {
+ return credentials;
+ }
+
+ /**
+ * Returns the GuacamoleConfiguration generated from the connection
+ * information provided by the external UDS service when the user
+ * authenticated.
+ *
+ * @return
+ * The GuacamoleConfiguration generated from the connection information
+ * provided by the external UDS service when the user authenticated.
+ */
+ public GuacamoleConfiguration getGuacamoleConfiguration() {
+ return config;
+ }
+
+}
diff --git a/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSAuthenticationProvider.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSAuthenticationProvider.java
new file mode 100644
index 00000000..6d10381f
--- /dev/null
+++ b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSAuthenticationProvider.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2020 Virtual Cable S.L.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of Virtual Cable S.L. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.openuds.guacamole;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import java.util.Collections;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.GuacamoleServerException;
+import org.apache.guacamole.form.Field;
+import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
+import org.apache.guacamole.net.auth.AuthenticatedUser;
+import org.apache.guacamole.net.auth.Credentials;
+import org.apache.guacamole.net.auth.UserContext;
+import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
+import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
+import org.apache.guacamole.net.auth.simple.SimpleUserContext;
+import org.apache.guacamole.protocol.GuacamoleConfiguration;
+import org.openuds.guacamole.connection.ConnectionService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AuthenticationProvider implementation which authenticates users that are
+ * confirmed as authorized by an external UDS service.
+ */
+public class UDSAuthenticationProvider extends AbstractAuthenticationProvider {
+
+ /**
+ * The name of the single connection that should be exposed to any user
+ * that authenticates via UDS.
+ */
+ private static final String CONNECTION_NAME = "UDS";
+
+ /**
+ * The name of the query parameter that should contain the data sent to
+ * the UDS service for authentication.
+ */
+ private static final String DATA_PARAMETER_NAME = "data";
+
+ /**
+ * Logger for this class.
+ */
+ private final Logger logger = LoggerFactory.getLogger(UDSAuthenticationProvider.class);
+
+ /**
+ * Service for retrieving connection configuration information from the
+ * UDS service.
+ */
+ private final ConnectionService connectionService;
+
+ /**
+ * Creates a new UDSAuthenticationProvider which authenticates users
+ * against an external UDS service.
+ *
+ * @throws GuacamoleException
+ * If an error prevents guacamole.properties from being read.
+ */
+ public UDSAuthenticationProvider() throws GuacamoleException {
+
+ // Create an injector with OpenUDS- and Guacamole-specific services
+ // properly bound
+ Injector injector = Guice.createInjector(
+ new UDSModule()
+ );
+
+ // Pull instance of connection service from injector
+ connectionService = injector.getInstance(ConnectionService.class);
+
+ }
+
+ @Override
+ public String getIdentifier() {
+ return "uds";
+ }
+
+ @Override
+ public AuthenticatedUser authenticateUser(Credentials credentials)
+ throws GuacamoleException {
+
+ HttpServletRequest request = credentials.getRequest();
+
+ // Pull OpenUDS-specific "data" parameter
+ String data = request.getParameter(DATA_PARAMETER_NAME);
+ if (data != null && !data.isEmpty()) {
+
+ logger.debug("Retrieving connection configuration using data from \"{}\"...", data);
+
+ // Retrieve connection information using provided data
+ GuacamoleConfiguration config = connectionService.getConnectionConfiguration(data);
+ if (config != null) {
+
+ // Report successful authentication as a temporary, anonymous user,
+ // storing the retrieved connection configuration data for future use
+ return new UDSAuthenticatedUser(this, credentials, config);
+
+ }
+
+ }
+
+ // Required parameter was missing or was invalid
+ throw new GuacamoleInvalidCredentialsException(
+ "Connection data was not provided or was rejected by UDS.",
+ new CredentialsInfo(Collections.singletonList(
+ new Field(DATA_PARAMETER_NAME, Field.Type.QUERY_PARAMETER)
+ ))
+ );
+
+ }
+
+ @Override
+ public UserContext getUserContext(AuthenticatedUser authenticatedUser)
+ throws GuacamoleException {
+
+ // Provide data only for users authenticated by this extension
+ if (!(authenticatedUser instanceof UDSAuthenticatedUser))
+ return null;
+
+ // Expose a single connection (derived from the "data" parameter
+ // provided during authentication)
+ return new SimpleUserContext(this, Collections.singletonMap(
+ CONNECTION_NAME,
+ ((UDSAuthenticatedUser) authenticatedUser).getGuacamoleConfiguration()
+ ));
+
+ }
+
+}
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/UDSModule.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSModule.java
similarity index 68%
rename from guacamole-tunnel/src/main/java/org/openuds/guacamole/UDSModule.java
rename to guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSModule.java
index 76e904d1..7163a0bc 100644
--- a/guacamole-tunnel/src/main/java/org/openuds/guacamole/UDSModule.java
+++ b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/UDSModule.java
@@ -28,9 +28,10 @@
package org.openuds.guacamole;
-import com.google.inject.servlet.ServletModule;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import org.apache.guacamole.tunnel.TunnelRequestService;
+import com.google.inject.AbstractModule;
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.environment.Environment;
+import org.apache.guacamole.environment.LocalEnvironment;
import org.openuds.guacamole.config.ConfigurationService;
import org.openuds.guacamole.connection.ConnectionService;
@@ -38,18 +39,34 @@ import org.openuds.guacamole.connection.ConnectionService;
* Guice module which binds classes required by the OpenUDS integration of
* Apache Guacamole.
*/
-public class UDSModule extends ServletModule {
+public class UDSModule extends AbstractModule {
+
+ /**
+ * The Guacamole server environment.
+ */
+ private final Environment environment;
+
+ /**
+ * Creates a new UDSModule which binds classes required by the OpenUDS
+ * integration of Apache Guacamole, including an implementation of the
+ * Guacamole server {@link Environment}.
+ *
+ * @throws GuacamoleException
+ * If the guacamole.properties file cannot be read.
+ */
+ public UDSModule() throws GuacamoleException {
+ this.environment = new LocalEnvironment();
+ }
@Override
- protected void configureServlets() {
+ protected void configure() {
- // Serve servlets, etc. with Guice
- bind(GuiceContainer.class);
+ // Bind instance of Guacamole server environment
+ bind(Environment.class).toInstance(environment);
// Bind UDS-specific services
bind(ConfigurationService.class);
bind(ConnectionService.class);
- bind(TunnelRequestService.class);
}
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/config/ConfigurationService.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/config/ConfigurationService.java
similarity index 73%
rename from guacamole-tunnel/src/main/java/org/openuds/guacamole/config/ConfigurationService.java
rename to guacamole-auth-uds/src/main/java/org/openuds/guacamole/config/ConfigurationService.java
index 0fdefc3d..9b300311 100644
--- a/guacamole-tunnel/src/main/java/org/openuds/guacamole/config/ConfigurationService.java
+++ b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/config/ConfigurationService.java
@@ -35,16 +35,16 @@ import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Properties;
-import javax.servlet.ServletContext;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleServerException;
+import org.apache.guacamole.environment.Environment;
+import org.apache.guacamole.properties.StringGuacamoleProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Service that provides access to configuration information stored within
- * OpenUDS' tunnel.properties file.
+ * Service that provides access to OpenUDS-specific configuration information
+ * stored within guacamole.properties.
*/
@Singleton
public class ConfigurationService {
@@ -59,7 +59,14 @@ public class ConfigurationService {
* whose content dictates the base URL of the service providing connection
* configuration information.
*/
- private static final String UDSFILE_PROPERTY = "udsfile";
+ private static final StringGuacamoleProperty UDSFILE_PROPERTY = new StringGuacamoleProperty() {
+
+ @Override
+ public String getName() {
+ return "udsfile";
+ }
+
+ };
/**
* The path beneath the OpenUDS service base URI (scheme + hostname) at
@@ -69,9 +76,10 @@ public class ConfigurationService {
private static final String UDS_CONNECTION_PATH = "/guacamole/";
/**
- * The base URI (scheme + hostname) where OpenUDS is being served.
+ * The Guacamole server environment.
*/
- private final URI udsBaseURI;
+ @Inject
+ private Environment environment;
/**
* Parses the contents of the given file, reading the URI of the OpenUDS
@@ -157,56 +165,6 @@ public class ConfigurationService {
}
- /**
- * Creates a new ConfigurationService which provides access to the
- * configuration information stored within the "/WEB-INF/tunnel.properties"
- * file in the classpath. This file will be parsed immediately, but any
- * resulting errors will simply be logged. If configuration information
- * cannot be read, attempts to retrieve this information later through calls
- * to the getters of this service will fail with appropriate exceptions.
- *
- * @param context
- * The ServletContext associated with the servlet container which is
- * serving this web application.
- */
- @Inject
- public ConfigurationService(ServletContext context) {
-
- // Read tunnel.properties
- Properties config = new Properties();
- try {
- config.load(context.getResourceAsStream("/WEB-INF/tunnel.properties"));
- }
- catch (IOException e) {
- logger.error("Unable to read tunnel.properties.", e);
- }
-
- // Parse URI from the UDS file (if defined)
- URI parsedURI = null;
- String udsFile = config.getProperty(UDSFILE_PROPERTY);
- if (udsFile != null) {
-
- // Attempt to parse base URI from the UDS file, logging any failures
- try {
- parsedURI = getBaseURI(readServiceURI(udsFile));
- }
- catch (GuacamoleException e) {
- logger.error("OpenUDS service URI could not be parsed. This "
- + "web application WILL NOT FUNCTION.", e);
- }
-
- }
-
- // If no UDS file is defined, web application startup has failed
- else
- logger.error("Property \"{}\" not found within tunnel.properties. "
- + "This web application WILL NOT FUNCTION.", UDSFILE_PROPERTY);
-
- // Assign the parsed URI, which may be null
- udsBaseURI = parsedURI;
-
- }
-
/**
* Returns the base URI of the OpenUDS service. All services providing data
* to this Guacamole integration are hosted beneath this base URI.
@@ -221,11 +179,11 @@ public class ConfigurationService {
*/
public URI getUDSBaseURI() throws GuacamoleException {
- // Explicitly fail if the configuration was not successfully read
- if (udsBaseURI == null)
- throw new GuacamoleServerException("The UDS base URI is not defined.");
+ // Parse URI from the UDS file (if defined)
+ String udsFile = environment.getRequiredProperty(UDSFILE_PROPERTY);
- return udsBaseURI;
+ // Attempt to parse base URI from the UDS file
+ return getBaseURI(readServiceURI(udsFile));
}
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/config/package-info.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/config/package-info.java
similarity index 100%
rename from guacamole-tunnel/src/main/java/org/openuds/guacamole/config/package-info.java
rename to guacamole-auth-uds/src/main/java/org/openuds/guacamole/config/package-info.java
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/connection/ConnectionService.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/connection/ConnectionService.java
similarity index 100%
rename from guacamole-tunnel/src/main/java/org/openuds/guacamole/connection/ConnectionService.java
rename to guacamole-auth-uds/src/main/java/org/openuds/guacamole/connection/ConnectionService.java
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/connection/package-info.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/connection/package-info.java
similarity index 100%
rename from guacamole-tunnel/src/main/java/org/openuds/guacamole/connection/package-info.java
rename to guacamole-auth-uds/src/main/java/org/openuds/guacamole/connection/package-info.java
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/package-info.java b/guacamole-auth-uds/src/main/java/org/openuds/guacamole/package-info.java
similarity index 100%
rename from guacamole-tunnel/src/main/java/org/openuds/guacamole/package-info.java
rename to guacamole-auth-uds/src/main/java/org/openuds/guacamole/package-info.java
diff --git a/guacamole-auth-uds/src/main/resources/guac-manifest.json b/guacamole-auth-uds/src/main/resources/guac-manifest.json
new file mode 100644
index 00000000..7a454953
--- /dev/null
+++ b/guacamole-auth-uds/src/main/resources/guac-manifest.json
@@ -0,0 +1,18 @@
+{
+
+ "guacamoleVersion" : "1.1.0",
+
+ "name" : "UDS Integration Extension for Apache Guacamole",
+ "namespace" : "uds",
+ "largeIcon" : "images/udsicon.png",
+ "smallIcon" : "images/udsicon.png",
+
+ "authProviders" : [
+ "org.openuds.guacamole.UDSAuthenticationProvider"
+ ],
+
+ "translations" : [
+ "translations/en.json"
+ ]
+
+}
diff --git a/guacamole-tunnel/src/main/webapp/images/udsicon.png b/guacamole-auth-uds/src/main/resources/images/udsicon.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/udsicon.png
rename to guacamole-auth-uds/src/main/resources/images/udsicon.png
diff --git a/guacamole-auth-uds/src/main/resources/translations/en.json b/guacamole-auth-uds/src/main/resources/translations/en.json
new file mode 100644
index 00000000..2f77a9ca
--- /dev/null
+++ b/guacamole-auth-uds/src/main/resources/translations/en.json
@@ -0,0 +1,7 @@
+{
+
+ "DATA_SOURCE_UDS" : {
+ "NAME" : "UDS"
+ }
+
+}
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-back.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-back.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-back.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-back.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-close.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-close.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-close.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-close.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-config.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-config.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-config.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-config.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-delete.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-delete.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-delete.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-delete.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-first-page.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-first-page.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-first-page.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-first-page.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-group-add.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-group-add.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-group-add.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-group-add.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-last-page.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-last-page.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-last-page.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-last-page.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-logout.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-logout.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-logout.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-logout.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-monitor-add.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-monitor-add.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-monitor-add.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-monitor-add.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-next-page.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-next-page.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-next-page.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-next-page.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-prev-page.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-prev-page.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-prev-page.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-prev-page.png
diff --git a/guacamole-tunnel/src/main/webapp/images/action-icons/guac-user-add.png b/guacamole-auth-uds/src/main/webapp/images/action-icons/guac-user-add.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/action-icons/guac-user-add.png
rename to guacamole-auth-uds/src/main/webapp/images/action-icons/guac-user-add.png
diff --git a/guacamole-tunnel/src/main/webapp/images/arrows/arrows-d.png b/guacamole-auth-uds/src/main/webapp/images/arrows/arrows-d.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/arrows/arrows-d.png
rename to guacamole-auth-uds/src/main/webapp/images/arrows/arrows-d.png
diff --git a/guacamole-tunnel/src/main/webapp/images/arrows/arrows-l.png b/guacamole-auth-uds/src/main/webapp/images/arrows/arrows-l.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/arrows/arrows-l.png
rename to guacamole-auth-uds/src/main/webapp/images/arrows/arrows-l.png
diff --git a/guacamole-tunnel/src/main/webapp/images/arrows/arrows-r.png b/guacamole-auth-uds/src/main/webapp/images/arrows/arrows-r.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/arrows/arrows-r.png
rename to guacamole-auth-uds/src/main/webapp/images/arrows/arrows-r.png
diff --git a/guacamole-tunnel/src/main/webapp/images/arrows/arrows-u.png b/guacamole-auth-uds/src/main/webapp/images/arrows/arrows-u.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/arrows/arrows-u.png
rename to guacamole-auth-uds/src/main/webapp/images/arrows/arrows-u.png
diff --git a/guacamole-tunnel/src/main/webapp/images/group-icons/guac-closed.png b/guacamole-auth-uds/src/main/webapp/images/group-icons/guac-closed.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/group-icons/guac-closed.png
rename to guacamole-auth-uds/src/main/webapp/images/group-icons/guac-closed.png
diff --git a/guacamole-tunnel/src/main/webapp/images/group-icons/guac-open.png b/guacamole-auth-uds/src/main/webapp/images/group-icons/guac-open.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/group-icons/guac-open.png
rename to guacamole-auth-uds/src/main/webapp/images/group-icons/guac-open.png
diff --git a/guacamole-tunnel/src/main/webapp/images/guac-mono-192.png b/guacamole-auth-uds/src/main/webapp/images/guac-mono-192.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/guac-mono-192.png
rename to guacamole-auth-uds/src/main/webapp/images/guac-mono-192.png
diff --git a/guacamole-tunnel/src/main/webapp/images/guacamole-logo-144.png b/guacamole-auth-uds/src/main/webapp/images/guacamole-logo-144.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/guacamole-logo-144.png
rename to guacamole-auth-uds/src/main/webapp/images/guacamole-logo-144.png
diff --git a/guacamole-tunnel/src/main/webapp/images/guacamole-logo-24.png b/guacamole-auth-uds/src/main/webapp/images/guacamole-logo-24.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/guacamole-logo-24.png
rename to guacamole-auth-uds/src/main/webapp/images/guacamole-logo-24.png
diff --git a/guacamole-tunnel/src/main/webapp/images/guacamole-logo-64.png b/guacamole-auth-uds/src/main/webapp/images/guacamole-logo-64.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/guacamole-logo-64.png
rename to guacamole-auth-uds/src/main/webapp/images/guacamole-logo-64.png
diff --git a/guacamole-tunnel/src/main/webapp/images/mouse/blank.cur b/guacamole-auth-uds/src/main/webapp/images/mouse/blank.cur
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/mouse/blank.cur
rename to guacamole-auth-uds/src/main/webapp/images/mouse/blank.cur
diff --git a/guacamole-tunnel/src/main/webapp/images/mouse/blank.gif b/guacamole-auth-uds/src/main/webapp/images/mouse/blank.gif
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/mouse/blank.gif
rename to guacamole-auth-uds/src/main/webapp/images/mouse/blank.gif
diff --git a/guacamole-tunnel/src/main/webapp/images/mouse/dot.gif b/guacamole-auth-uds/src/main/webapp/images/mouse/dot.gif
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/mouse/dot.gif
rename to guacamole-auth-uds/src/main/webapp/images/mouse/dot.gif
diff --git a/guacamole-tunnel/src/main/webapp/images/noguacamole-logo-24.png b/guacamole-auth-uds/src/main/webapp/images/noguacamole-logo-24.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/noguacamole-logo-24.png
rename to guacamole-auth-uds/src/main/webapp/images/noguacamole-logo-24.png
diff --git a/guacamole-tunnel/src/main/webapp/images/progress.png b/guacamole-auth-uds/src/main/webapp/images/progress.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/progress.png
rename to guacamole-auth-uds/src/main/webapp/images/progress.png
diff --git a/guacamole-tunnel/src/main/webapp/images/protocol-icons/guac-monitor.png b/guacamole-auth-uds/src/main/webapp/images/protocol-icons/guac-monitor.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/protocol-icons/guac-monitor.png
rename to guacamole-auth-uds/src/main/webapp/images/protocol-icons/guac-monitor.png
diff --git a/guacamole-tunnel/src/main/webapp/images/protocol-icons/guac-plug.png b/guacamole-auth-uds/src/main/webapp/images/protocol-icons/guac-plug.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/protocol-icons/guac-plug.png
rename to guacamole-auth-uds/src/main/webapp/images/protocol-icons/guac-plug.png
diff --git a/guacamole-tunnel/src/main/webapp/images/protocol-icons/guac-text.png b/guacamole-auth-uds/src/main/webapp/images/protocol-icons/guac-text.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/protocol-icons/guac-text.png
rename to guacamole-auth-uds/src/main/webapp/images/protocol-icons/guac-text.png
diff --git a/guacamole-tunnel/src/main/webapp/images/settings/tablet-keys.png b/guacamole-auth-uds/src/main/webapp/images/settings/tablet-keys.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/settings/tablet-keys.png
rename to guacamole-auth-uds/src/main/webapp/images/settings/tablet-keys.png
diff --git a/guacamole-tunnel/src/main/webapp/images/settings/touchpad.png b/guacamole-auth-uds/src/main/webapp/images/settings/touchpad.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/settings/touchpad.png
rename to guacamole-auth-uds/src/main/webapp/images/settings/touchpad.png
diff --git a/guacamole-tunnel/src/main/webapp/images/settings/touchscreen.png b/guacamole-auth-uds/src/main/webapp/images/settings/touchscreen.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/settings/touchscreen.png
rename to guacamole-auth-uds/src/main/webapp/images/settings/touchscreen.png
diff --git a/guacamole-tunnel/src/main/webapp/images/settings/zoom-in.png b/guacamole-auth-uds/src/main/webapp/images/settings/zoom-in.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/settings/zoom-in.png
rename to guacamole-auth-uds/src/main/webapp/images/settings/zoom-in.png
diff --git a/guacamole-tunnel/src/main/webapp/images/settings/zoom-out.png b/guacamole-auth-uds/src/main/webapp/images/settings/zoom-out.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/settings/zoom-out.png
rename to guacamole-auth-uds/src/main/webapp/images/settings/zoom-out.png
diff --git a/guacamole-tunnel/src/main/webapp/images/user-icons/guac-user.png b/guacamole-auth-uds/src/main/webapp/images/user-icons/guac-user.png
similarity index 100%
rename from guacamole-tunnel/src/main/webapp/images/user-icons/guac-user.png
rename to guacamole-auth-uds/src/main/webapp/images/user-icons/guac-user.png
diff --git a/guacamole-tunnel/NOTICE b/guacamole-tunnel/NOTICE
deleted file mode 100644
index 2ef7e548..00000000
--- a/guacamole-tunnel/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Guacamole
-Copyright 2016 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
diff --git a/guacamole-tunnel/pom.xml b/guacamole-tunnel/pom.xml
deleted file mode 100644
index 4caea2fc..00000000
--- a/guacamole-tunnel/pom.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
- 4.0.0
- org.openuds.server
- transport
- war
- 2.5.0
- Guacamole Transport
- https://github.com/dkmstr/openuds
-
-
- UTF-8
-
-
-
- transport
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.3
-
- 1.6
- 1.6
-
- -Xlint:all
- -Werror
-
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- 2.6
-
-
-
- org.apache.guacamole
- guacamole-common-js
- zip
-
-
-
-
-
-
-
-
-
-
-
-
- javax.servlet
- servlet-api
- provided
- 2.5
-
-
-
-
- org.slf4j
- slf4j-api
- 1.6.1
-
-
- org.slf4j
- slf4j-jcl
- 1.6.1
- runtime
-
-
-
-
- org.apache.guacamole
- guacamole-common
- 1.1.0
-
-
-
-
- org.apache.guacamole
- guacamole-common-js
- 1.2.0
- zip
- runtime
-
-
-
-
- javax.websocket
- javax.websocket-api
- 1.0
- provided
-
-
-
-
- org.eclipse.jetty
- jetty-websocket
- 8.1.1.v20120215
- provided
-
-
-
-
- org.eclipse.jetty
- jetty-parent
- 20
- provided
- pom
-
-
- org.eclipse.jetty.websocket
- websocket-api
- 9.0.7.v20131107
- provided
-
-
- org.eclipse.jetty.websocket
- websocket-servlet
- 9.0.7.v20131107
- provided
-
-
-
-
- org.apache.tomcat
- tomcat-catalina
- 7.0.37
- provided
-
-
- org.apache.tomcat
- tomcat-coyote
- 7.0.37
- provided
-
-
-
-
- com.sun.jersey.contribs
- jersey-guice
- 1.17.1
-
-
-
-
- com.google.inject.extensions
- guice-servlet
- 3.0
-
-
-
-
- com.google.inject
- guice
- 3.0
-
-
-
-
-
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelLoader.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelLoader.java
deleted file mode 100644
index b91527f5..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelLoader.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel;
-
-import com.google.inject.Module;
-
-/**
- * Generic means of loading a tunnel without adding explicit dependencies within
- * the main ServletModule, as not all servlet containers may have the classes
- * required by all tunnel implementations.
- *
- * @author Michael Jumper
- */
-public interface TunnelLoader extends Module {
-
- /**
- * Checks whether this type of tunnel is supported by the servlet container.
- *
- * @return true if this type of tunnel is supported and can be loaded
- * without errors, false otherwise.
- */
- public boolean isSupported();
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelModule.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelModule.java
deleted file mode 100644
index 9b03ecb8..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelModule.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel;
-
-import org.apache.guacamole.tunnel.http.RestrictedGuacamoleHTTPTunnelServlet;
-import com.google.inject.servlet.ServletModule;
-import java.lang.reflect.InvocationTargetException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Module which loads tunnel implementations.
- *
- * @author Michael Jumper
- */
-public class TunnelModule extends ServletModule {
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(TunnelModule.class);
-
- /**
- * Classnames of all implementation-specific WebSocket tunnel modules.
- */
- private static final String[] WEBSOCKET_MODULES = {
- "org.apache.guacamole.tunnel.websocket.WebSocketTunnelModule",
- "org.apache.guacamole.tunnel.websocket.jetty8.WebSocketTunnelModule",
- "org.apache.guacamole.tunnel.websocket.jetty9.WebSocketTunnelModule",
- "org.apache.guacamole.tunnel.websocket.tomcat.WebSocketTunnelModule"
- };
-
- private boolean loadWebSocketModule(String classname) {
-
- try {
-
- // Attempt to find WebSocket module
- Class> module = Class.forName(classname);
-
- // Create loader
- TunnelLoader loader = (TunnelLoader) module.getConstructor().newInstance();
-
- // Install module, if supported
- if (loader.isSupported()) {
- install(loader);
- return true;
- }
-
- }
-
- // If no such class or constructor, etc., then this particular
- // WebSocket support is not present
- catch (ClassNotFoundException e) {}
- catch (NoClassDefFoundError e) {}
- catch (NoSuchMethodException e) {}
-
- // Log errors which indicate bugs
- catch (InstantiationException e) {
- logger.debug("Error instantiating WebSocket module.", e);
- }
- catch (IllegalAccessException e) {
- logger.debug("Error instantiating WebSocket module.", e);
- }
- catch (InvocationTargetException e) {
- logger.debug("Error instantiating WebSocket module.", e);
- }
-
- // Load attempt failed
- return false;
-
- }
-
- @Override
- protected void configureServlets() {
-
- bind(TunnelRequestService.class);
-
- // Set up HTTP tunnel
- serve("/tunnel").with(RestrictedGuacamoleHTTPTunnelServlet.class);
-
- // Try to load each WebSocket tunnel in sequence
- for (String classname : WEBSOCKET_MODULES) {
- if (loadWebSocketModule(classname)) {
- logger.debug("WebSocket module loaded: {}", classname);
- return;
- }
- }
-
- // Warn of lack of WebSocket
- logger.info("WebSocket support NOT present. Only HTTP will be used.");
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelRequest.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelRequest.java
deleted file mode 100644
index 2c97f047..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelRequest.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel;
-
-import java.util.List;
-import org.apache.guacamole.GuacamoleClientException;
-import org.apache.guacamole.GuacamoleClientException;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.GuacamoleException;
-
-/**
- * A request object which provides only the functions absolutely required to
- * retrieve and connect to a tunnel.
- *
- * @author Michael Jumper
- */
-public abstract class TunnelRequest {
-
- /**
- * The name of the request parameter containing the user's authentication
- * token.
- */
- public static final String AUTH_TOKEN_PARAMETER = "token";
-
- /**
- * The name of the parameter containing the identifier of the
- * AuthenticationProvider associated with the UserContext containing the
- * object to which a tunnel is being requested.
- */
- public static final String AUTH_PROVIDER_IDENTIFIER_PARAMETER = "GUAC_DATA_SOURCE";
-
- /**
- * The name of the parameter specifying the type of object to which a
- * tunnel is being requested. Currently, this may be "c" for a Guacamole
- * connection, or "g" for a Guacamole connection group.
- */
- public static final String TYPE_PARAMETER = "GUAC_TYPE";
-
- /**
- * The name of the parameter containing the unique identifier of the object
- * to which a tunnel is being requested.
- */
- public static final String IDENTIFIER_PARAMETER = "GUAC_ID";
-
- /**
- * The name of the parameter containing the desired display width, in
- * pixels.
- */
- public static final String WIDTH_PARAMETER = "GUAC_WIDTH";
-
- /**
- * The name of the parameter containing the desired display height, in
- * pixels.
- */
- public static final String HEIGHT_PARAMETER = "GUAC_HEIGHT";
-
- /**
- * The name of the parameter containing the desired display resolution, in
- * DPI.
- */
- public static final String DPI_PARAMETER = "GUAC_DPI";
-
- /**
- * The name of the parameter specifying one supported audio mimetype. This
- * will normally appear multiple times within a single tunnel request -
- * once for each mimetype.
- */
- public static final String AUDIO_PARAMETER = "GUAC_AUDIO";
-
- /**
- * The name of the parameter specifying one supported video mimetype. This
- * will normally appear multiple times within a single tunnel request -
- * once for each mimetype.
- */
- public static final String VIDEO_PARAMETER = "GUAC_VIDEO";
-
- /**
- * The name of the parameter specifying one supported image mimetype. This
- * will normally appear multiple times within a single tunnel request -
- * once for each mimetype.
- */
- public static final String IMAGE_PARAMETER = "GUAC_IMAGE";
-
- /**
- * All supported object types that can be used as the destination of a
- * tunnel.
- */
- public static enum Type {
-
- /**
- * A Guacamole connection.
- */
- CONNECTION("c"),
-
- /**
- * A Guacamole connection group.
- */
- CONNECTION_GROUP("g");
-
- /**
- * The parameter value which denotes a destination object of this type.
- */
- final String PARAMETER_VALUE;
-
- /**
- * Defines a Type having the given corresponding parameter value.
- *
- * @param value
- * The parameter value which denotes a destination object of this
- * type.
- */
- Type(String value) {
- PARAMETER_VALUE = value;
- }
-
- };
-
- /**
- * Returns the value of the parameter having the given name.
- *
- * @param name
- * The name of the parameter to return.
- *
- * @return
- * The value of the parameter having the given name, or null if no such
- * parameter was specified.
- */
- public abstract String getParameter(String name);
-
- /**
- * Returns a list of all values specified for the given parameter.
- *
- * @param name
- * The name of the parameter to return.
- *
- * @return
- * All values of the parameter having the given name , or null if no
- * such parameter was specified.
- */
- public abstract List getParameterValues(String name);
-
- /**
- * Returns the value of the parameter having the given name, throwing an
- * exception if the parameter is missing.
- *
- * @param name
- * The name of the parameter to return.
- *
- * @return
- * The value of the parameter having the given name.
- *
- * @throws GuacamoleException
- * If the parameter is not present in the request.
- */
- public String getRequiredParameter(String name) throws GuacamoleException {
-
- // Pull requested parameter, aborting if absent
- String value = getParameter(name);
- if (value == null)
- throw new GuacamoleClientException("Parameter \"" + name + "\" is required.");
-
- return value;
-
- }
-
- /**
- * Returns the integer value of the parameter having the given name,
- * throwing an exception if the parameter cannot be parsed.
- *
- * @param name
- * The name of the parameter to return.
- *
- * @return
- * The integer value of the parameter having the given name, or null if
- * the parameter is missing.
- *
- * @throws GuacamoleException
- * If the parameter is not a valid integer.
- */
- public Integer getIntegerParameter(String name) throws GuacamoleException {
-
- // Pull requested parameter
- String value = getParameter(name);
- if (value == null)
- return null;
-
- // Attempt to parse as an integer
- try {
- return Integer.parseInt(value);
- }
-
- // Rethrow any parsing error as a GuacamoleClientException
- catch (NumberFormatException e) {
- throw new GuacamoleClientException("Parameter \"" + name + "\" must be a valid integer.", e);
- }
-
- }
-
- /**
- * Returns the authentication token associated with this tunnel request.
- *
- * @return
- * The authentication token associated with this tunnel request, or
- * null if no authentication token is present.
- */
- public String getAuthenticationToken() {
- return getParameter(AUTH_TOKEN_PARAMETER);
- }
-
- /**
- * Returns the identifier of the AuthenticationProvider associated with the
- * UserContext from which the connection or connection group is to be
- * retrieved when the tunnel is created. In the context of the REST API and
- * the JavaScript side of the web application, this is referred to as the
- * data source identifier.
- *
- * @return
- * The identifier of the AuthenticationProvider associated with the
- * UserContext from which the connection or connection group is to be
- * retrieved when the tunnel is created.
- *
- * @throws GuacamoleException
- * If the identifier was not present in the request.
- */
- public String getAuthenticationProviderIdentifier()
- throws GuacamoleException {
- return getRequiredParameter(AUTH_PROVIDER_IDENTIFIER_PARAMETER);
- }
-
- /**
- * Returns the type of object for which the tunnel is being requested.
- *
- * @return
- * The type of object for which the tunnel is being requested.
- *
- * @throws GuacamoleException
- * If the type was not present in the request, or if the type requested
- * is in the wrong format.
- */
- public Type getType() throws GuacamoleException {
-
- String type = getRequiredParameter(TYPE_PARAMETER);
-
- // For each possible object type
- for (Type possibleType : Type.values()) {
-
- // Match against defined parameter value
- if (type.equals(possibleType.PARAMETER_VALUE))
- return possibleType;
-
- }
-
- throw new GuacamoleClientException("Illegal identifier - unknown type.");
-
- }
-
- /**
- * Returns the identifier of the destination of the tunnel being requested.
- * As there are multiple types of destination objects available, and within
- * multiple data sources, the associated object type and data source are
- * also necessary to determine what this identifier refers to.
- *
- * @return
- * The identifier of the destination of the tunnel being requested.
- *
- * @throws GuacamoleException
- * If the identifier was not present in the request.
- */
- public String getIdentifier() throws GuacamoleException {
- return getRequiredParameter(IDENTIFIER_PARAMETER);
- }
-
- /**
- * Returns the display width desired for the Guacamole session over the
- * tunnel being requested.
- *
- * @return
- * The display width desired for the Guacamole session over the tunnel
- * being requested, or null if no width was given.
- *
- * @throws GuacamoleException
- * If the width specified was not a valid integer.
- */
- public Integer getWidth() throws GuacamoleException {
- return getIntegerParameter(WIDTH_PARAMETER);
- }
-
- /**
- * Returns the display height desired for the Guacamole session over the
- * tunnel being requested.
- *
- * @return
- * The display height desired for the Guacamole session over the tunnel
- * being requested, or null if no width was given.
- *
- * @throws GuacamoleException
- * If the height specified was not a valid integer.
- */
- public Integer getHeight() throws GuacamoleException {
- return getIntegerParameter(HEIGHT_PARAMETER);
- }
-
- /**
- * Returns the display resolution desired for the Guacamole session over
- * the tunnel being requested, in DPI.
- *
- * @return
- * The display resolution desired for the Guacamole session over the
- * tunnel being requested, or null if no resolution was given.
- *
- * @throws GuacamoleException
- * If the resolution specified was not a valid integer.
- */
- public Integer getDPI() throws GuacamoleException {
- return getIntegerParameter(DPI_PARAMETER);
- }
-
- /**
- * Returns a list of all audio mimetypes declared as supported within the
- * tunnel request.
- *
- * @return
- * A list of all audio mimetypes declared as supported within the
- * tunnel request, or null if no mimetypes were specified.
- */
- public List getAudioMimetypes() {
- return getParameterValues(AUDIO_PARAMETER);
- }
-
- /**
- * Returns a list of all video mimetypes declared as supported within the
- * tunnel request.
- *
- * @return
- * A list of all video mimetypes declared as supported within the
- * tunnel request, or null if no mimetypes were specified.
- */
- public List getVideoMimetypes() {
- return getParameterValues(VIDEO_PARAMETER);
- }
-
- /**
- * Returns a list of all image mimetypes declared as supported within the
- * tunnel request.
- *
- * @return
- * A list of all image mimetypes declared as supported within the
- * tunnel request, or null if no mimetypes were specified.
- */
- public List getImageMimetypes() {
- return getParameterValues(IMAGE_PARAMETER);
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelRequestService.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelRequestService.java
deleted file mode 100644
index 0cb62ee0..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/TunnelRequestService.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.apache.guacamole.GuacamoleClientException;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.GuacamoleSocket;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.net.InetGuacamoleSocket;
-import org.apache.guacamole.net.SimpleGuacamoleTunnel;
-import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
-import org.apache.guacamole.protocol.GuacamoleClientInformation;
-import org.apache.guacamole.protocol.GuacamoleConfiguration;
-import org.openuds.guacamole.connection.ConnectionService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility class that takes a standard request from the Guacamole JavaScript
- * client and produces the corresponding GuacamoleTunnel. The implementation
- * of this utility is specific to the form of request used by the upstream
- * Guacamole web application, and is not necessarily useful to applications
- * that use purely the Guacamole API.
- *
- * @author Michael Jumper
- * @author Vasily Loginov
- */
-@Singleton
-public class TunnelRequestService {
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(TunnelRequestService.class);
-
- /**
- * Service for retrieving remotely-maintained connection information.
- */
- @Inject
- private ConnectionService connectionService;
-
- /**
- * The hostname of the server hosting guacd.
- */
- private static final String GUACD_HOSTNAME = "127.0.0.1";
-
- /**
- * The port that guacd will be listening on.
- */
- private static final int GUACD_PORT = 4822;
-
- /**
- * Creates a new tunnel using the parameters and credentials present in
- * the given request.
- *
- * @param request
- * The HttpServletRequest describing the tunnel to create.
- *
- * @return
- * The created tunnel, or null if the tunnel could not be created.
- *
- * @throws GuacamoleException
- * If an error occurs while creating the tunnel.
- */
- public GuacamoleTunnel createTunnel(TunnelRequest request) throws GuacamoleException {
-
- // Pull OpenUDS-specific "data" parameter
- String data = request.getParameter("data");
- if (data == null || data.isEmpty()) {
- logger.debug("No ID received in tunnel connect request.");
- throw new GuacamoleClientException("Connection data not provided.");
- }
-
- logger.debug("Establishing tunnel and connection with data from \"{}\"...", data);
-
- // Get connection from remote service
- GuacamoleConfiguration config = connectionService.getConnectionConfiguration(data);
- if (config == null)
- throw new GuacamoleClientException("Connection configuration could not be retrieved.");
-
- // Get client information
- GuacamoleClientInformation info = new GuacamoleClientInformation();
-
- // Set width if provided
- String width = request.getParameter("GUAC_WIDTH");
- if (width != null)
- info.setOptimalScreenWidth(Integer.parseInt(width));
-
- // Set height if provided
- String height = request.getParameter("GUAC_HEIGHT");
- if (height != null)
- info.setOptimalScreenHeight(Integer.parseInt(height));
-
- // Set resolution if provided
- String dpi = request.getParameter("GUAC_DPI");
- if (dpi != null)
- info.setOptimalResolution(Integer.parseInt(dpi));
-
- // Add audio mimetypes
- List audio_mimetypes = request.getParameterValues("GUAC_AUDIO");
- if (audio_mimetypes != null)
- info.getAudioMimetypes().addAll(audio_mimetypes);
-
- // Add video mimetypes
- List video_mimetypes = request.getParameterValues("GUAC_VIDEO");
- if (video_mimetypes != null)
- info.getVideoMimetypes().addAll(video_mimetypes);
-
- // Add image mimetypes
- List image_mimetypes = request.getParameterValues("GUAC_IMAGE");
- if (image_mimetypes != null)
- info.getImageMimetypes().addAll(image_mimetypes);
-
- // Connect socket for connection
- GuacamoleSocket socket;
- try {
- socket = new ConfiguredGuacamoleSocket(
- new InetGuacamoleSocket(GUACD_HOSTNAME, GUACD_PORT),
- config, info
- );
- }
-
- // Log any errors during connection
- catch (GuacamoleException e) {
- logger.error("Unable to connect to guacd.", e);
- throw e;
- }
-
- // Return corresponding tunnel
- return new SimpleGuacamoleTunnel(socket);
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/HTTPTunnelRequest.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/HTTPTunnelRequest.java
deleted file mode 100644
index 2b88af93..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/HTTPTunnelRequest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.http;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.guacamole.tunnel.TunnelRequest;
-
-/**
- * HTTP-specific implementation of TunnelRequest.
- *
- * @author Michael Jumper
- */
-public class HTTPTunnelRequest extends TunnelRequest {
-
- /**
- * A copy of the parameters obtained from the HttpServletRequest used to
- * construct the HTTPTunnelRequest.
- */
- private final Map> parameterMap =
- new HashMap>();
-
- /**
- * Creates a HTTPTunnelRequest which copies and exposes the parameters
- * from the given HttpServletRequest.
- *
- * @param request
- * The HttpServletRequest to copy parameter values from.
- */
- @SuppressWarnings("unchecked") // getParameterMap() is defined as returning Map
- public HTTPTunnelRequest(HttpServletRequest request) {
-
- // For each parameter
- for (Map.Entry mapEntry : ((Map)
- request.getParameterMap()).entrySet()) {
-
- // Get parameter name and corresponding values
- String parameterName = mapEntry.getKey();
- List parameterValues = Arrays.asList(mapEntry.getValue());
-
- // Store copy of all values in our own map
- parameterMap.put(
- parameterName,
- new ArrayList(parameterValues)
- );
-
- }
-
- }
-
- @Override
- public String getParameter(String name) {
- List values = getParameterValues(name);
-
- // Return the first value from the list if available
- if (values != null && !values.isEmpty())
- return values.get(0);
-
- return null;
- }
-
- @Override
- public List getParameterValues(String name) {
- return parameterMap.get(name);
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/RestrictedGuacamoleHTTPTunnelServlet.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/RestrictedGuacamoleHTTPTunnelServlet.java
deleted file mode 100644
index 50f6df65..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/RestrictedGuacamoleHTTPTunnelServlet.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.http;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.servlet.GuacamoleHTTPTunnelServlet;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Connects users to a tunnel associated with the authorized connection
- * having the given ID.
- *
- * @author Michael Jumper
- */
-@Singleton
-public class RestrictedGuacamoleHTTPTunnelServlet extends GuacamoleHTTPTunnelServlet {
-
- /**
- * Service for handling tunnel requests.
- */
- @Inject
- private TunnelRequestService tunnelRequestService;
-
- /**
- * Logger for this class.
- */
- private static final Logger logger = LoggerFactory.getLogger(RestrictedGuacamoleHTTPTunnelServlet.class);
-
- @Override
- protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {
-
- // Attempt to create HTTP tunnel
- GuacamoleTunnel tunnel = tunnelRequestService.createTunnel(new HTTPTunnelRequest(request));
-
- // If successful, warn of lack of WebSocket
- logger.info("Using HTTP tunnel (not WebSocket). Performance may be sub-optimal.");
-
- return tunnel;
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/package-info.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/package-info.java
deleted file mode 100644
index a7cb73ef..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/http/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Classes which leverage Guacamole's built-in HTTP tunnel implementation.
- */
-package org.apache.guacamole.tunnel.http;
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/package-info.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/package-info.java
deleted file mode 100644
index 383b4b6b..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Classes which are common to all tunnel implementations.
- */
-package org.apache.guacamole.tunnel;
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/RestrictedGuacamoleWebSocketTunnelEndpoint.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/RestrictedGuacamoleWebSocketTunnelEndpoint.java
deleted file mode 100644
index fd2c022c..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/RestrictedGuacamoleWebSocketTunnelEndpoint.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket;
-
-import com.google.inject.Provider;
-import java.util.Map;
-import javax.websocket.EndpointConfig;
-import javax.websocket.HandshakeResponse;
-import javax.websocket.Session;
-import javax.websocket.server.HandshakeRequest;
-import javax.websocket.server.ServerEndpointConfig;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.tunnel.TunnelRequest;
-import org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-
-/**
- * Tunnel implementation which uses WebSocket as a tunnel backend, rather than
- * HTTP, properly parsing connection IDs included in the connection request.
- */
-public class RestrictedGuacamoleWebSocketTunnelEndpoint extends GuacamoleWebSocketTunnelEndpoint {
-
- /**
- * Unique string which shall be used to store the TunnelRequest
- * associated with a WebSocket connection.
- */
- private static final String TUNNEL_REQUEST_PROPERTY = "WS_GUAC_TUNNEL_REQUEST";
-
- /**
- * Unique string which shall be used to store the TunnelRequestService to
- * be used for processing TunnelRequests.
- */
- private static final String TUNNEL_REQUEST_SERVICE_PROPERTY = "WS_GUAC_TUNNEL_REQUEST_SERVICE";
-
- /**
- * Configurator implementation which stores the requested GuacamoleTunnel
- * within the user properties. The GuacamoleTunnel will be later retrieved
- * during the connection process.
- */
- public static class Configurator extends ServerEndpointConfig.Configurator {
-
- /**
- * Provider which provides instances of a service for handling
- * tunnel requests.
- */
- private final Provider tunnelRequestServiceProvider;
-
- /**
- * Creates a new Configurator which uses the given tunnel request
- * service provider to retrieve the necessary service to handle new
- * connections requests.
- *
- * @param tunnelRequestServiceProvider
- * The tunnel request service provider to use for all new
- * connections.
- */
- public Configurator(Provider tunnelRequestServiceProvider) {
- this.tunnelRequestServiceProvider = tunnelRequestServiceProvider;
- }
-
- @Override
- public void modifyHandshake(ServerEndpointConfig config,
- HandshakeRequest request, HandshakeResponse response) {
-
- super.modifyHandshake(config, request, response);
-
- // Store tunnel request and tunnel request service for retrieval
- // upon WebSocket open
- Map userProperties = config.getUserProperties();
- userProperties.clear();
- userProperties.put(TUNNEL_REQUEST_PROPERTY, new WebSocketTunnelRequest(request));
- userProperties.put(TUNNEL_REQUEST_SERVICE_PROPERTY, tunnelRequestServiceProvider.get());
-
- }
-
- }
-
- @Override
- protected GuacamoleTunnel createTunnel(Session session,
- EndpointConfig config) throws GuacamoleException {
-
- Map userProperties = config.getUserProperties();
-
- // Get original tunnel request
- TunnelRequest tunnelRequest = (TunnelRequest) userProperties.get(TUNNEL_REQUEST_PROPERTY);
- if (tunnelRequest == null)
- return null;
-
- // Get tunnel request service
- TunnelRequestService tunnelRequestService = (TunnelRequestService) userProperties.get(TUNNEL_REQUEST_SERVICE_PROPERTY);
- if (tunnelRequestService == null)
- return null;
-
- // Create and return tunnel
- return tunnelRequestService.createTunnel(tunnelRequest);
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/WebSocketTunnelModule.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/WebSocketTunnelModule.java
deleted file mode 100644
index b4ece2d0..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/WebSocketTunnelModule.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket;
-
-import com.google.inject.Provider;
-import com.google.inject.servlet.ServletModule;
-import java.util.Arrays;
-import javax.websocket.DeploymentException;
-import javax.websocket.server.ServerContainer;
-import javax.websocket.server.ServerEndpointConfig;
-import org.apache.guacamole.tunnel.TunnelLoader;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Loads the JSR-356 WebSocket tunnel implementation.
- *
- * @author Michael Jumper
- */
-public class WebSocketTunnelModule extends ServletModule implements TunnelLoader {
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(WebSocketTunnelModule.class);
-
- @Override
- public boolean isSupported() {
-
- try {
-
- // Attempt to find WebSocket servlet
- Class.forName("javax.websocket.Endpoint");
-
- // Support found
- return true;
-
- }
-
- // If no such servlet class, this particular WebSocket support
- // is not present
- catch (ClassNotFoundException e) {}
- catch (NoClassDefFoundError e) {}
-
- // Support not found
- return false;
-
- }
-
- @Override
- public void configureServlets() {
-
- logger.info("Loading JSR-356 WebSocket support...");
-
- // Get container
- ServerContainer container = (ServerContainer) getServletContext().getAttribute("javax.websocket.server.ServerContainer");
- if (container == null) {
- logger.warn("ServerContainer attribute required by JSR-356 is missing. Cannot load JSR-356 WebSocket support.");
- return;
- }
-
- Provider tunnelRequestServiceProvider = getProvider(TunnelRequestService.class);
-
- // Build configuration for WebSocket tunnel
- ServerEndpointConfig config =
- ServerEndpointConfig.Builder.create(RestrictedGuacamoleWebSocketTunnelEndpoint.class, "/websocket-tunnel")
- .configurator(new RestrictedGuacamoleWebSocketTunnelEndpoint.Configurator(tunnelRequestServiceProvider))
- .subprotocols(Arrays.asList(new String[]{"guacamole"}))
- .build();
-
- try {
-
- // Add configuration to container
- container.addEndpoint(config);
-
- }
- catch (DeploymentException e) {
- logger.error("Unable to deploy WebSocket tunnel.", e);
- }
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/WebSocketTunnelRequest.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/WebSocketTunnelRequest.java
deleted file mode 100644
index acebe057..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/WebSocketTunnelRequest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket;
-
-import java.util.List;
-import java.util.Map;
-import javax.websocket.server.HandshakeRequest;
-import org.apache.guacamole.tunnel.TunnelRequest;
-
-/**
- * WebSocket-specific implementation of TunnelRequest.
- *
- * @author Michael Jumper
- */
-public class WebSocketTunnelRequest extends TunnelRequest {
-
- /**
- * All parameters passed via HTTP to the WebSocket handshake.
- */
- private final Map> handshakeParameters;
-
- /**
- * Creates a TunnelRequest implementation which delegates parameter and
- * session retrieval to the given HandshakeRequest.
- *
- * @param request The HandshakeRequest to wrap.
- */
- public WebSocketTunnelRequest(HandshakeRequest request) {
- this.handshakeParameters = request.getParameterMap();
- }
-
- @Override
- public String getParameter(String name) {
-
- // Pull list of values, if present
- List values = getParameterValues(name);
- if (values == null || values.isEmpty())
- return null;
-
- // Return first parameter value arbitrarily
- return values.get(0);
-
- }
-
- @Override
- public List getParameterValues(String name) {
- return handshakeParameters.get(name);
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/GuacamoleWebSocketTunnelServlet.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/GuacamoleWebSocketTunnelServlet.java
deleted file mode 100644
index 933ff654..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/GuacamoleWebSocketTunnelServlet.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty8;
-
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.io.GuacamoleReader;
-import org.apache.guacamole.io.GuacamoleWriter;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocket.Connection;
-import org.eclipse.jetty.websocket.WebSocketServlet;
-import org.apache.guacamole.GuacamoleClientException;
-import org.apache.guacamole.GuacamoleConnectionClosedException;
-import org.apache.guacamole.protocol.GuacamoleInstruction;
-import org.apache.guacamole.tunnel.http.HTTPTunnelRequest;
-import org.apache.guacamole.tunnel.TunnelRequest;
-import org.apache.guacamole.protocol.GuacamoleStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A WebSocketServlet partial re-implementation of GuacamoleTunnelServlet.
- *
- * @author Michael Jumper
- */
-public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
-
- /**
- * Logger for this class.
- */
- private static final Logger logger = LoggerFactory.getLogger(GuacamoleWebSocketTunnelServlet.class);
-
- /**
- * The default, minimum buffer size for instructions.
- */
- private static final int BUFFER_SIZE = 8192;
-
- /**
- * Sends the given status on the given WebSocket connection and closes the
- * connection.
- *
- * @param connection The WebSocket connection to close.
- * @param guac_status The status to send.
- */
- public static void closeConnection(Connection connection,
- GuacamoleStatus guac_status) {
-
- connection.close(guac_status.getWebSocketCode(),
- Integer.toString(guac_status.getGuacamoleStatusCode()));
-
- }
-
- @Override
- public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
-
- final TunnelRequest tunnelRequest = new HTTPTunnelRequest(request);
-
- // Return new WebSocket which communicates through tunnel
- return new WebSocket.OnTextMessage() {
-
- /**
- * The GuacamoleTunnel associated with the connected WebSocket. If
- * the WebSocket has not yet been connected, this will be null.
- */
- private GuacamoleTunnel tunnel = null;
-
- @Override
- public void onMessage(String string) {
-
- // Ignore inbound messages if there is no associated tunnel
- if (tunnel == null)
- return;
-
- GuacamoleWriter writer = tunnel.acquireWriter();
-
- // Write message received
- try {
- writer.write(string.toCharArray());
- }
- catch (GuacamoleConnectionClosedException e) {
- logger.debug("Connection to guacd closed.", e);
- }
- catch (GuacamoleException e) {
- logger.debug("WebSocket tunnel write failed.", e);
- }
-
- tunnel.releaseWriter();
-
- }
-
- @Override
- public void onOpen(final Connection connection) {
-
- try {
- tunnel = doConnect(tunnelRequest);
- }
- catch (GuacamoleException e) {
- logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
- logger.debug("Error connecting WebSocket tunnel.", e);
- closeConnection(connection, e.getStatus());
- return;
- }
-
- // Do not start connection if tunnel does not exist
- if (tunnel == null) {
- closeConnection(connection, GuacamoleStatus.RESOURCE_NOT_FOUND);
- return;
- }
-
- Thread readThread = new Thread() {
-
- @Override
- public void run() {
-
- StringBuilder buffer = new StringBuilder(BUFFER_SIZE);
- GuacamoleReader reader = tunnel.acquireReader();
- char[] readMessage;
-
- try {
-
- // Send tunnel UUID
- connection.sendMessage(new GuacamoleInstruction(
- GuacamoleTunnel.INTERNAL_DATA_OPCODE,
- tunnel.getUUID().toString()
- ).toString());
-
- try {
-
- // Attempt to read
- while ((readMessage = reader.read()) != null) {
-
- // Buffer message
- buffer.append(readMessage);
-
- // Flush if we expect to wait or buffer is getting full
- if (!reader.available() || buffer.length() >= BUFFER_SIZE) {
- connection.sendMessage(buffer.toString());
- buffer.setLength(0);
- }
-
- }
-
- // No more data
- closeConnection(connection, GuacamoleStatus.SUCCESS);
-
- }
-
- // Catch any thrown guacamole exception and attempt
- // to pass within the WebSocket connection, logging
- // each error appropriately.
- catch (GuacamoleClientException e) {
- logger.info("WebSocket connection terminated: {}", e.getMessage());
- logger.debug("WebSocket connection terminated due to client error.", e);
- closeConnection(connection, e.getStatus());
- }
- catch (GuacamoleConnectionClosedException e) {
- logger.debug("Connection to guacd closed.", e);
- closeConnection(connection, GuacamoleStatus.SUCCESS);
- }
- catch (GuacamoleException e) {
- logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
- logger.debug("Internal error during connection to guacd.", e);
- closeConnection(connection, e.getStatus());
- }
-
- }
- catch (IOException e) {
- logger.debug("WebSocket tunnel read failed due to I/O error.", e);
- }
-
- }
-
- };
-
- readThread.start();
-
- }
-
- @Override
- public void onClose(int i, String string) {
- try {
- if (tunnel != null)
- tunnel.close();
- }
- catch (GuacamoleException e) {
- logger.debug("Unable to close connection to guacd.", e);
- }
- }
-
- };
-
- }
-
- /**
- * Called whenever the JavaScript Guacamole client makes a connection
- * request. It it up to the implementor of this function to define what
- * conditions must be met for a tunnel to be configured and returned as a
- * result of this connection request (whether some sort of credentials must
- * be specified, for example).
- *
- * @param request
- * The TunnelRequest associated with the connection request received.
- * Any parameters specified along with the connection request can be
- * read from this object.
- *
- * @return
- * A newly constructed GuacamoleTunnel if successful, null otherwise.
- *
- * @throws GuacamoleException
- * If an error occurs while constructing the GuacamoleTunnel, or if the
- * conditions required for connection are not met.
- */
- protected abstract GuacamoleTunnel doConnect(TunnelRequest request)
- throws GuacamoleException;
-
-}
-
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/RestrictedGuacamoleWebSocketTunnelServlet.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/RestrictedGuacamoleWebSocketTunnelServlet.java
deleted file mode 100644
index 267fa136..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/RestrictedGuacamoleWebSocketTunnelServlet.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty8;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.tunnel.TunnelRequest;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-
-/**
- * Tunnel servlet implementation which uses WebSocket as a tunnel backend,
- * rather than HTTP, properly parsing connection IDs included in the connection
- * request.
- */
-@Singleton
-public class RestrictedGuacamoleWebSocketTunnelServlet extends GuacamoleWebSocketTunnelServlet {
-
- /**
- * Service for handling tunnel requests.
- */
- @Inject
- private TunnelRequestService tunnelRequestService;
-
- @Override
- protected GuacamoleTunnel doConnect(TunnelRequest request)
- throws GuacamoleException {
- return tunnelRequestService.createTunnel(request);
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/WebSocketTunnelModule.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/WebSocketTunnelModule.java
deleted file mode 100644
index 4cbc2b09..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/WebSocketTunnelModule.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty8;
-
-import com.google.inject.servlet.ServletModule;
-import org.apache.guacamole.tunnel.TunnelLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Loads the Jetty 8 WebSocket tunnel implementation.
- *
- * @author Michael Jumper
- */
-public class WebSocketTunnelModule extends ServletModule implements TunnelLoader {
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(WebSocketTunnelModule.class);
-
- @Override
- public boolean isSupported() {
-
- try {
-
- // Attempt to find WebSocket servlet
- Class.forName("org.apache.guacamole.tunnel.websocket.jetty8.RestrictedGuacamoleWebSocketTunnelServlet");
-
- // Support found
- return true;
-
- }
-
- // If no such servlet class, this particular WebSocket support
- // is not present
- catch (ClassNotFoundException e) {}
- catch (NoClassDefFoundError e) {}
-
- // Support not found
- return false;
-
- }
-
- @Override
- public void configureServlets() {
-
- logger.info("Loading Jetty 8 WebSocket support...");
- serve("/websocket-tunnel").with(RestrictedGuacamoleWebSocketTunnelServlet.class);
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/package-info.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/package-info.java
deleted file mode 100644
index 9aecac2b..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty8/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Jetty 8 WebSocket tunnel implementation. The classes here require Jetty 8.
- */
-package org.apache.guacamole.tunnel.websocket.jetty8;
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/GuacamoleWebSocketTunnelListener.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/GuacamoleWebSocketTunnelListener.java
deleted file mode 100644
index 89105fc9..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/GuacamoleWebSocketTunnelListener.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty9;
-
-import java.io.IOException;
-import org.eclipse.jetty.websocket.api.CloseStatus;
-import org.eclipse.jetty.websocket.api.RemoteEndpoint;
-import org.eclipse.jetty.websocket.api.Session;
-import org.eclipse.jetty.websocket.api.WebSocketListener;
-import org.apache.guacamole.GuacamoleClientException;
-import org.apache.guacamole.GuacamoleConnectionClosedException;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.io.GuacamoleReader;
-import org.apache.guacamole.io.GuacamoleWriter;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.protocol.GuacamoleInstruction;
-import org.apache.guacamole.protocol.GuacamoleStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * WebSocket listener implementation which provides a Guacamole tunnel
- *
- * @author Michael Jumper
- */
-public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListener {
-
- /**
- * The default, minimum buffer size for instructions.
- */
- private static final int BUFFER_SIZE = 8192;
-
- /**
- * Logger for this class.
- */
- private static final Logger logger = LoggerFactory.getLogger(RestrictedGuacamoleWebSocketTunnelServlet.class);
-
- /**
- * The underlying GuacamoleTunnel. WebSocket reads/writes will be handled
- * as reads/writes to this tunnel.
- */
- private GuacamoleTunnel tunnel;
-
- /**
- * Sends the given status on the given WebSocket connection and closes the
- * connection.
- *
- * @param session The outbound WebSocket connection to close.
- * @param guac_status The status to send.
- */
- private void closeConnection(Session session, GuacamoleStatus guac_status) {
-
- try {
- int code = guac_status.getWebSocketCode();
- String message = Integer.toString(guac_status.getGuacamoleStatusCode());
- session.close(new CloseStatus(code, message));
- }
- catch (IOException e) {
- logger.debug("Unable to close WebSocket connection.", e);
- }
-
- }
-
- /**
- * Returns a new tunnel for the given session. How this tunnel is created
- * or retrieved is implementation-dependent.
- *
- * @param session The session associated with the active WebSocket
- * connection.
- * @return A connected tunnel, or null if no such tunnel exists.
- * @throws GuacamoleException If an error occurs while retrieving the
- * tunnel, or if access to the tunnel is denied.
- */
- protected abstract GuacamoleTunnel createTunnel(Session session)
- throws GuacamoleException;
-
- @Override
- public void onWebSocketConnect(final Session session) {
-
- try {
-
- // Get tunnel
- tunnel = createTunnel(session);
- if (tunnel == null) {
- closeConnection(session, GuacamoleStatus.RESOURCE_NOT_FOUND);
- return;
- }
-
- }
- catch (GuacamoleException e) {
- logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
- logger.debug("Error connecting WebSocket tunnel.", e);
- closeConnection(session, e.getStatus());
- return;
- }
-
- // Prepare read transfer thread
- Thread readThread = new Thread() {
-
- /**
- * Remote (client) side of this connection
- */
- private final RemoteEndpoint remote = session.getRemote();
-
- @Override
- public void run() {
-
- StringBuilder buffer = new StringBuilder(BUFFER_SIZE);
- GuacamoleReader reader = tunnel.acquireReader();
- char[] readMessage;
-
- try {
-
- // Send tunnel UUID
- remote.sendString(new GuacamoleInstruction(
- GuacamoleTunnel.INTERNAL_DATA_OPCODE,
- tunnel.getUUID().toString()
- ).toString());
-
- try {
-
- // Attempt to read
- while ((readMessage = reader.read()) != null) {
-
- // Buffer message
- buffer.append(readMessage);
-
- // Flush if we expect to wait or buffer is getting full
- if (!reader.available() || buffer.length() >= BUFFER_SIZE) {
- remote.sendString(buffer.toString());
- buffer.setLength(0);
- }
-
- }
-
- // No more data
- closeConnection(session, GuacamoleStatus.SUCCESS);
-
- }
-
- // Catch any thrown guacamole exception and attempt
- // to pass within the WebSocket connection, logging
- // each error appropriately.
- catch (GuacamoleClientException e) {
- logger.info("WebSocket connection terminated: {}", e.getMessage());
- logger.debug("WebSocket connection terminated due to client error.", e);
- closeConnection(session, e.getStatus());
- }
- catch (GuacamoleConnectionClosedException e) {
- logger.debug("Connection to guacd closed.", e);
- closeConnection(session, GuacamoleStatus.SUCCESS);
- }
- catch (GuacamoleException e) {
- logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
- logger.debug("Internal error during connection to guacd.", e);
- closeConnection(session, e.getStatus());
- }
-
- }
- catch (IOException e) {
- logger.debug("I/O error prevents further reads.", e);
- }
-
- }
-
- };
-
- readThread.start();
-
- }
-
- @Override
- public void onWebSocketText(String message) {
-
- // Ignore inbound messages if there is no associated tunnel
- if (tunnel == null)
- return;
-
- GuacamoleWriter writer = tunnel.acquireWriter();
-
- try {
- // Write received message
- writer.write(message.toCharArray());
- }
- catch (GuacamoleConnectionClosedException e) {
- logger.debug("Connection to guacd closed.", e);
- }
- catch (GuacamoleException e) {
- logger.debug("WebSocket tunnel write failed.", e);
- }
-
- tunnel.releaseWriter();
-
- }
-
- @Override
- public void onWebSocketBinary(byte[] payload, int offset, int length) {
- throw new UnsupportedOperationException("Binary WebSocket messages are not supported.");
- }
-
- @Override
- public void onWebSocketError(Throwable t) {
-
- logger.debug("WebSocket tunnel closing due to error.", t);
-
- try {
- if (tunnel != null)
- tunnel.close();
- }
- catch (GuacamoleException e) {
- logger.debug("Unable to close connection to guacd.", e);
- }
-
- }
-
-
- @Override
- public void onWebSocketClose(int statusCode, String reason) {
-
- try {
- if (tunnel != null)
- tunnel.close();
- }
- catch (GuacamoleException e) {
- logger.debug("Unable to close connection to guacd.", e);
- }
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketCreator.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketCreator.java
deleted file mode 100644
index 5d3543b1..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketCreator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty9;
-
-import org.eclipse.jetty.websocket.api.UpgradeRequest;
-import org.eclipse.jetty.websocket.api.UpgradeResponse;
-import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-
-/**
- * WebSocketCreator which selects the appropriate WebSocketListener
- * implementation if the "guacamole" subprotocol is in use.
- *
- * @author Michael Jumper
- */
-public class RestrictedGuacamoleWebSocketCreator implements WebSocketCreator {
-
- /**
- * Service for handling tunnel requests.
- */
- private final TunnelRequestService tunnelRequestService;
-
- /**
- * Creates a new WebSocketCreator which uses the given TunnelRequestService
- * to create new GuacamoleTunnels for inbound requests.
- *
- * @param tunnelRequestService The service to use for inbound tunnel
- * requests.
- */
- public RestrictedGuacamoleWebSocketCreator(TunnelRequestService tunnelRequestService) {
- this.tunnelRequestService = tunnelRequestService;
- }
-
- @Override
- public Object createWebSocket(UpgradeRequest request, UpgradeResponse response) {
-
- // Validate and use "guacamole" subprotocol
- for (String subprotocol : request.getSubProtocols()) {
-
- if ("guacamole".equals(subprotocol)) {
- response.setAcceptedSubProtocol(subprotocol);
- return new RestrictedGuacamoleWebSocketTunnelListener(tunnelRequestService);
- }
-
- }
-
- // Invalid protocol
- return null;
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketTunnelListener.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketTunnelListener.java
deleted file mode 100644
index 338413db..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketTunnelListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty9;
-
-import org.eclipse.jetty.websocket.api.Session;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-
-/**
- * WebSocket listener implementation which properly parses connection IDs
- * included in the connection request.
- *
- * @author Michael Jumper
- */
-public class RestrictedGuacamoleWebSocketTunnelListener extends GuacamoleWebSocketTunnelListener {
-
- /**
- * Service for handling tunnel requests.
- */
- private final TunnelRequestService tunnelRequestService;
-
- /**
- * Creates a new WebSocketListener which uses the given TunnelRequestService
- * to create new GuacamoleTunnels for inbound requests.
- *
- * @param tunnelRequestService The service to use for inbound tunnel
- * requests.
- */
- public RestrictedGuacamoleWebSocketTunnelListener(TunnelRequestService tunnelRequestService) {
- this.tunnelRequestService = tunnelRequestService;
- }
-
- @Override
- protected GuacamoleTunnel createTunnel(Session session) throws GuacamoleException {
- return tunnelRequestService.createTunnel(new WebSocketTunnelRequest(session.getUpgradeRequest()));
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketTunnelServlet.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketTunnelServlet.java
deleted file mode 100644
index 9829ac3a..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/RestrictedGuacamoleWebSocketTunnelServlet.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty9;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
-import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-
-/**
- * A WebSocketServlet partial re-implementation of GuacamoleTunnelServlet.
- *
- * @author Michael Jumper
- */
-@Singleton
-public class RestrictedGuacamoleWebSocketTunnelServlet extends WebSocketServlet {
-
- /**
- * Service for handling tunnel requests.
- */
- @Inject
- private TunnelRequestService tunnelRequestService;
-
- @Override
- public void configure(WebSocketServletFactory factory) {
-
- // Register WebSocket implementation
- factory.setCreator(new RestrictedGuacamoleWebSocketCreator(tunnelRequestService));
-
- }
-
-}
-
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/WebSocketTunnelModule.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/WebSocketTunnelModule.java
deleted file mode 100644
index c98d1cb7..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/WebSocketTunnelModule.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty9;
-
-import com.google.inject.servlet.ServletModule;
-import org.apache.guacamole.tunnel.TunnelLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Loads the Jetty 9 WebSocket tunnel implementation.
- *
- * @author Michael Jumper
- */
-public class WebSocketTunnelModule extends ServletModule implements TunnelLoader {
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(WebSocketTunnelModule.class);
-
- @Override
- public boolean isSupported() {
-
- try {
-
- // Attempt to find WebSocket servlet
- Class.forName("org.apache.guacamole.tunnel.websocket.jetty9.RestrictedGuacamoleWebSocketTunnelServlet");
-
- // Support found
- return true;
-
- }
-
- // If no such servlet class, this particular WebSocket support
- // is not present
- catch (ClassNotFoundException e) {}
- catch (NoClassDefFoundError e) {}
-
- // Support not found
- return false;
-
- }
-
- @Override
- public void configureServlets() {
-
- logger.info("Loading Jetty 9 WebSocket support...");
- serve("/websocket-tunnel").with(RestrictedGuacamoleWebSocketTunnelServlet.class);
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/WebSocketTunnelRequest.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/WebSocketTunnelRequest.java
deleted file mode 100644
index adbc8d01..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/WebSocketTunnelRequest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.jetty9;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.jetty.websocket.api.UpgradeRequest;
-import org.apache.guacamole.tunnel.TunnelRequest;
-
-/**
- * Jetty 9 WebSocket-specific implementation of TunnelRequest.
- *
- * @author Michael Jumper
- */
-public class WebSocketTunnelRequest extends TunnelRequest {
-
- /**
- * All parameters passed via HTTP to the WebSocket handshake.
- */
- private final Map handshakeParameters;
-
- /**
- * Creates a TunnelRequest implementation which delegates parameter and
- * session retrieval to the given UpgradeRequest.
- *
- * @param request The UpgradeRequest to wrap.
- */
- public WebSocketTunnelRequest(UpgradeRequest request) {
- this.handshakeParameters = request.getParameterMap();
- }
-
- @Override
- public String getParameter(String name) {
-
- // Pull list of values, if present
- List values = getParameterValues(name);
- if (values == null || values.isEmpty())
- return null;
-
- // Return first parameter value arbitrarily
- return values.get(0);
-
- }
-
- @Override
- public List getParameterValues(String name) {
-
- String[] values = handshakeParameters.get(name);
- if (values == null)
- return null;
-
- return Arrays.asList(values);
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/package-info.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/package-info.java
deleted file mode 100644
index c2a5803f..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/jetty9/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Jetty 9 WebSocket tunnel implementation. The classes here require at least
- * Jetty 9, prior to Jetty 9.1 (when support for JSR 356 was implemented).
- */
-package org.apache.guacamole.tunnel.websocket.jetty9;
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/package-info.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/package-info.java
deleted file mode 100644
index 1d083edd..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Standard WebSocket tunnel implementation. The classes here require a recent
- * servlet container that supports JSR 356.
- */
-package org.apache.guacamole.tunnel.websocket;
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/GuacamoleWebSocketTunnelServlet.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/GuacamoleWebSocketTunnelServlet.java
deleted file mode 100644
index 1b9098f9..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/GuacamoleWebSocketTunnelServlet.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.tomcat;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.io.GuacamoleReader;
-import org.apache.guacamole.io.GuacamoleWriter;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.catalina.websocket.StreamInbound;
-import org.apache.catalina.websocket.WebSocketServlet;
-import org.apache.catalina.websocket.WsOutbound;
-import org.apache.guacamole.GuacamoleClientException;
-import org.apache.guacamole.GuacamoleConnectionClosedException;
-import org.apache.guacamole.protocol.GuacamoleInstruction;
-import org.apache.guacamole.tunnel.http.HTTPTunnelRequest;
-import org.apache.guacamole.tunnel.TunnelRequest;
-import org.apache.guacamole.protocol.GuacamoleStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A WebSocketServlet partial re-implementation of GuacamoleTunnelServlet.
- *
- * @author Michael Jumper
- */
-public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
-
- /**
- * The default, minimum buffer size for instructions.
- */
- private static final int BUFFER_SIZE = 8192;
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(GuacamoleWebSocketTunnelServlet.class);
-
- /**
- * Sends the given status on the given WebSocket connection and closes the
- * connection.
- *
- * @param outbound The outbound WebSocket connection to close.
- * @param guac_status The status to send.
- */
- public void closeConnection(WsOutbound outbound, GuacamoleStatus guac_status) {
-
- try {
- byte[] message = Integer.toString(guac_status.getGuacamoleStatusCode()).getBytes("UTF-8");
- outbound.close(guac_status.getWebSocketCode(), ByteBuffer.wrap(message));
- }
- catch (IOException e) {
- logger.debug("Unable to close WebSocket tunnel.", e);
- }
-
- }
-
- @Override
- protected String selectSubProtocol(List subProtocols) {
-
- // Search for expected protocol
- for (String protocol : subProtocols)
- if ("guacamole".equals(protocol))
- return "guacamole";
-
- // Otherwise, fail
- return null;
-
- }
-
- @Override
- public StreamInbound createWebSocketInbound(String protocol,
- HttpServletRequest request) {
-
- final TunnelRequest tunnelRequest = new HTTPTunnelRequest(request);
-
- // Return new WebSocket which communicates through tunnel
- return new StreamInbound() {
-
- /**
- * The GuacamoleTunnel associated with the connected WebSocket. If
- * the WebSocket has not yet been connected, this will be null.
- */
- private GuacamoleTunnel tunnel = null;
-
- @Override
- protected void onTextData(Reader reader) throws IOException {
-
- // Ignore inbound messages if there is no associated tunnel
- if (tunnel == null)
- return;
-
- GuacamoleWriter writer = tunnel.acquireWriter();
-
- // Write all available data
- try {
-
- char[] buffer = new char[BUFFER_SIZE];
-
- int num_read;
- while ((num_read = reader.read(buffer)) > 0)
- writer.write(buffer, 0, num_read);
-
- }
- catch (GuacamoleConnectionClosedException e) {
- logger.debug("Connection to guacd closed.", e);
- }
- catch (GuacamoleException e) {
- logger.debug("WebSocket tunnel write failed.", e);
- }
-
- tunnel.releaseWriter();
- }
-
- @Override
- public void onOpen(final WsOutbound outbound) {
-
- try {
- tunnel = doConnect(tunnelRequest);
- }
- catch (GuacamoleException e) {
- logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
- logger.debug("Error connecting WebSocket tunnel.", e);
- closeConnection(outbound, e.getStatus());
- return;
- }
-
- // Do not start connection if tunnel does not exist
- if (tunnel == null) {
- closeConnection(outbound, GuacamoleStatus.RESOURCE_NOT_FOUND);
- return;
- }
-
- Thread readThread = new Thread() {
-
- @Override
- public void run() {
-
- StringBuilder buffer = new StringBuilder(BUFFER_SIZE);
- GuacamoleReader reader = tunnel.acquireReader();
- char[] readMessage;
-
- try {
-
- // Send tunnel UUID
- outbound.writeTextMessage(CharBuffer.wrap(new GuacamoleInstruction(
- GuacamoleTunnel.INTERNAL_DATA_OPCODE,
- tunnel.getUUID().toString()
- ).toString()));
-
- try {
-
- // Attempt to read
- while ((readMessage = reader.read()) != null) {
-
- // Buffer message
- buffer.append(readMessage);
-
- // Flush if we expect to wait or buffer is getting full
- if (!reader.available() || buffer.length() >= BUFFER_SIZE) {
- outbound.writeTextMessage(CharBuffer.wrap(buffer));
- buffer.setLength(0);
- }
-
- }
-
- // No more data
- closeConnection(outbound, GuacamoleStatus.SUCCESS);
-
- }
-
- // Catch any thrown guacamole exception and attempt
- // to pass within the WebSocket connection, logging
- // each error appropriately.
- catch (GuacamoleClientException e) {
- logger.info("WebSocket connection terminated: {}", e.getMessage());
- logger.debug("WebSocket connection terminated due to client error.", e);
- closeConnection(outbound, e.getStatus());
- }
- catch (GuacamoleConnectionClosedException e) {
- logger.debug("Connection to guacd closed.", e);
- closeConnection(outbound, GuacamoleStatus.SUCCESS);
- }
- catch (GuacamoleException e) {
- logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
- logger.debug("Internal error during connection to guacd.", e);
- closeConnection(outbound, e.getStatus());
- }
-
- }
- catch (IOException e) {
- logger.debug("I/O error prevents further reads.", e);
- }
-
- }
-
- };
-
- readThread.start();
-
- }
-
- @Override
- public void onClose(int i) {
- try {
- if (tunnel != null)
- tunnel.close();
- }
- catch (GuacamoleException e) {
- logger.debug("Unable to close connection to guacd.", e);
- }
- }
-
- @Override
- protected void onBinaryData(InputStream in) throws IOException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- };
-
- }
-
- /**
- * Called whenever the JavaScript Guacamole client makes a connection
- * request. It it up to the implementor of this function to define what
- * conditions must be met for a tunnel to be configured and returned as a
- * result of this connection request (whether some sort of credentials must
- * be specified, for example).
- *
- * @param request
- * The TunnelRequest associated with the connection request received.
- * Any parameters specified along with the connection request can be
- * read from this object.
- *
- * @return
- * A newly constructed GuacamoleTunnel if successful, null otherwise.
- *
- * @throws GuacamoleException
- * If an error occurs while constructing the GuacamoleTunnel, or if the
- * conditions required for connection are not met.
- */
- protected abstract GuacamoleTunnel doConnect(TunnelRequest request)
- throws GuacamoleException;
-
-}
-
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/RestrictedGuacamoleWebSocketTunnelServlet.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/RestrictedGuacamoleWebSocketTunnelServlet.java
deleted file mode 100644
index df1c008d..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/RestrictedGuacamoleWebSocketTunnelServlet.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This file has been modified from the original, upstream version to facilitate
- * integration with OpenUDS.
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.tomcat;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.apache.guacamole.GuacamoleException;
-import org.apache.guacamole.net.GuacamoleTunnel;
-import org.apache.guacamole.tunnel.TunnelRequest;
-import org.apache.guacamole.tunnel.TunnelRequestService;
-
-/**
- * Tunnel servlet implementation which uses WebSocket as a tunnel backend,
- * rather than HTTP, properly parsing connection IDs included in the connection
- * request.
- */
-@Singleton
-public class RestrictedGuacamoleWebSocketTunnelServlet extends GuacamoleWebSocketTunnelServlet {
-
- /**
- * Service for handling tunnel requests.
- */
- @Inject
- private TunnelRequestService tunnelRequestService;
-
- @Override
- protected GuacamoleTunnel doConnect(TunnelRequest request)
- throws GuacamoleException {
- return tunnelRequestService.createTunnel(request);
- };
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/WebSocketTunnelModule.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/WebSocketTunnelModule.java
deleted file mode 100644
index 34190761..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/WebSocketTunnelModule.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.guacamole.tunnel.websocket.tomcat;
-
-import com.google.inject.servlet.ServletModule;
-import org.apache.guacamole.tunnel.TunnelLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Loads the Jetty 9 WebSocket tunnel implementation.
- *
- * @author Michael Jumper
- */
-public class WebSocketTunnelModule extends ServletModule implements TunnelLoader {
-
- /**
- * Logger for this class.
- */
- private final Logger logger = LoggerFactory.getLogger(WebSocketTunnelModule.class);
-
- @Override
- public boolean isSupported() {
-
- try {
-
- // Attempt to find WebSocket servlet
- Class.forName("org.apache.guacamole.tunnel.websocket.tomcat.RestrictedGuacamoleWebSocketTunnelServlet");
-
- // Support found
- return true;
-
- }
-
- // If no such servlet class, this particular WebSocket support
- // is not present
- catch (ClassNotFoundException e) {}
- catch (NoClassDefFoundError e) {}
-
- // Support not found
- return false;
-
- }
-
- @Override
- public void configureServlets() {
-
- logger.info("Loading Tomcat 7 WebSocket support...");
- serve("/websocket-tunnel").with(RestrictedGuacamoleWebSocketTunnelServlet.class);
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/package-info.java b/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/package-info.java
deleted file mode 100644
index 21002a2c..00000000
--- a/guacamole-tunnel/src/main/java/org/apache/guacamole/tunnel/websocket/tomcat/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Tomcat WebSocket tunnel implementation. The classes here require at least
- * Tomcat 7.0, and may change significantly as there is no common WebSocket
- * API for Java yet.
- */
-package org.apache.guacamole.tunnel.websocket.tomcat;
diff --git a/guacamole-tunnel/src/main/java/org/openuds/guacamole/UDSServletContextListener.java b/guacamole-tunnel/src/main/java/org/openuds/guacamole/UDSServletContextListener.java
deleted file mode 100644
index 4d8f5bf7..00000000
--- a/guacamole-tunnel/src/main/java/org/openuds/guacamole/UDSServletContextListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2015 Virtual Cable S.L.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Virtual Cable S.L. nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openuds.guacamole;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.servlet.GuiceServletContextListener;
-import org.apache.guacamole.tunnel.TunnelModule;
-
-/**
- * ServletContextListener implementation which initializes Guice and services
- * specific to OpenUDS.
- */
-public class UDSServletContextListener extends GuiceServletContextListener {
-
- @Override
- protected Injector getInjector() {
-
- // Create an injector with OpenUDS- and Guacamole-specific services
- // properly bound
- return Guice.createInjector(
- new UDSModule(),
- new TunnelModule()
- );
-
- }
-
-}
diff --git a/guacamole-tunnel/src/main/webapp/WEB-INF/tunnel.properties b/guacamole-tunnel/src/main/webapp/WEB-INF/tunnel.properties
deleted file mode 100644
index 25dca267..00000000
--- a/guacamole-tunnel/src/main/webapp/WEB-INF/tunnel.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-# We can specify the uds server here as:
-# uds=http://172.27.0.1:8000
-# Or we can get the server from an external file. The path part of the URL inside the file will be removed,
-# so, if we put "https://example.com/other", the value of uds configuration will be "https://example.com"
-udsfile=/etc/uds.conf
diff --git a/guacamole-tunnel/src/main/webapp/WEB-INF/web.xml b/guacamole-tunnel/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index f213f720..00000000
--- a/guacamole-tunnel/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
- index.xhtml
-
-
-
-
- org.openuds.guacamole.UDSServletContextListener
-
-
-
-
- guiceFilter
- com.google.inject.servlet.GuiceFilter
-
-
- guiceFilter
- /*
-
-
-
diff --git a/guacamole-tunnel/src/main/webapp/index.xhtml b/guacamole-tunnel/src/main/webapp/index.xhtml
deleted file mode 100644
index 8720f3f7..00000000
--- a/guacamole-tunnel/src/main/webapp/index.xhtml
+++ /dev/null
@@ -1,182 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- UDS Guacamole Access
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Guacamole ${project.version}
-
-
Clipboard
-
-
Text copied/cut within Guacamole will appear here. Changes to the text below will affect the remote clipboard.
-
-
-
-
Input method
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Mouse emulation mode
-
-
Determines how the remote mouse behaves with respect to touches.