GUACAMOLE-524: Provide bridge implementations of both old and new versions of connect() for sake of compatibility.

This commit is contained in:
Michael Jumper
2019-01-20 13:26:44 -08:00
parent 59b1ccc732
commit 4a1527b1d4

View File

@@ -19,6 +19,7 @@
package org.apache.guacamole.net.auth; package org.apache.guacamole.net.auth;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.GuacamoleTunnel; import org.apache.guacamole.net.GuacamoleTunnel;
@@ -29,6 +30,37 @@ import org.apache.guacamole.protocol.GuacamoleClientInformation;
*/ */
public interface Connectable { public interface Connectable {
/**
* Establishes a connection to guacd using the information associated with
* this object. The connection will be provided the given client
* information.
*
* @deprecated
* This function has been deprecated in favor of
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation, java.util.Map)},
* which allows for connection parameter tokens to be injected and
* applied by cooperating extensions, replacing the functionality
* previously provided through the {@link org.apache.guacamole.token.StandardTokens}
* class. It continues to be defined on this interface for
* compatibility. <strong>New implementations should instead implement
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation, java.util.Map)}.</strong>
*
* @param info
* Information associated with the connecting client.
*
* @return
* A fully-established GuacamoleTunnel.
*
* @throws GuacamoleException
* If an error occurs while connecting to guacd, or if permission to
* connect is denied.
*/
@Deprecated
default GuacamoleTunnel connect(GuacamoleClientInformation info)
throws GuacamoleException {
return this.connect(info, Collections.emptyMap());
}
/** /**
* Establishes a connection to guacd using the information associated with * Establishes a connection to guacd using the information associated with
* this object. The connection will be provided the given client * this object. The connection will be provided the given client
@@ -36,6 +68,17 @@ public interface Connectable {
* apply the given tokens when configuring the connection, such as with a * apply the given tokens when configuring the connection, such as with a
* {@link org.apache.guacamole.token.TokenFilter}. * {@link org.apache.guacamole.token.TokenFilter}.
* *
* <p>A default implementation which invokes the old, deprecated
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation)}
* is provided solely for compatibility with extensions which implement only
* the deprecated function. This default implementation is useful only
* for extensions relying on the deprecated function and will be removed
* when the deprecated function is removed.
*
* <p><strong>New implementations should always implement this function
* in favor of the deprecated
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation)}.</strong>
*
* @see <a href="http://guacamole.apache.org/doc/gug/configuring-guacamole.html#parameter-tokens">Parameter Tokens</a> * @see <a href="http://guacamole.apache.org/doc/gug/configuring-guacamole.html#parameter-tokens">Parameter Tokens</a>
* *
* @param info * @param info
@@ -54,8 +97,13 @@ public interface Connectable {
* If an error occurs while connecting to guacd, or if permission to * If an error occurs while connecting to guacd, or if permission to
* connect is denied. * connect is denied.
*/ */
public GuacamoleTunnel connect(GuacamoleClientInformation info, default GuacamoleTunnel connect(GuacamoleClientInformation info,
Map<String, String> tokens) throws GuacamoleException; Map<String, String> tokens) throws GuacamoleException {
// Allow old implementations of Connectable to continue to work
return this.connect(info);
}
/** /**
* Returns the number of active connections associated with this object. * Returns the number of active connections associated with this object.