gpt4 book ai didi

java - 动态生成JNLP,使用不同证书签名的jar

转载 作者:行者123 更新时间:2023-12-02 02:33:08 33 4
gpt4 key购买 nike

现在,我们有一个 Webstart 应用程序,其中包含来自不同应用程序的多个 jar,并使用相同的代码签名证书进行签名。它看起来像:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" codebase="http://host:port/">
<information>
<title>Test</title>
<description>test application</description>
<icon href="http://host:port/test_logo.gif"/></information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7" max-heap-size="512M"/>
<jar href="http://host:port/app1/jars/app1jar.jar" />
<jar href="http://host:port/app2/jars/app2jar.jar" />
<jar href="http://host:port/app3/jars/app3jar.jar" />
</resources>
</jnlp>

我计划为每个 app1、app2 和 app3 使用不同的证书对这些 jar 进行签名。我知道,it is possible to launch webstart applications signed using different certificate 。我们需要为每个文件创建单独的 jnlp 文件,并在主 jnlp 中将它们引用为:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" codebase="http://host:port/">
<information>
<title>Test</title>
<description>test application</description>
<icon href="http://host:port/test_logo.gif"/></information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7" max-heap-size="512M"/>
<jar href="http://host:port/app1/jars/app1jar.jar" />
<extension name="app2" href="app2.jnlp"/>
<extension name="app3" href="app3.jnlp"/>
</resources>
</jnlp>

不幸的是,我无法执行此操作,因为我们在 servlet 内动态生成 JNLP。要包含的 JAR 文件不固定。它们在属性文件中配置。因此,使用这种方法,如果我需要为 app2 和 app3 创建单独的 jnlp 文件,则意味着需要动态生成这些 jnlp 文件,存储在服务器上,然后在我的主 jnlp 中引用。我还需要清理这些临时生成的 jnlp 文件。

我一直在寻找更简单的方法。例如动态生成 app2 和 app3 的 jnlp 代码,然后将其嵌入到主 app1 jnlp 中,而不需要临时 jn​​lp 文件。例如像这样的东西:

  <?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" codebase="http://host:port/">
<information>
<title>Test</title>
<description>test application</description>
<icon href="http://host:port/test_logo.gif"/></information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7" max-heap-size="512M"/>
<jar href="http://host:port/app1/jars/app1jar.jar" />
<jnlp spec="6.0+" codebase="http://host:port/">
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7" max-heap-size="512M"/>
<jar href="http://host:port/app2/jars/app2jar.jar" />
</resources>
</jnlp>
<jnlp spec="6.0+" codebase="http://host:port/">
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7" max-heap-size="512M"/>
<jar href="http://host:port/app3/jars/app3jar.jar" />
</resources>
</jnlp>
</resources>
</jnlp>

我尝试了这个,令人惊讶的是 webstart 没有抛出任何控制台。但是app1找不到app2和app3的类。如果您知道如何实现这一目标,请告诉我。我的JDK版本是1.7.80。

谢谢

最佳答案

我通过为各个应用程序创建单独的 WebServlet 解决了这个问题。这些 WebServlet 将为各个应用程序生成 jnlp 文件。然后我使用 的 href 属性从我的主 jnlp 调用这些 WebServlet。我的最终 jnlp 代码如下所示:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" codebase="http://host:port/">
<information>
<title>Test</title>
<description>test application</description>
<icon href="http://host:port/test_logo.gif"/></information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7" max-heap-size="512M"/>
<jar href="http://host:port/app1/jars/app1jar.jar" />
<extension name="app2" href=http://host:port/app1/app2servlet"/>
<extension name="app2" href=http://host:port/app1/app3servlet"/>
</resources>
</jnlp>

关于java - 动态生成JNLP,使用不同证书签名的jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57219088/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com