Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (1) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (30) javascript (3) Linux (164) Mac (19) Machine Learning (1) mySQL (47) Netbeans (4) Networking (1) Nexus (1) OpenVMS (6) Oracle (1) Pandas (3) php (16) Postgresql (8) Python (9) raid (1) RedHat (14) Samba (2) Slackware (45) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Wednesday 4 December 2019

multiple JAR files signed with different certificates

REF: https://docs.oracle.com/javase/8/docs/technotes/guides/javaws/developersguide/faq.html#s213

Basically, if I have multiple jar files, some of which are signed by a different certificate, then we need to create separate jnlp files for these resources.

TLDR - Signing each jar with the same certificate, seems to work, regardless if it has been signed before.



The section in the jnlp file that contains:

<jar href="lib/Utilities.jar"/>
 
should be replaced with:

<extension name="Java Utilities" href="utilities_launch.jnlp"/> 
 
and we then need another jnlp file, named utilities_launch.jnlp such as:

<?xml version="1.0" encoding="utf-8"?>
 <jnlp spec="1.0+" href="utilities_launch.jnlp">
 <information>
<title>Java Utilities</title>
<vendor>Harry Nisbet</vendor>
 </information>
     <security>
<all-permissions/>
</security>
<resources>
<jar href="lib/Utilities.jar"/>
</resources>
 <component-desc/>
</jnlp>



So as an example for my Peon application;
Also see below for a live version;


peon.jnlp which exists on the local machine:
 
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="http://172.16.144.252/stuff/peon/" href="launch.jnlp" spec="1.0+">
    <information>
        <title>Peon</title>
        <vendor>Harry Nisbet</vendor>
        <homepage href=""/>
        <description>Peon</description>
        <description kind="short">Peon</description>
    <icon href="peon.png" kind="splash"/>
</information>
    <update check="always"/>
    <security>
<all-permissions/>
</security>
    <resources>
        <j2se version="1.8+"/>
        <jar href="Peon.jar" main="true"/>
        <jar href="lib/postgresql-42.2.8.jar"/>
        <extension name="Java Utilities" href="utilities_launch.jnlp"/>
</resources>
    <application-desc main-class="peon.Form1">
    </application-desc>
</jnlp>

 
launch.jnlp which exists on the server:
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp href="launch.jnlp" spec="1.0+">
    <information>
        <title>Peon</title>
        <vendor>Harry Nisbet</vendor>
        <homepage href=""/>
        <description>Peon</description>
        <description kind="short">Peon</description>
    <icon href="peon.png" kind="splash"/>
</information>
    <update check="always"/>
    <security>
<all-permissions/>
</security>
    <resources>
        <j2se version="1.8+"/>
        <jar href="Peon.jar" main="true"/>
        <jar href="lib/postgresql-42.2.8.jar"/>
<extension name="Java Utilities" href="utilities_launch.jnlp"/>
</resources>
    <application-desc main-class="peon.Form1">
    </application-desc>
</jnlp>

 
 
and finally the utilities_launch.jnlp file which exists beside the launch.jnlp file above:
 
<?xml version="1.0" encoding="utf-8"?>
 <jnlp spec="1.0+" href="utilities_launch.jnlp">
 <information>
<title>Java Utilities</title>
<vendor>Harry Nisbet</vendor>
 </information>
     <security>
<all-permissions/>
</security>
<resources>
<jar href="lib/Utilities.jar"/>
</resources>
 <component-desc/>
</jnlp> 



A live example from my Peon application on server;

 

Contents of readme.txt

1 Create a folder on local pc
2 Download the peon.jnlp file into said folder.
3 Create a shortcut to said peon.jnlp file and place it on Desktop.
4 Profit.
5 Profit more...


Contents of readme2.txt

peon.jnlp should be on desktop or in its own folder.
launch.jnlp should be on server beside the jar file and lib folder.
utilities_launch.jnlp file should be beside the launch.jnlp file above.


Contents of index.html


<HTML>
<meta http-equiv="Refresh" content="n;getpeon.bat">
<p><center>
<a href="getpeon.bat">If download doesnt start automatically, click here!</a>
</center></p>
</HTML>
 


Contents of getpeon.bat


mkdir Peon
cd peon
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://172.16.144.252/stuff/peon/peon.jnlp', 'peon.jnlp')"
cd ..
del -f getpeon.bat


 
Contents of peon.jnlp


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="http://172.16.144.252/stuff/peon/" href="launch.jnlp" spec="1.0+">
    <information>
        <title>Peon</title>
        <vendor>Harry Nisbet</vendor>
        <homepage href=""/>
        <description>Peon</description>
        <description kind="short">Peon</description>
    <icon href="peon.png" kind="splash"/>
</information>
    <update check="always"/>
    <security>
<all-permissions/>
</security>
    <resources>
        <j2se version="1.8+"/>
        <jar href="Peon.jar" main="true"/>
        <jar href="lib/postgresql-42.2.8.jar"/>
        <extension name="Java Utilities" href="utilities_launch.jnlp"/>
</resources>
    <application-desc main-class="peon.Form1">
    </application-desc>
</jnlp>



Contents of launch.jnlp

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp href="launch.jnlp" spec="1.0+">
    <information>
        <title>Peon</title>
        <vendor>Harry Nisbet</vendor>
        <homepage href=""/>
        <description>Peon</description>
        <description kind="short">Peon</description>
    <icon href="peon.png" kind="splash"/>
</information>
    <update check="always"/>
    <security>
<all-permissions/>
</security>
    <resources>
        <j2se version="1.8+"/>
        <jar href="Peon.jar" main="true"/>
        <jar href="lib/postgresql-42.2.8.jar"/>
        <extension name="Java Utilities" href="utilities_launch.jnlp"/>
    </resources>
    <application-desc main-class="peon.Form1">
    </application-desc>
</jnlp>



Contents of utilities_launch.jnlp



<?xml version="1.0" encoding="utf-8"?>
 <jnlp spec="1.0+" href="utilities_launch.jnlp">
 <information>
<title>Java Utilities</title>
<vendor>Harry Nisbet</vendor>
 </information>
     <security>
<all-permissions/>
</security>
<resources>
<jar href="lib/Utilities.jar"/>
</resources>
 <component-desc/>
</jnlp>








No comments:

Post a Comment

Note: only a member of this blog may post a comment.