Search code examples
javassl-certificatecode-signingjava-web-startjnlp

Dynamically generated JNLP, jars signed with different certificates


Right now, we have a webstart application, with multiple jars from different applications, singed with same code signing certificate. It looks like:

<?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>

I am planning to sign these jars with different certificates for each app1, app2 and app3. I am aware that, it is possible to launch webstart applications signed using different certificate. We need to create separate jnlp file for each and refer them in main jnlp as:

<?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>

Unfortunately I can't do this as we generate our JNLP dynamically inside a servlet. JAR files to be included are not fixed. They are configured in properties file. So with this approach, if I need to create separate jnlp files for app2 and app3, it means those jnlp needs to be generated dynamically, stored on server and then referred inside my main jnlp. I also need to take care of clean up of these temporarily generated jnlp files.

I was looking for more easy approach. e.g. generate jnlp code for app2 and app3 dynamically and then embed it inside main app1 jnlp without needing temporary jnlp files. e.g. something like this:

  <?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>

I tried this, surprisingly webstart didnt throw any console. But app1 can not find classes of app2 and app3. Please let me know if you have idea on how to achieve this. My JDK version is 1.7.80.

Thanks,


Solution

  • I solved this problem by creating separate WebServlets for individual applications. These WebServlets would generate jnlp files for individual applications. And then I called these WebServlets from my main jnlp using href attribute of . My final jnlp code looks like:

    <?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>