mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17: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.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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user