mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-1132: Associate tunnels with records, not sockets. Provide tunnel for connect().
This commit is contained in:
		| @@ -23,7 +23,7 @@ | ||||
| package org.glyptodon.guacamole.net.auth; | ||||
|  | ||||
| import org.glyptodon.guacamole.GuacamoleException; | ||||
| import org.glyptodon.guacamole.net.GuacamoleSocket; | ||||
| import org.glyptodon.guacamole.net.GuacamoleTunnel; | ||||
| import org.glyptodon.guacamole.protocol.GuacamoleClientInformation; | ||||
|  | ||||
| /** | ||||
| @@ -42,13 +42,13 @@ public interface Connectable { | ||||
|      *     Information associated with the connecting client. | ||||
|      * | ||||
|      * @return | ||||
|      *     A fully-established GuacamoleSocket. | ||||
|      *     A fully-established GuacamoleTunnel. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If an error occurs while connecting to guacd, or if permission to | ||||
|      *     connect is denied. | ||||
|      */ | ||||
|     public GuacamoleSocket connect(GuacamoleClientInformation info) | ||||
|     public GuacamoleTunnel connect(GuacamoleClientInformation info) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -23,7 +23,7 @@ | ||||
| package org.glyptodon.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Date; | ||||
| import org.glyptodon.guacamole.net.GuacamoleSocket; | ||||
| import org.glyptodon.guacamole.net.GuacamoleTunnel; | ||||
|  | ||||
| /** | ||||
|  * A logging record describing when a user started and ended usage of a | ||||
| @@ -88,14 +88,14 @@ public interface ConnectionRecord { | ||||
|     public boolean isActive(); | ||||
|  | ||||
|     /** | ||||
|      * Returns the connected GuacamoleSocket of the connection associated with | ||||
|      * Returns the connected GuacamoleTunnel of the connection associated with | ||||
|      * this record, if any. If the connection is not active, or access to | ||||
|      * the socket is denied, null is returned. | ||||
|      * | ||||
|      * @return | ||||
|      *     The connected GuacamoleSocket, if any, or null if the connection is | ||||
|      *     The connected GuacamoleTunnel, if any, or null if the connection is | ||||
|      *     not active or permission is denied. | ||||
|      */ | ||||
|     public GuacamoleSocket getSocket(); | ||||
|     public GuacamoleTunnel getTunnel(); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -112,4 +112,25 @@ public interface UserContext { | ||||
|     Collection<ConnectionRecord> getActiveConnections() | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Returns the connection record associated with the active connection | ||||
|      * having the tunnel with the given UUID. The active connection will only | ||||
|      * be returned if the current user has access. | ||||
|      * | ||||
|      * @param tunnelUUID | ||||
|      *     The UUID of the tunnel whose associated connection record should be | ||||
|      *     returned. | ||||
|      * | ||||
|      * @return | ||||
|      *     The connection record associated with the active connection having | ||||
|      *     the tunnel with the given UUID, if any, or null if no such | ||||
|      *     connection exists. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If an error occurs while reading active connection records, or if | ||||
|      *     permission is denied. | ||||
|      */ | ||||
|     ConnectionRecord getActiveConnection(String tunnelUUID) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -28,8 +28,10 @@ import org.glyptodon.guacamole.GuacamoleException; | ||||
| import org.glyptodon.guacamole.environment.Environment; | ||||
| import org.glyptodon.guacamole.environment.LocalEnvironment; | ||||
| import org.glyptodon.guacamole.net.GuacamoleSocket; | ||||
| import org.glyptodon.guacamole.net.GuacamoleTunnel; | ||||
| import org.glyptodon.guacamole.net.InetGuacamoleSocket; | ||||
| import org.glyptodon.guacamole.net.SSLGuacamoleSocket; | ||||
| import org.glyptodon.guacamole.net.SynchronizedGuacamoleTunnel; | ||||
| import org.glyptodon.guacamole.net.auth.AbstractConnection; | ||||
| import org.glyptodon.guacamole.net.auth.ConnectionRecord; | ||||
| import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket; | ||||
| @@ -84,7 +86,7 @@ public class SimpleConnection extends AbstractConnection { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public GuacamoleSocket connect(GuacamoleClientInformation info) | ||||
|     public GuacamoleTunnel connect(GuacamoleClientInformation info) | ||||
|             throws GuacamoleException { | ||||
|  | ||||
|         Environment env = new LocalEnvironment(); | ||||
| @@ -93,19 +95,24 @@ public class SimpleConnection extends AbstractConnection { | ||||
|         String hostname = env.getProperty(Environment.GUACD_HOSTNAME); | ||||
|         int port = env.getProperty(Environment.GUACD_PORT); | ||||
|  | ||||
|         GuacamoleSocket socket; | ||||
|          | ||||
|         // If guacd requires SSL, use it | ||||
|         if (env.getProperty(Environment.GUACD_SSL, false)) | ||||
|             return new ConfiguredGuacamoleSocket( | ||||
|             socket = new ConfiguredGuacamoleSocket( | ||||
|                 new SSLGuacamoleSocket(hostname, port), | ||||
|                 config, info | ||||
|             ); | ||||
|  | ||||
|         // Return connected socket | ||||
|         return new ConfiguredGuacamoleSocket( | ||||
|             new InetGuacamoleSocket(hostname, port), | ||||
|             config, info | ||||
|         ); | ||||
|         // Otherwise, just connect directly via TCP | ||||
|         else | ||||
|             socket = new ConfiguredGuacamoleSocket( | ||||
|                 new InetGuacamoleSocket(hostname, port), | ||||
|                 config, info | ||||
|             ); | ||||
|  | ||||
|         return new SynchronizedGuacamoleTunnel(socket); | ||||
|          | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -27,7 +27,7 @@ import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| import org.glyptodon.guacamole.GuacamoleException; | ||||
| import org.glyptodon.guacamole.GuacamoleSecurityException; | ||||
| import org.glyptodon.guacamole.net.GuacamoleSocket; | ||||
| import org.glyptodon.guacamole.net.GuacamoleTunnel; | ||||
| import org.glyptodon.guacamole.net.auth.AbstractConnectionGroup; | ||||
| import org.glyptodon.guacamole.net.auth.ConnectionGroup; | ||||
| import org.glyptodon.guacamole.protocol.GuacamoleClientInformation; | ||||
| @@ -102,7 +102,7 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public GuacamoleSocket connect(GuacamoleClientInformation info)  | ||||
|     public GuacamoleTunnel connect(GuacamoleClientInformation info)  | ||||
|             throws GuacamoleException { | ||||
|         throw new GuacamoleSecurityException("Permission denied."); | ||||
|     } | ||||
|   | ||||
| @@ -174,4 +174,10 @@ public class SimpleUserContext implements UserContext { | ||||
|         return Collections.EMPTY_LIST; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ConnectionRecord getActiveConnection(String tunnelUUID) | ||||
|             throws GuacamoleException { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user