mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1218: Use TokenFilter to inject tokens from configuration attributes
This commit is contained in:
@@ -43,6 +43,7 @@ import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
|||||||
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;
|
||||||
|
import org.apache.guacamole.token.TokenFilter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ public class ConnectionService {
|
|||||||
* connect is denied.
|
* connect is denied.
|
||||||
*/
|
*/
|
||||||
public GuacamoleTunnel connect(UserData.Connection connection,
|
public GuacamoleTunnel connect(UserData.Connection connection,
|
||||||
GuacamoleClientInformation info) throws GuacamoleException {
|
GuacamoleClientInformation info, Map<String, String> tokens) throws GuacamoleException {
|
||||||
|
|
||||||
// Retrieve proxy configuration from environment
|
// Retrieve proxy configuration from environment
|
||||||
GuacamoleProxyConfiguration proxyConfig = environment.getDefaultGuacamoleProxyConfiguration();
|
GuacamoleProxyConfiguration proxyConfig = environment.getDefaultGuacamoleProxyConfiguration();
|
||||||
@@ -176,14 +177,17 @@ public class ConnectionService {
|
|||||||
int port = proxyConfig.getPort();
|
int port = proxyConfig.getPort();
|
||||||
|
|
||||||
// Generate and verify connection configuration
|
// Generate and verify connection configuration
|
||||||
GuacamoleConfiguration config = getConfiguration(connection);
|
GuacamoleConfiguration filteredConfig = getConfiguration(connection);
|
||||||
if (config == null) {
|
if (filteredConfig == null) {
|
||||||
logger.debug("Configuration for connection could not be "
|
logger.debug("Configuration for connection could not be "
|
||||||
+ "generated. Perhaps the connection being joined is not "
|
+ "generated. Perhaps the connection being joined is not "
|
||||||
+ "active?");
|
+ "active?");
|
||||||
throw new GuacamoleResourceNotFoundException("No such connection");
|
throw new GuacamoleResourceNotFoundException("No such connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply tokens to config parameters
|
||||||
|
new TokenFilter(tokens).filterValues(filteredConfig.getParameters());
|
||||||
|
|
||||||
// Determine socket type based on required encryption method
|
// Determine socket type based on required encryption method
|
||||||
final ConfiguredGuacamoleSocket socket;
|
final ConfiguredGuacamoleSocket socket;
|
||||||
switch (proxyConfig.getEncryptionMethod()) {
|
switch (proxyConfig.getEncryptionMethod()) {
|
||||||
@@ -192,7 +196,7 @@ public class ConnectionService {
|
|||||||
case SSL:
|
case SSL:
|
||||||
socket = new ConfiguredGuacamoleSocket(
|
socket = new ConfiguredGuacamoleSocket(
|
||||||
new SSLGuacamoleSocket(hostname, port),
|
new SSLGuacamoleSocket(hostname, port),
|
||||||
config, info
|
filteredConfig, info
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -200,7 +204,7 @@ public class ConnectionService {
|
|||||||
case NONE:
|
case NONE:
|
||||||
socket = new ConfiguredGuacamoleSocket(
|
socket = new ConfiguredGuacamoleSocket(
|
||||||
new InetGuacamoleSocket(hostname, port),
|
new InetGuacamoleSocket(hostname, port),
|
||||||
config, info
|
filteredConfig, info
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -277,7 +281,7 @@ public class ConnectionService {
|
|||||||
|
|
||||||
// Track tunnels which join connections, such that they can be
|
// Track tunnels which join connections, such that they can be
|
||||||
// automatically closed when the joined connection closes
|
// automatically closed when the joined connection closes
|
||||||
String joinedConnection = config.getConnectionID();
|
String joinedConnection = filteredConfig.getConnectionID();
|
||||||
if (joinedConnection != null) {
|
if (joinedConnection != null) {
|
||||||
|
|
||||||
// Track shadower of joined connection if possible
|
// Track shadower of joined connection if possible
|
||||||
|
@@ -180,7 +180,7 @@ public class UserDataConnection implements Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform connection operation
|
// Perform connection operation
|
||||||
return connectionService.connect(connection, info);
|
return connectionService.connect(connection, info, tokens);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user