[英]Why access denied (java.lang.RuntimePermission setSecurityManager) in my java Applet?
I had an existing very very old java applet which use:我有一个现有的非常非常旧的 java 小程序,它使用:
<dependency>
<groupId>com.al6</groupId>
<artifactId>rxtx</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>java</groupId>
<artifactId>plugin</artifactId>
<version>1.6.12</version>
</dependency>
In the lib directory of the project there is:在项目的lib目录下有:
RXTXcomm.jar RXTXcomm.jar
RXTXcomm.jar.sig RXTXcomm.jar.sig
rxtxParallel.dll rxtxParallel.dll
rxtxSerial.dll rxtxSerial.dll
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>.keyticket</keystore>
<alias>ticket</alias>
<storepass>ticket</storepass>
<keypass>katana</keypass>
<!--
signedjar>${project.build.directory}/signed/${project.build.finalName}.jar</signedjar
-->
<verify>false</verify>
</configuration>
</plugin>
The project runs well on a java 1.6 environment, builded by a java 1.6 server.项目在java 1.6环境下运行良好,由java 1.6服务器搭建。
But if I build it on a new java 1.8 server, and runs with java 1.8, I have a lots of major.minor errors because some old sub-librairies are used by this project.但是,如果我在新的 java 1.8 服务器上构建它,并使用 java 1.8 运行,我会遇到很多 major.minor 错误,因为该项目使用了一些旧的子库。
So to avoid problems, I keep this in the pom.xml:所以为了避免出现问题,我将其保存在 pom.xml 中:
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
The project compile and runs, but I had a:该项目编译并运行,但我有一个:
access denied java.lang.RuntimePermission setSecurityManager)访问被拒绝 java.lang.RuntimePermission setSecurityManager)
I supposed my jar is not signed.我以为我的 jar 没有签名。 I see that the existing ".keyticket" used to sign seems to not use a valid level of sign for java 1.8.
我看到用于签名的现有“.keyticket”似乎没有使用 java 1.8 的有效签名级别。 So I modify java.security on the build machine to accept the old sign process.
所以我在构建机器上修改 java.security 以接受旧的签名过程。 The jar seems signed:
jar 似乎已签名:
Finally, I generate a new certificate for my jar using:最后,我使用以下方法为我的 jar 生成一个新证书:
/opt/jdk/bin/keytool -genkey -keyalg RSA -alias myFirstKey -keystore myKeystore -validity 360
And I add the new file in the maven task to sign it:我在 maven 任务中添加新文件以对其进行签名:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>myKeystore</keystore>
<alias>myFirstKey</alias>
<storepass>keypass</storepass>
<keypass>keypass</keypass>
<!--
signedjar>${project.build.directory}/signed/${project.build.finalName}.jar</signedjar
-->
<verify>false</verify>
</configuration>
</plugin>
And it works perfectly now.现在它工作得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.