From 3c8d72653e7c0fea54d7d1fe5ebeab3c1dc1990f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 3 Mar 2014 09:39:09 -0800 Subject: [PATCH] Add controlling enable-clipboard-integration property. --- .../guacamole/net/basic/CaptureClipboard.java | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/CaptureClipboard.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/CaptureClipboard.java index 322f088bf..4b16a0240 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/CaptureClipboard.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/CaptureClipboard.java @@ -29,8 +29,8 @@ import javax.servlet.http.HttpSession; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleServerException; import org.glyptodon.guacamole.net.auth.UserContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty; +import org.glyptodon.guacamole.properties.GuacamoleProperties; /** * Servlet which dumps the current contents of the clipboard. @@ -39,35 +39,46 @@ import org.slf4j.LoggerFactory; */ public class CaptureClipboard extends AuthenticatingHttpServlet { - /** - * Logger for this class. - */ - private Logger logger = LoggerFactory.getLogger(CaptureClipboard.class); - /** * The amount of time to wait for clipboard changes, in milliseconds. */ private static final int CLIPBOARD_TIMEOUT = 250; - + + /** + * Whether clipboard integration is enabled. + */ + public static final BooleanGuacamoleProperty INTEGRATION_ENABLED = new BooleanGuacamoleProperty() { + + @Override + public String getName() { return "enable-clipboard-integration"; } + + }; + + @Override protected void authenticatedService( UserContext context, HttpServletRequest request, HttpServletResponse response) throws GuacamoleException { - // Get clipboard - final HttpSession session = request.getSession(true); - final ClipboardState clipboard = getClipboardState(session); - - // Send clipboard contents - try { - response.setContentType("text/plain"); - response.getWriter().print(clipboard.waitForContents(CLIPBOARD_TIMEOUT)); - } - catch (IOException e) { - throw new GuacamoleServerException("Unable to send clipboard contents", e); - } + // Only bother if actually enabled + if (GuacamoleProperties.getProperty(INTEGRATION_ENABLED, false)) { + // Get clipboard + final HttpSession session = request.getSession(true); + final ClipboardState clipboard = getClipboardState(session); + + // Send clipboard contents + try { + response.setContentType("text/plain"); + response.getWriter().print(clipboard.waitForContents(CLIPBOARD_TIMEOUT)); + } + catch (IOException e) { + throw new GuacamoleServerException("Unable to send clipboard contents", e); + } + + } + } }