Applet 中的 java.net.SocketPermission [英] java.net.SocketPermission in Applet

查看:18
本文介绍了Applet 中的 java.net.SocketPermission的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要在服务器上保存文本文件的小程序.在与这个问题搏斗了一段时间后,我偶然发现了 Lynlin.class 上的互联网,它可以使用 ftp 连接发送文件.如果我将以下行添加到 C:\Program Files\Java\jre7\lib\security\java.policy 文件中,则效果很好:

I'm developing an applet that requires to save a text file on the server. After wrestling with this problem for a while I stumbled on the internet on the Lynlin.class which can send files using ftp connection. That works fine provided I add to my C:\Program Files\Java\jre7\lib\security\java.policy file a following line:

permission java.net.SocketPermission "192.168.33.15:*", "connect, accept ,resolve, listen";

如果我尝试从未编辑过 java.policy 文件的计算机上运行此小程序,则会出现以下错误:

If I try to run this applet from the computer that did not have the java.policy file edited I get the following error:

java.security.AccessControlException: access denied 
    ("java.net.SocketPermission" "192.168.33.15:21" "connect,resolve")*

除了在每台将使用此小程序的计算机上编辑 java.policy 文件之外,有没有人知道我怎样才能摆脱这个问题?

Does anybody know how could I get rid of this problem other than editing java.policy file at each and every computer that will be using this applet?

只是为了澄清:

  • 我的小程序目前没有签名,但它尝试发送文件的服务器与小程序所在的服务器相同

  • my applet at the moment is not signed, but the server with which it tries to send a file is the same at which the applet is located

http 和 ftp 服务器是运行在 Windows Server 2003 (ip 192.168.33.15) 上的 microsoft IIS

the http and ftp server are microsoft IIS running on the Windows Server 2003 (ip 192.168.33.15)

推荐答案

正如 EJP 所暗示的,传递小程序的地址和服务器的地址似乎与运行小程序的 JRE 不同.

As EJP alluded to, the address delivering the applet, and the address of the server, seem to be different to the JRE that is running the applet.

需要通过服务器访问 HTML(一个 http://.. 地址).

It is necessary to access the HTML via the server (an http://.. address).

这篇关于Applet 中的 java.net.SocketPermission的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆