1.生成证书(cjzk.keystore)
keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 36000 -alias www.cjzk.com -keystore cjzk.keystore
2.导出证书(cjzk.cer)
keytool -exportcert -alias www.cjzk.com -keystore cjzk.keystore -file cjzk.cer -rfc
3.对jar包签名(还有ic.jar依赖的jar最好都签名一下,我用的JNA两个jar都签名了)
jarsigner -keystore cjzk.keystore ic.jar www.cjzk.com
jarsigner -keystore cjzk.keystore jna.jar www.cjzk.com
jarsigner -keystore cjzk.keystore platform.jar www.cjzk.com
4.创建ic.policy文件(内容如下)
keystore "file:cjzk.store", "JKS";
grantsignedBy "www.cjzk.com"
{
permission java.io.FilePermission"<<ALLFILES>>", "read";
};
5.注册ic.policy文件
打开C:\Program Files\Java\jre6\lib\security\java.security文件
找到如下两行
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy
在它们下面添加
policy.url.3=file:C:/Program Files/Java/jre6/lib/security/ic.policy
6.jsp中applet调用
<applet id="IcCardApplet" name="IcCardApplet" code="little.ant.pingtai.applet.IcCardApplet.class"
archive="little/ant/pingtai/applet/ic.jar,little/ant/pingtai/applet/jna.jar,little/ant/pingtai/applet/platform.jar" width="200px" height="200px">
</applet>
<script type="text/javascript">
function test(){
var str = window.document.IcCardApplet.hello();
alert(str);
}
</script>
<input type="button" value="测试Dll" οnclick="test()">
keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 36000 -alias www.cjzk.com -keystore cjzk.keystore
2.导出证书(cjzk.cer)
keytool -exportcert -alias www.cjzk.com -keystore cjzk.keystore -file cjzk.cer -rfc
3.对jar包签名(还有ic.jar依赖的jar最好都签名一下,我用的JNA两个jar都签名了)
jarsigner -keystore cjzk.keystore ic.jar www.cjzk.com
jarsigner -keystore cjzk.keystore jna.jar www.cjzk.com
jarsigner -keystore cjzk.keystore platform.jar www.cjzk.com
4.创建ic.policy文件(内容如下)
keystore "file:cjzk.store", "JKS";
grantsignedBy "www.cjzk.com"
{
permission java.io.FilePermission"<<ALLFILES>>", "read";
};
5.注册ic.policy文件
打开C:\Program Files\Java\jre6\lib\security\java.security文件
找到如下两行
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy
在它们下面添加
policy.url.3=file:C:/Program Files/Java/jre6/lib/security/ic.policy
6.jsp中applet调用
<applet id="IcCardApplet" name="IcCardApplet" code="little.ant.pingtai.applet.IcCardApplet.class"
archive="little/ant/pingtai/applet/ic.jar,little/ant/pingtai/applet/jna.jar,little/ant/pingtai/applet/platform.jar" width="200px" height="200px">
</applet>
<script type="text/javascript">
function test(){
var str = window.document.IcCardApplet.hello();
alert(str);
}
</script>
<input type="button" value="测试Dll" οnclick="test()">