测试 JCTerm,java applet 终端模拟器,可以在 Eclipse 中运行,但不能在浏览器中运行

发布于 2024-11-09 01:32:18 字数 2397 浏览 5 评论 0原文

测试未修改版本的 JCTerm(终端仿真器,可以用作小程序;我想使用小程序功能),在 Eclipse 的 AppletViewer 中一切似乎都工作正常,但在网页中测试生成的 jar 文件,所有选项显示带有闪烁黄色警告符号的消息框,但不执行任何操作。某些选项显示“在此设置之前建立连接”错误。

我感兴趣的选项是“文件”菜单中的“打开 SHELL 会话...”。当尝试“打开 SHELL 会话...”选项时,小程序的 Java 控制台会显示这些内容,这似乎是直接相关的。但我不知道这意味着什么。

    network: Connecting http://xxx.xx.xx.xxx/crossdomain.xml with proxy=DIRECT
    network: Connecting http://xxx.xx.xx.xxx:80/ with proxy=DIRECT
    java.security.PrivilegedActionException: java.net.ConnectException: Connection refused: connect
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.deploy.net.CrossDomainXML.check(Unknown Source)
        at com.sun.deploy.net.CrossDomainXML.check(Unknown Source)
        at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at com.jcraft.jsch.Util$1.run(Util.java:354)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at sun.net.NetworkClient.doConnect(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.<init>(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
        at com.sun.deploy.net.CrossDomainXML$2.run(Unknown Source)
        ... 10 more    

该程序正常工作的示例可以在这里找到,http://wiredx.net/jcterm/

Testing an unmodified version of JCTerm (terminal emulator, can be used as an applet; I would like to use the applet functionality), everything seems to be working fine in Eclipse's AppletViewer, but testing the resulting jar file in an web page, all options display a message box with a flashing yellow warning symbol and do nothing. Some options display a "Establish the connection before this setting" error.

The option I'm interested in using is 'Open SHELL Session...' from the File menu. When trying 'Open SHELL Session...' option, the Java Console for the applet displays this stuff, which seems directly related. I don't have a clue as to what it means though.

    network: Connecting http://xxx.xx.xx.xxx/crossdomain.xml with proxy=DIRECT
    network: Connecting http://xxx.xx.xx.xxx:80/ with proxy=DIRECT
    java.security.PrivilegedActionException: java.net.ConnectException: Connection refused: connect
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.deploy.net.CrossDomainXML.check(Unknown Source)
        at com.sun.deploy.net.CrossDomainXML.check(Unknown Source)
        at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at com.jcraft.jsch.Util$1.run(Util.java:354)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at sun.net.NetworkClient.doConnect(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.<init>(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
        at com.sun.deploy.net.CrossDomainXML$2.run(Unknown Source)
        ... 10 more    

An example of this program working correctly can be found here, http://wiredx.net/jcterm/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墟烟 2024-11-16 01:32:18

我是 jcterm 的作者。
http://wiredx.net/jcterm/ 上的 jar 文件已进行数字签名。
因此,如果您将这些文件复制并安装到您的网络服务器中,它就会起作用。

I'm the author of jcterm.
The jar files at http://wiredx.net/jcterm/ have been digitally signed.
So, if you copy and intstall those files into your web server, it will work.

南七夏 2024-11-16 01:32:18

这看起来像是一个安全问题。

默认情况下,未签名的 Java 小程序只能连接到从其加载的主机。此外,如果您要连接的主机通过其 crossdomain.xml 文件允许这样做,您还可以连接到其他主机。

从堆栈跟踪来看,您想要连接到没有 HTTP 服务器的主机,因此无法提供 crossdomain.xml 文件。因此,您会在此处得到此异常。

有以下方法可以解决这个问题:

  • 将小程序放在您稍后要使用 SSH 连接的同一 Web 服务器上。 (每个小程序都可以连接到自己的主机。)
  • 让 SSH 服务器拥有一个带有 crossdomain.xml 的最小 Web 服务器。 (crossdomain.xml 必须允许来自 applet 服务器的内容访问该服务器。)
  • 对 applet 进行签名(并让用户信任它)。 (经过签名且受信任的小程序可以执行所有操作。)

您链接的官方 WiredX 示例小程序使用最后一种方法,这就是为什么它即使在连接到服务器时也能工作的原因。

This looks like a security problem.

By default, an unsigned Java applet can only connect to the host if was loaded from. Additionally, if the host you want to connect to allows this with it's crossdomain.xml file, you can also connect to other hosts.

Judging from the stack trace, you want to connect to a host which does not have an HTTP server, and thus can't provide a crossdomain.xml file. For this reason, you get this exception here.

There are these ways out of this:

  • Put the applet on the same web server which you want to connect to with SSH later. (Every applet can connect to its own host.)
  • Let the SSH server have a minimal web server with a crossdomain.xml. (The crossdomain.xml must allow content from the applet's server to access this server.)
  • Sign the applet (and let the user trust it). (Signed and trusted applets are allowed to do everything.)

The official WiredX sample applet you linked uses the last method, this is why it works even when connecting to your server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文