mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-524: Ensure all guacamole-ext classes implementing connect() use the old connect() as their basis. Overriding the old connect() will not have the expected effect otherwise.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -39,6 +40,24 @@ public class DelegatingConnection implements Connection {
|
||||
*/
|
||||
private final Connection connection;
|
||||
|
||||
/**
|
||||
* The tokens which should apply strictly to the next call to
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation)}.
|
||||
* This storage is intended as a temporary bridge allowing the old version
|
||||
* of connect() to be overridden while still resulting in the same behavior
|
||||
* as older versions of DelegatingConnection. <strong>This storage should be
|
||||
* removed once support for the old, deprecated connect() is removed.</strong>
|
||||
*/
|
||||
private final ThreadLocal<Map<String, String>> currentTokens =
|
||||
new ThreadLocal<Map<String, String>>() {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> initialValue() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps the given Connection such that all function calls against this
|
||||
* DelegatingConnection will be delegated to it.
|
||||
@@ -127,10 +146,27 @@ public class DelegatingConnection implements Connection {
|
||||
return connection.getSharingProfileIdentifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
return connection.connect(info, currentTokens.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
return connection.connect(info, tokens);
|
||||
|
||||
// Make received tokens available within the legacy connect() strictly
|
||||
// in context of the current connect() call
|
||||
try {
|
||||
currentTokens.set(tokens);
|
||||
return connect(info);
|
||||
}
|
||||
finally {
|
||||
currentTokens.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
@@ -36,6 +37,25 @@ public class DelegatingConnectionGroup implements ConnectionGroup {
|
||||
*/
|
||||
private final ConnectionGroup connectionGroup;
|
||||
|
||||
/**
|
||||
* The tokens which should apply strictly to the next call to
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation)}.
|
||||
* This storage is intended as a temporary bridge allowing the old version
|
||||
* of connect() to be overridden while still resulting in the same behavior
|
||||
* as older versions of DelegatingConnectionGroup. <strong>This storage
|
||||
* should be removed once support for the old, deprecated connect() is
|
||||
* removed.</strong>
|
||||
*/
|
||||
private final ThreadLocal<Map<String, String>> currentTokens =
|
||||
new ThreadLocal<Map<String, String>>() {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> initialValue() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps the given ConnectionGroup such that all function calls against this
|
||||
* DelegatingConnectionGroup will be delegated to it.
|
||||
@@ -118,10 +138,27 @@ public class DelegatingConnectionGroup implements ConnectionGroup {
|
||||
connectionGroup.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
return connectionGroup.connect(info, currentTokens.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
return connectionGroup.connect(info, tokens);
|
||||
|
||||
// Make received tokens available within the legacy connect() strictly
|
||||
// in context of the current connect() call
|
||||
try {
|
||||
currentTokens.set(tokens);
|
||||
return connect(info);
|
||||
}
|
||||
finally {
|
||||
currentTokens.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -47,7 +47,7 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
||||
* The identifiers of all connection groups in this group.
|
||||
*/
|
||||
private final Set<String> connectionGroupIdentifiers;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new SimpleConnectionGroup having the given name and identifier
|
||||
* which will expose the given contents.
|
||||
@@ -109,9 +109,16 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
@Deprecated
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleSecurityException("Permission denied.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
return connect(info);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user