package com.test;
import org.apache.guacamole.GuacamoleClientException;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleResourceNotFoundException;
import org.apache.guacamole.GuacamoleServerException;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.servlet.GuacamoleHTTPTunnelServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class MyGuacamoleHTTPTunnelServlet extends GuacamoleHTTPTunnelServlet{
private final Logger logger = LoggerFactory.getLogger(MyGuacamoleHTTPTunnelServlet.class);
private static final int READ_PREFIX_LENGTH = "read:".length();
private static final int WRITE_PREFIX_LENGTH = "write:".length();
@Override
protected GuacamoleTunnel doConnect(HttpServletRequest httpServletRequest) throws GuacamoleException {
return null;
}
@Override
protected void handleTunnelRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException {
try {
String query = request.getQueryString();
if (query == null) {
throw new GuacamoleClientException("No query string provided.");
}
if (query.startsWith("connect")) {
GuacamoleTunnel tunnel = this.doConnect(request);
if (tunnel == null) {
throw new GuacamoleResourceNotFoundException("No tunnel created.");
}
this.registerTunnel(tunnel);
try {
response.setHeader("Cache-Control", "no-cache");
response.getWriter().print(tunnel.getUUID().toString());
} catch (IOException var6) {
throw new GuacamoleServerException(var6);
}
} else if (query.startsWith("read:")) {
this.doRead(request, response, query.substring(READ_PREFIX_LENGTH, READ_PREFIX_LENGTH + 36));
} else {
if (!query.startsWith("write:")) {
throw new GuacamoleClientException("Invalid tunnel operation: " + query);
}
this.doWrite(request, response, query.substring(WRITE_PREFIX_LENGTH, WRITE_PREFIX_LENGTH + 36));
}
} catch (GuacamoleClientException var7) {
this.logger.warn("HTTP tunnel request rejected: {}", var7.getMessage());
this.sendError(response, var7.getStatus(), var7.getMessage());
} catch (GuacamoleException var8) {
this.logger.error("HTTP tunnel request failed: {}", var8.getMessage());
this.logger.debug("Internal error in HTTP tunnel.", var8);
this.sendError(response, var8.getStatus(), "Internal server error.");
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Guacamole 简单案例
共39个文件
xml:12个
class:6个
js:6个
需积分: 50 28 下载量 99 浏览量
2018-03-07
16:23:04
上传
评论 1
收藏 311KB RAR 举报
温馨提示
Guacamole 简单案例,不需要登录,简单易懂 Guacamole 简单案例,不需要登录,简单易懂
资源推荐
资源详情
资源评论
收起资源包目录
GuacamoleDemo.rar (39个子文件)
GuacamoleDemo
src
test
java
main
webapp
WEB-INF
web.xml 1KB
index.html 4KB
guacamole
map.js 4KB
dot.gif 72B
guacamole-common-js
all.js 407KB
app.css 57KB
jquery-1.8.0.min.js 90KB
guacamole.css 891B
resources
java
com
test
MyGuacamoleHTTPTunnelServlet.java 3KB
ServletTest.java 662B
TutorialGuacamoleTunnelServlet.java 2KB
target
generated-sources
annotations
classes
com
test
ServletTest.class 1KB
MyGuacamoleHTTPTunnelServlet.class 4KB
TutorialGuacamoleTunnelServlet.class 2KB
.idea
artifacts
GuacamoleDemo_war_exploded.xml 795B
libraries
Maven__org_slf4j_slf4j_api_1_7_7.xml 506B
Maven__org_apache_guacamole_guacamole_common_0_9_14.xml 606B
Maven__javax_servlet_servlet_api_2_5.xml 522B
misc.xml 439B
compiler.xml 638B
workspace.xml 36KB
encodings.xml 172B
inspectionProfiles
modules.xml 266B
GuacamoleDemo.iml 2KB
pom.xml 2KB
out
artifacts
GuacamoleDemo_war_exploded
WEB-INF
classes
com
test
ServletTest.class 1KB
MyGuacamoleHTTPTunnelServlet.class 4KB
TutorialGuacamoleTunnelServlet.class 2KB
lib
slf4j-api-1.7.7.jar 29KB
guacamole-common-0.9.14.jar 58KB
web.xml 1KB
index.html 4KB
guacamole
map.js 4KB
dot.gif 72B
guacamole-common-js
all.js 407KB
app.css 57KB
jquery-1.8.0.min.js 90KB
guacamole.css 891B
META-INF
MANIFEST.MF 98B
共 39 条
- 1
资源评论
mylove1417
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功