嵌入签名的小程序
我有一个 Java 小程序,它将与本地服务器建立 TCP 连接并获取一些数据。我对小程序进行了自签名,当我在 netbeans 中运行小程序时,它工作正常,但是当我尝试将小程序嵌入到网页中时,我收到此错误:
java.lang.SecurityException: trusted loader attempted to load sandboxed resource from file:/C:/Users/...
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1500(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
...
HTML
<APPLET codebase="classes" archive="lib1.jar, lib2.jar" code="test/Test.class" width=350 height=200></APPLET>
我猜测使用 code 属性会导致问题,因为仅对 jar 文件进行了签名,这些类文件是由 netbeans 生成的。
I have a Java applet which will establish a TCP connection with a local server and get some data. I self signed the applets, and when I run the applet in netbeans it works fine, but when I try to embed the applet into a webpage, I get this error:
java.lang.SecurityException: trusted loader attempted to load sandboxed resource from file:/C:/Users/...
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1500(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
...
HTML
<APPLET codebase="classes" archive="lib1.jar, lib2.jar" code="test/Test.class" width=350 height=200></APPLET>
I'm guessing that using the code attribute is causing the issue because only the jar files were signed, and those class files were generated by netbeans.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定,因为我看不到完整的图片及其所有细节,但正如我所看到的,这里提到了一个非常不寻常的例外:
我可能建议您尝试加载,正如我所注意到的,两个罐子...
so
A) 也许其中一个(或两个)jar 未签名,但确实包含“安全限制代码”,因此它仍然由小程序的沙箱控制
我想你应该对所有可能包含 IO 调用的 jar 进行签名
,或者
B) 你的 jar 位置 file:/C:/Users/... 对于小程序来说是很不寻常的由于文件协议...通常,所有jar都应该直接从applet本机主机下载,而不是本地文件系统...所以我建议您部署它并重试。 ...让我们看看有什么变化
或
C) 只需仔细观察所有小程序对象调用语法,尤其是 JS 或 HTML 中的
语法
无论如何,要告诉更多信息,最好至少看到整个 stackTrace 及其“原因”
祝你好运
I am not pretty sure because I cannot see the whole picture with all its details but as I can see here is mentioned a quite unusual exception as
I may suggest that you are trying to load, as I can notice, two jars as...
so
A) perhaps one (or both) of the jars is NOT SIGNED but do contain "security restricted code" so it is still controlled by applets' sandbox
I guess you should sign all jars which may contain IO invokation
OR
B) Your jar location as file:/C:/Users/... is quite unusual as for applet because of file protocol... As a rule, all jars should be downloaded right from the applet native host but not a local file system... So I suggest you to deploy it and try again. ...Lets see what changes
OR
C) Just watch carefully all applet objects calls syntax especially in JS or HTML
P.S.
Anyway, to tell more it would be better to see, at least, the whole stackTrace with its "cause by"
Good luck