java

位置:IT落伍者 >> java >> 浏览文章

Ant实战之Jar文件数字签名的制作


发布日期:2019年09月05日
 
Ant实战之Jar文件数字签名的制作

buildproperties

==================================

#public info

module = test

JAVA_HOME = C:\\jsdk_

keystore = Yoinnstore

# 别名

alias = Yoinn

# keystore密码

storepass = password

# 主密码

keypass = password

# 证书文件名

cerfile = NeuLioncer

# dname info

# dname {CN= OU= O= L= ST= C=}

# 名字与姓氏

dnameCN = name

# 组织单位名称

dnameOU = organizationUnitName

# 组织名称

dnameO = organizationName

# 所在的城市或区域名称

dnameL = DL

# 所在的州或省份名称

dnameST = LN

# 该单位的两字母国家代码

dnameC = CN

# about keytool

keytool = keytoolexe

keytoolhome = ${JAVA_HOME}/bin

# about jarsigner

jarsigner = jarsignerexe

jarsignerhome = ${JAVA_HOME}/bin

buildxml

================================

<! Copyright (c) by Yoinn All Rights Reserved >

<project name=JarSignerBuilder default=jarsigner basedir=>

<! set global properties for this build >

<property file=buildproperties />

<property name=dist value=/dist />

<property name=deploydir value=${basedir} />

<! ********************************************************* >

<! dname {CN= OU= O= L= ST= C=} ?>

<!名字与姓氏>

<property name=commonName value=${dnameCN} />

<! 组织单位名称 >

<property name=organizationUnit value=${dnameOU} />

<! 组织名称 >

<property name=organizationName value=${dnameO} />

<! 所在的城市或区域名称 >

<property name=localityName value=${dnameL} />

<! 所在的州或省份名称 >

<property name=stateName value=${dnameST} />

<! 该单位的两字母国家代码 >

<property name=country value=${dnameC} />

<property name=dname value=CN=${commonName}OU=${organizationUnit}O=${organizationName}L=${localityName}ST=${stateName}C=${country} />

<! ********************************************************* >

<target name=init>

<mkdir dir=${dist} />

</target>

<target name=keytool depends=undeploy>

<echo message=keytool />

<echo message=dname = { ${dname} } />

<exec dir=${deploydir} executable=${keytoolhome}/${keytool} os=Windows >

<arg line=genkey />

<arg line=dname ${dname} />

<arg line=keystore ${keystore} />

<arg line=alias ${alias} />

<arg line=storepass ${storepass} />

<arg line=keypass ${keypass} />

</exec>

<exec dir=${deploydir} executable=${keytoolhome}/${keytool} os=Windows >

<arg line=export />

<arg line=keystore ${keystore} />

<arg line=storepass ${storepass} />

<arg line=alias ${alias} />

<arg line=file ${cerfile} />

</exec>

<echo message=keytooldone />

</target>

<target name=jarsigner depends=keytool>

<! Sign the jar >

<echo message=jarsigner />

<exec dir=${deploydir} executable=${jarsignerhome}/${jarsigner} os=Windows >

<arg line=keystore ${keystore} />

<arg line=storepass ${storepass} />

<arg line=${module}jar />

<arg line=${alias} />

</exec>

<echo message=jarsignerdone />

<delete file=${keystore} />

<delete file=${cerfile} />

<delete dir=${dist} />

</target>

<target name=undeploy>

<delete file=${keystore} />

<delete file=${cerfile} />

</target>

</project>

上一篇:Spring Security学习总结一

下一篇:Eclipse 3.1中用注释单元测试框架(图)