mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-38: Extend SimpleConnection instead of copying code manually.
This commit is contained in:
@@ -36,6 +36,7 @@ import org.apache.guacamole.net.auth.AbstractConnection;
|
|||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
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.ConfiguredGuacamoleSocket;
|
||||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
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.
|
* A type of Connection specific to this authentication extension.
|
||||||
*/
|
*/
|
||||||
public class QuickConnection extends AbstractConnection {
|
public class QuickConnection extends SimpleConnection {
|
||||||
|
|
||||||
/**
|
|
||||||
* Backing configuration, containing all sensitive information.
|
|
||||||
*/
|
|
||||||
private GuacamoleConfiguration config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of active connections.
|
* Number of active connections.
|
||||||
@@ -80,12 +76,7 @@ public class QuickConnection extends AbstractConnection {
|
|||||||
public QuickConnection(String name, String identifier,
|
public QuickConnection(String name, String identifier,
|
||||||
GuacamoleConfiguration config) {
|
GuacamoleConfiguration config) {
|
||||||
|
|
||||||
setName(name);
|
super(name, identifier, config);
|
||||||
|
|
||||||
setIdentifier(identifier);
|
|
||||||
|
|
||||||
setConfiguration(config);
|
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
this.activeConnections = 0;
|
this.activeConnections = 0;
|
||||||
|
|
||||||
@@ -101,81 +92,11 @@ public class QuickConnection extends AbstractConnection {
|
|||||||
*/
|
*/
|
||||||
public QuickConnection(Connection object) {
|
public QuickConnection(Connection object) {
|
||||||
|
|
||||||
setName(object.getName());
|
super(object.getName(),object.getIdentifier(),object.getConfiguration());
|
||||||
setIdentifier(object.getIdentifier());
|
|
||||||
setParentIdentifier(object.getParentIdentifier());
|
setParentIdentifier(object.getParentIdentifier());
|
||||||
setConfiguration(object.getConfiguration());
|
|
||||||
this.config = object.getConfiguration();
|
|
||||||
this.activeConnections = 0;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user