mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Add controlling enable-clipboard-integration property.
This commit is contained in:
@@ -29,8 +29,8 @@ import javax.servlet.http.HttpSession;
|
|||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleServerException;
|
import org.glyptodon.guacamole.GuacamoleServerException;
|
||||||
import org.glyptodon.guacamole.net.auth.UserContext;
|
import org.glyptodon.guacamole.net.auth.UserContext;
|
||||||
import org.slf4j.Logger;
|
import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Servlet which dumps the current contents of the clipboard.
|
* Servlet which dumps the current contents of the clipboard.
|
||||||
@@ -39,35 +39,46 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class CaptureClipboard extends AuthenticatingHttpServlet {
|
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.
|
* The amount of time to wait for clipboard changes, in milliseconds.
|
||||||
*/
|
*/
|
||||||
private static final int CLIPBOARD_TIMEOUT = 250;
|
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
|
@Override
|
||||||
protected void authenticatedService(
|
protected void authenticatedService(
|
||||||
UserContext context,
|
UserContext context,
|
||||||
HttpServletRequest request, HttpServletResponse response)
|
HttpServletRequest request, HttpServletResponse response)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Get clipboard
|
// Only bother if actually enabled
|
||||||
final HttpSession session = request.getSession(true);
|
if (GuacamoleProperties.getProperty(INTEGRATION_ENABLED, false)) {
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user