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

Dynamically generated JNLP, jars signed with different certificates

现在,我们有一个 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>