mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-921: Restore Jetty 9 support. Tunnel request service was marked for injection in the wrong place.
This commit is contained in:
		| @@ -25,6 +25,7 @@ package org.glyptodon.guacamole.net.basic.websocket.jetty9; | ||||
| import org.eclipse.jetty.websocket.api.UpgradeRequest; | ||||
| import org.eclipse.jetty.websocket.api.UpgradeResponse; | ||||
| import org.eclipse.jetty.websocket.servlet.WebSocketCreator; | ||||
| import org.glyptodon.guacamole.net.basic.TunnelRequestService; | ||||
|  | ||||
| /** | ||||
|  * WebSocketCreator which selects the appropriate WebSocketListener | ||||
| @@ -34,6 +35,22 @@ import org.eclipse.jetty.websocket.servlet.WebSocketCreator; | ||||
|  */ | ||||
| public class BasicGuacamoleWebSocketCreator implements WebSocketCreator { | ||||
|  | ||||
|     /** | ||||
|      * Service for handling tunnel requests. | ||||
|      */ | ||||
|     private final TunnelRequestService tunnelRequestService; | ||||
|  | ||||
|     /** | ||||
|      * Creates a new WebSocketCreator which uses the given TunnelRequestService | ||||
|      * to create new GuacamoleTunnels for inbound requests. | ||||
|      * | ||||
|      * @param tunnelRequestService The service to use for inbound tunnel | ||||
|      *                             requests. | ||||
|      */ | ||||
|     public BasicGuacamoleWebSocketCreator(TunnelRequestService tunnelRequestService) { | ||||
|         this.tunnelRequestService = tunnelRequestService; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Object createWebSocket(UpgradeRequest request, UpgradeResponse response) { | ||||
|  | ||||
| @@ -42,7 +59,7 @@ public class BasicGuacamoleWebSocketCreator implements WebSocketCreator { | ||||
|  | ||||
|             if ("guacamole".equals(subprotocol)) { | ||||
|                 response.setAcceptedSubProtocol(subprotocol); | ||||
|                 return new BasicGuacamoleWebSocketTunnelListener(); | ||||
|                 return new BasicGuacamoleWebSocketTunnelListener(tunnelRequestService); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|   | ||||
| @@ -22,8 +22,6 @@ | ||||
|  | ||||
| package org.glyptodon.guacamole.net.basic.websocket.jetty9; | ||||
|  | ||||
| import com.google.inject.Inject; | ||||
| import com.google.inject.Singleton; | ||||
| import org.eclipse.jetty.websocket.api.Session; | ||||
| import org.glyptodon.guacamole.GuacamoleException; | ||||
| import org.glyptodon.guacamole.net.GuacamoleTunnel; | ||||
| @@ -35,15 +33,24 @@ import org.glyptodon.guacamole.net.basic.TunnelRequestService; | ||||
|  *  | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| @Singleton | ||||
| public class BasicGuacamoleWebSocketTunnelListener extends GuacamoleWebSocketTunnelListener { | ||||
|  | ||||
|     /** | ||||
|      * Service for handling tunnel requests. | ||||
|      */ | ||||
|     @Inject | ||||
|     private TunnelRequestService tunnelRequestService; | ||||
|   | ||||
|     private final TunnelRequestService tunnelRequestService; | ||||
|  | ||||
|     /** | ||||
|      * Creates a new WebSocketListener which uses the given TunnelRequestService | ||||
|      * to create new GuacamoleTunnels for inbound requests. | ||||
|      * | ||||
|      * @param tunnelRequestService The service to use for inbound tunnel | ||||
|      *                             requests. | ||||
|      */ | ||||
|     public BasicGuacamoleWebSocketTunnelListener(TunnelRequestService tunnelRequestService) { | ||||
|         this.tunnelRequestService = tunnelRequestService; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected GuacamoleTunnel createTunnel(Session session) throws GuacamoleException { | ||||
|         return tunnelRequestService.createTunnel(new WebSocketTunnelRequest(session.getUpgradeRequest())); | ||||
|   | ||||
| @@ -22,21 +22,31 @@ | ||||
|  | ||||
| package org.glyptodon.guacamole.net.basic.websocket.jetty9; | ||||
|  | ||||
| import com.google.inject.Inject; | ||||
| import com.google.inject.Singleton; | ||||
| import org.eclipse.jetty.websocket.servlet.WebSocketServlet; | ||||
| import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; | ||||
| import org.glyptodon.guacamole.net.basic.TunnelRequestService; | ||||
|  | ||||
| /** | ||||
|  * A WebSocketServlet partial re-implementation of GuacamoleTunnelServlet. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| @Singleton | ||||
| public class BasicGuacamoleWebSocketTunnelServlet extends WebSocketServlet { | ||||
|  | ||||
|     /** | ||||
|      * Service for handling tunnel requests. | ||||
|      */ | ||||
|     @Inject | ||||
|     private TunnelRequestService tunnelRequestService; | ||||
|   | ||||
|     @Override | ||||
|     public void configure(WebSocketServletFactory factory) { | ||||
|  | ||||
|         // Register WebSocket implementation | ||||
|         factory.setCreator(new BasicGuacamoleWebSocketCreator()); | ||||
|         factory.setCreator(new BasicGuacamoleWebSocketCreator(tunnelRequestService)); | ||||
|          | ||||
|     } | ||||
|      | ||||
|   | ||||
| @@ -113,14 +113,6 @@ public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListe | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Set accepted subprotocol | ||||
|         for (String subprotocol : session.getUpgradeRequest().getSubProtocols()) { | ||||
|             if ("guacamole".equals(subprotocol)) { | ||||
|                 session.getUpgradeResponse().setAcceptedSubProtocol(subprotocol); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Prepare read transfer thread | ||||
|         Thread readThread = new Thread() { | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user