GUACAMOLE-38: Extend SimpleConnection instead of copying code manually.

Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/a3d85122
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/a3d85122
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/a3d85122

Branch: refs/heads/staging/1.0.0
Commit: a3d851228eb523782ce20965be4391645d86f014
Parents: 2113d1a
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Mar 16 14:54:05 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Fri Jun 1 13:40:50 2018 -0400

----------------------------------------------------------------------
 .../auth/quickconnect/QuickConnection.java      | 89 ++------------------
 1 file changed, 5 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/a3d85122/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java
 
b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java
index a2f3814..2603f17 100644
--- 
a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java
+++ 
b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java
@@ -36,6 +36,7 @@ import org.apache.guacamole.net.auth.AbstractConnection;
 import org.apache.guacamole.net.auth.Connection;
 import org.apache.guacamole.net.auth.ConnectionRecord;
 import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
+import org.apache.guacamole.net.auth.simple.SimpleConnection;
 import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
 import org.apache.guacamole.protocol.GuacamoleClientInformation;
 import org.apache.guacamole.protocol.GuacamoleConfiguration;
@@ -43,12 +44,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration;
 /**
  * A type of Connection specific to this authentication extension.
  */
-public class QuickConnection extends AbstractConnection {
-
-    /**
-     * Backing configuration, containing all sensitive information.
-     */
-    private GuacamoleConfiguration config;
+public class QuickConnection extends SimpleConnection {
 
     /**
      * Number of active connections.
@@ -80,12 +76,7 @@ public class QuickConnection extends AbstractConnection {
     public QuickConnection(String name, String identifier,
             GuacamoleConfiguration config) {
 
-        setName(name);
-
-        setIdentifier(identifier);
-
-        setConfiguration(config);
-        this.config = config;
+        super(name, identifier, config);
 
         this.activeConnections = 0;
 
@@ -101,81 +92,11 @@ public class QuickConnection extends AbstractConnection {
      */
     public QuickConnection(Connection object) {
 
-        setName(object.getName());
-        setIdentifier(object.getIdentifier());
+        
super(object.getName(),object.getIdentifier(),object.getConfiguration());
+
         setParentIdentifier(object.getParentIdentifier());
-        setConfiguration(object.getConfiguration());
-        this.config = object.getConfiguration();
         this.activeConnections = 0;
 
     }
 
-    @Override
-    public int getActiveConnections() {
-        return activeConnections;
-    }
-
-    @Override
-    public Map<String, String> getAttributes() {
-        return Collections.<String, String>emptyMap();
-    }
-
-    @Override
-    public void setAttributes(Map<String, String> attributes) {
-        // Do nothing - there are no attributes
-    }
-
-    @Override
-    public GuacamoleTunnel connect(GuacamoleClientInformation info)
-            throws GuacamoleException {
-
-        // Retrieve proxy configuration from environment
-        Environment environment = new LocalEnvironment();
-        GuacamoleProxyConfiguration proxyConfig = 
environment.getDefaultGuacamoleProxyConfiguration();
-
-        // Get guacd connection parameters
-        String hostname = proxyConfig.getHostname();
-        int port = proxyConfig.getPort();
-
-        GuacamoleSocket socket;
-
-        // Determine socket type based on required encryption method
-        switch (proxyConfig.getEncryptionMethod()) {
-
-            // If guacd requires SSL, use it
-            case SSL:
-                socket = new ConfiguredGuacamoleSocket(
-                    new SSLGuacamoleSocket(hostname, port),
-                    config, info
-                );
-                break;
-
-            // Connect directly via TCP if encryption is not enabled
-            case NONE:
-                socket = new ConfiguredGuacamoleSocket(
-                    new InetGuacamoleSocket(hostname, port),
-                    config, info
-                );
-                break;
-
-            // Abort if encryption method is unknown
-            default:
-                throw new GuacamoleServerException("Unimplemented encryption 
method.");
-
-        }
-
-        return new SimpleGuacamoleTunnel(socket);
-
-    }
-
-    @Override
-    public List<ConnectionRecord> getHistory() throws GuacamoleException {
-        return Collections.<ConnectionRecord>emptyList();
-    }
-
-    @Override
-    public Date getLastActive() {
-        return null;
-    }
-
 }

Reply via email to