我在新Web服务器上部署签名小程序(来自受信任CA的证书)时遇到问题。它在旧的Web服务器上运行良好,但是当我将其传输到新主机时,它被Java安全设置阻止。
我在html文件中这样部署它:
<div id="applet">
<script>
var attributes = {codebase:'http://ab123.wwwdns.example.com/Applet/',
code: 'db.main.ExApplet',
archive: 'ExampleApplet.jar',
width: '1150',
height: '700',
permissions: 'sandbox'};
var parameters = {};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
</div>
我的清单文件包含以下几行:
Manifest-Version: 1.0
Application-Name: Example Name
Permissions: sandbox
Caller-Allowable-Codebase: *.example.com http://ab123.wwwdns.example.com http://other.example.com
Codebase: *.example.com http://ab123.wwwdns.example.com http://other.example.com
Application-Library-Allowable-Codebase: *.example.com http://ab123.wwwdns.example.com http://other.example.com
Entry-Point: db.main.ExApplet
(以前我只指定* .example.com尝试过,但这也不起作用)
我想这个问题与以下事实有关:现在可以通过两个不同的URL(ab123.wwwdns.example.com和other.example.com)访问该applet?
这是Java控制台的摘录(Firefox上的Java 8 Update 71 build 15 Plugin):
java.lang.reflect.InvocationTargetException
...
Caused by: com.sun.deploy.security.BlockedException: Your security settings have blocked an untrusted application from running
at com.sun.deploy.security.BlockedDialog.show(Unknown Source)
at com.sun.deploy.security.SandboxSecurity.checkRunUntrusted(Unknown Source)
at
com.sun.deploy.security.SandboxSecurity.checkUnsignedSandboxSecurity(Unknown Source)
...
任何提示都欢迎!
最佳答案
我终于解决了我的问题;我发现“未知源”错误是由于找不到我使用的外部库这一事实造成的。这很奇怪,因为我使用与在旧服务器上使用的完全相同的体系结构来访问外部库,但是在新服务器上,由于某些原因(我不知道),该方法不起作用。
这是我在研究过程中为了使Applet正常运行而进行的更改的列表,现在它可以正常运行,希望这也可以帮助其他在部署applet方面遇到问题的人:
我从html文件中删除了codebase属性
我在清单文件中使用了通配符* .example.com
我将所有外部库移至ExampleApplet.jar所在的文件夹,并且不再将其添加到ExampleApplet.jar文件中
以前我在Class-Path属性中有一个点(。),我也将其删除了
html文件
<div id="applet">
<script>
var attributes = {code: 'db.main.ExApplet',
archive: 'ExampleApplet.jar',
width: '1150',
height: '700',
permissions: 'sandbox'};
var parameters = {};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
</div>
清单文件
Manifest-Version: 1.0
Application-Name: Example Name
Permissions: sandbox
Caller-Allowable-Codebase: *.example.com
Codebase: *.example.com
Application-Library-Allowable-Codebase: *.example.com
Class-Path: external1.jar external2.jar
Entry-Point: db.main.ExApplet
(以前,Class-Path看起来像这样,外部库位于lib /下,此外还位于ExampleApplet.jar中):
Class-Path: . lib/external1.jar lib/external2.jar