Ant实战之Jar文件数字签名的制作
2008-01-05 10:14:47 来源:WEB开发网核心提示:build.PRoperties==#public infomodule = testjava_HOME = C:\\j2sdk1.4.2_04keystore = Yoinn.store# 别名alias = Yoinn# keystore密码storepass = passWord# 主密码keypass = pa
build.PRoperties
==================================
#public info
module = test
java_HOME = C:\\j2sdk1.4.2_04
keystore = Yoinn.store
# 别名
alias = Yoinn
# keystore密码
storepass = passWord
# 主密码
keypass = password
# 证书文件名
cer.file = NeuLion.cer
# dname info
# dname {CN=1, OU=1, O=1, L=1, ST=1, C=1}
# 名字与姓氏
dname.CN = name
# 组织单位名称
dname.OU = organizationUnitName
# 组织名称
dname.O = organizationName
# 所在的城市或区域名称
dname.L = DL
# 所在的州或省份名称
dname.ST = LN
# 该单位的两字母国家代码
dname.C = CN
# about keytool
keytool = keytool.exe
keytool.home = ${JAVA_HOME}/bin
# about jarsigner
jarsigner = jarsigner.exe
jarsigner.home = ${JAVA_HOME}/bin
------------------------------------------------
build.xml
================================
<!-- Copyright (c) 2004 by Yoinn. All Rights Reserved. -->
<project name="JarSignerBuilder" default="jarsigner" basedir=".">
<!-- set global properties for this build -->
<property file="build.properties" />
<property name="dist" value="./dist" />
<property name="deploy.dir" value="${basedir}" />
<!-- ********************************************************* -->
<!-- dname {CN=1, OU=1, O=1, L=1, ST=1, C=1} ?-->
<!--名字与姓氏-->
<property name="commonName" value="${dname.CN}" />
<!-- 组织单位名称 -->
<property name="organizationUnit" value="${dname.OU}" />
<!-- 组织名称 -->
<property name="organizationName" value="${dname.O}" />
<!-- 所在的城市或区域名称 -->
<property name="localityName" value="${dname.L}" />
<!-- 所在的州或省份名称 -->
<property name="stateName" value="${dname.ST}" />
<!-- 该单位的两字母国家代码 -->
<property name="country" value="${dname.C}" />
<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="${deploy.dir}" executable="${keytool.home}/${keytool}" os="windows 2000">
<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="${deploy.dir}" executable="${keytool.home}/${keytool}" os="Windows 2000">
<arg line="-eXPort" />
<arg line="-keystore ${keystore}" />
<arg line="-storepass ${storepass}" />
<arg line="-alias ${alias}" />
<arg line="-file ${cer.file}" />
</exec>
<echo message="keytool...done." />
</target>
<target name="jarsigner" depends="keytool">
<!-- Sign the jar -->
<echo message="jarsigner..." />
<exec dir="${deploy.dir}" executable="${jarsigner.home}/${jarsigner}" os="Windows 2000">
<arg line="-keystore ${keystore}" />
<arg line="-storepass ${storepass}" />
<arg line="${module}.jar" />
<arg line="${alias}" />
</exec>
<echo message="jarsigner...done." />
<delete file="${keystore}" />
<delete file="${cer.file}" />
<delete dir="${dist}" />
</target>
<target name="undeploy">
<delete file="${keystore}" />
<delete file="${cer.file}" />
</target>
</project>
[]
- ››实战案例分析:高质量软文对网站百度排名的影响
- ››实战经验浅谈网站搬家后的优化工作
- ››实战Active Directory站点部署与管理,Active Dir...
- ››实战操作主机角色转移,Active Directory系列之十...
- ››实战经验:巧用微博推广淘宝网店
- ››实战iPhone GPS定位系统
- ››实战Linux环境配置DBD:Oracle模块
- ››JAR 文件揭密:探索 JAR 文件格式的强大功能
- ››实战DeviceIoControl系列之一:通过API访问设备驱...
- ››实战DeviceIoControl系列之二:获取软盘/硬盘/光盘...
- ››实战DeviceIoControl系列之三:制作磁盘镜像文件
- ››实战DeviceIoControl系列之四:获取硬盘的详细信息...
赞助商链接