[英]Can the maven-webstart-plugin sign the JNLP file itself?
JNLP規范說,可選地,JNLP文件本身可以通過將其包含在JNLP應用程序的主jar(它本身必須簽名)中進行簽名。 有誰知道maven-webstart-plugin是否可以這樣做?
基於MWEBSTART-176,這看起來像是已經請求但尚未實現的功能。
JNLP簽名(自動生成APPLICATION.JNLP或APPLICATION_TEMPLATE.JNLP)可以通過組合多個maven插件來完成。 通常,webstart-maven-plugin完成整個工作,包括在maven模塊中打包工件(例如zip文件)。 進行JNLP簽名的關鍵是將此任務分為幾個步驟:
A)用於APPLICATION.JNLP生成:
B)用於APPLICATION_TEMPLATE.JNLP生成(第1點和第2點與前面的步驟不同):
注1:main.jar文件被簽名兩次(在步驟1中)和3)),這與通過maven-jarsigner-plugin在步驟3)中僅對所有jar進行一次簽名進行比較是開銷。 但是我們需要這樣做,因為webstart-maven-plugin只有配置的簽名才能更新清單文件(帶有權限標題)。
注意2:當您的webstart應用程序具有許多不同的構建配置文件時,此方法非常有效,因為APPLICATION.JNLP或APPLICATION_TEMPLATE.JNLP是根據您的配置文件自動生成的。
注3:開發和測試這種方法需要一天半的時間,希望它能讓你的生活更輕松;)
下面是兩種類型的JNLP簽名的一些pom.xml部分。
A)用於APPLICATION.JNLP生成:
<project ....>
...
<build>
<plugins>
<plugin>
<!-- Step 1) your obvious configuration, also with signing,
assume that generated jnlp file has name: launch.jnlp -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-jnlp-and-sign-libs</id>
<phase>generate-resources</phase>
<goals>
<goal>jnlp-inline</goal>
</goals>
...
</execution>
</executions>
...
</plugin>
<plugin>
<!-- Step 2) copy & rename of jnlp to APPLICATION_JNLP in main.jar -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>copy-jnlp-template</id>
<goals>
<goal>copy</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<files>
<file>
<source>${project.build.directory}/jnlp/launch.jnlp</source>
<outputDirectory>${project.build.directory}/jnlp/main.jar/JNLP-INF</outputDirectory>
<destName>APPLICATION.JNLP</destName>
</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Step 3) repeat signing of main.jar -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>sign</id>
<phase>prepare-package</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<archiveDirectory>${project.build.directory}/jnlp</archiveDirectory>
<includes>
<include>main.jar</include>
</includes>
<keystore>...</keystore>
<storepass>...</storepass>
<alias>...</alias>
<verbose>true</verbose>
</configuration>
</plugin>
<plugin>
<!-- Step 4) custom packaging -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
...
<webResources>
<resource>
<directory>${project.build.directory}/jnlp</directory>
</resource>
...
</webResources>
...
</configuration>
</plugin>
</build>
</project>
B)對於APPLICATION_TEMPLATE.JNLP生成:
<project ....>
...
<build>
<plugins>
<plugin>
<!-- Step 1) your obvious configuration + added one new execution
for APPLICATION_TEMPLATE.jnlp file generation from template stored
in /templates/APPLICATION_TEMPLATE.jnlp dir -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<executions>
<execution>
<!-- This is new execution block, don't be afraid,
inspite of multiple executions
signing and manifest update is performed only once -->
<id>generate-jnlp-template-for-signing</id>
<phase>generate-resources</phase>
<goals>
<goal>jnlp-inline</goal>
</goals>
<configuration>
<jnlp>
<inputTemplateResourcePath>${project.basedir}/templates
</inputTemplateResourcePath>
<inputTemplate>APPLICATION_TEMPLATE.jnlp</inputTemplate>
<outputFile>APPLICATION_TEMPLATE.jnlp</outputFile>
<mainClass>...</mainClass>
</jnlp>
</configuration>
</execution>
<execution>
<id>generate-jnlp-and-sign-libs</id>
<phase>generate-resources</phase>
<goals>
<goal>jnlp-inline</goal>
</goals>
<configuration>
<jnlp>
<!-- JNLP settings from your obvious configuration -->
...
</jnlp>
</configuration>
...
</execution>
</executions>
...
</plugin>
<plugin>
<!-- Step 2) move to APPLICATION_TEMPLATE from /target/jnlp
to target/jnlp/main.jar/JNLP-INF dir -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>move-jnlp-template</id>
<goals>
<goal>move</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<from>${project.build.directory}/jnlp/APPLICATION_TEMPLATE.jnlp
</from>
<to>${project.build.directory}/jnlp/lib/main.jar/JNLP-INF/APPLICATION_TEMPLATE.jnlp
</to>
</configuration>
</execution>
</executions>
</plugin>
<!-- Steps 3) and 4) are same as in previous code block -->
</build>
</project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.