开发学院WEB开发Jsp Ant实战之Jar文件数字签名的制作 阅读

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>

Tags:Ant 实战 Jar

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接