1

按照本教程,我在第 7 步,我不明白该怎么做PolicyTool。我需要它来在我的应用程序中分配我的小程序,因为当我运行我的小程序时,我收到了SecurityException以下错误消息:

Could not open file policy C:\Program Files\Java\jdk1.7.0_05\bin\raystore: 
sun.security.provider.PolicyParser$ParsingException line 1: expected [;] found[pípí]
4

1 回答 1

2

这是一个文件,其内容显然会导致问题:C:\Program Files\Java\jdk1.7.0_05\bin\raystore

生成密钥时

keytool -import -alias company -file 
        CompanyCer.cer -keystore 
    raystore -storepass abcdefgh

仔细检查它是否确实在同一位置生成了一个文件。

然后,

keystore "/home/ray/raystore"; // make sure you reference the path to the key you generated in the previous step

// A sample policy file that lets a program 
// create demo.ini in user's home directory
// Satya N Dodda

grant SignedBy "company" {
  permission java.util.PropertyPermission 
    "user.home", "read";
  permission java.io.FilePermission 
    "${user.home}/demo.ini", "write";
};

编辑:

生成密钥

keytool -genkey -keystore mykeys -storepass abc123 

标志罐

jarsigner -keystore mykeys -storepass abc123 app.jar johndoe

http://docs.oracle.com/javase/tutorial/deployment/jar/signing.html

于 2012-07-16T18:50:33.733 回答