Java 数字签名(Digital Signature)的批处理文件制作

Java 数字签名(Digital Signature)的批处理文件制作


制作以下5个批处理文件:

 

set.cmd

set JDK_BIN=E:/"Program Files"/Java/jdk1.6.0_24/bin
set KEY_FOLDER=E:/DigitalSignature


key.cmd

call set.cmd
%JDK_BIN%/keytool -genkey -keystore %KEY_FOLDER%/cuckoo.keystore -alias cuckoo < KEY_ANSWER.lst
%JDK_BIN%/keytool -selfcert -keystore %KEY_FOLDER%/cuckoo.keystore -alias cuckoo -validity 1000 < KEY_PWD.lst
%JDK_BIN%/keytool -export -keystore %KEY_FOLDER%/cuckoo.keystore -alias cuckoo -file %KEY_FOLDER%/cuckoo.cer <
KEY_PWD.lst
KEY_ANSWER.lst KEY_PWD.lst 为输入重定向文件,从文本文件里读每行来回答命令行的问题,换行回车作为提交。 -validity 后面跟签名有效期,以天为单位,默认是半年

例: KEY_ANSWER.lst

password
password
Ren Jian
The CUCKOO Workgroup
Sun Yat-sen University
Guangzhou
Guangdong
CN

(后面加两个换行)

KEY_PWD.lst

password

(换行)


selfsign.cmd

%JDK_BIN%/jarsigner -keystore %KEY_FOLDER%/cuckoo.keystore %1 cuckoo < KEY_PWD.lst


sign.cmd

call set.cmd
call selfsign.cmd %1


batchsign.cmd

call set.cmd
for %%N in (%1/*.jar) do call selfsign.cmd %%N


使用说明:

1. 在set.cmd中设置JDK_BIN文件夹位置和存放Key的文件夹位置

2. 运行key.cmd产生key

3. 单个文件签名
    命令: sign.cmd [jar]

4. 对指定文件夹下所有文件批量签名:
    命令: batchsign.cmd [jar_folder]


你可能感兴趣的:(02.Java)