简体   繁体   中英

How to sign JNLP file?

I'm having a Java 7 application that's being built using ANT script (application is built into a jar file) and deployed to clients using JNLP file.

Currently I need to put some "property" into JNLP file but that property isn't visible from within my app unless I mark that particular property as "secure" (meaning to put "jnlp." as property name prefix). That works but I don't think it's a good way to provide my custom properties to the application.

In order to use jnlp properties they way I should, I have to "sign" jnlp file as described here .

As I'm using Java 7, the ability to make JNLP template is nice but I'm not sure were to put described JNLP template in my project structure nor how to include it in my Ant build.

I'm not very "fluent" with Ant.

You need to use the signJar task in Ant. Here is a link to the documentation and examples of how to use it.

https://ant.apache.org/manual/Tasks/signjar.html

您需要将JNLP添加到链接中指定的目录和名称下的JAR文件中,这是通过<jar>任务完成的,然后使用<signjar>任务对其进行签名。

As the article describes if you want to sign your JNLP file you have to put it into the JNLP-INF subdirectory. So your project structure should look like this:

YourApp.jar:
  \- com (folder with your java classes)
  \- META-INF (folder which contains the manifest)
  \- JNLP-INF (folder which contains your.jnlp file)
  \- ... (other folders like res, dtd etc.)

The JAR file is created and signed in the usual manner - there is no extra task necessary. Please note, that when the app is started, the JNLP file used must be identical to the JNLP file in the signed JAR in order for the application to run.

under "jar" i have only 2 subnodes: "manifest" and fileset dir="${workspace.path}${project.name}/bin"

This means that a manifest will be created and every file and folder which is in the /bin directory will be included in your app.jar file. So eg eclipse automatically puts each of the source directories into the /bin file. So depending on what kind of IDE you are using / or not using you have to copy the JNLP-INF manually. Since signing is always done on the whole jar file you doesn't need to do anything...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM