1.在cmd中用keytool建立公鑰和密鑰,生成簽名憑証
keytool -genkey -keystore 文件名.store -alias 别名(記住密碼) -validity (days)
Ex: keytool -genkey -keystore test.store -alias testkey -validity 7200 (私(密)key)
2.執行jarsigner工具,並指定jar檔和私密金鑰的別名
jarsigner -keystore 密鑰名 JAR名 别名
ex: jarsigner -keystore teststore testclient.jar testkey
3.產生certs.store並把testkey憑證加入
keytool -export -keystore test.store -alias testkey -file testkey.cert
keytool -import -keystore cert.store -alias testkey -file testkey.cert
4. 必須產生policy授與權限給所有以該金鑰庫中簽章的applet
在policy檔中加入
keystore "keystoreURL","keystore類型"
e.g
keystore "file:cert.store","JKS"
接著在policy中加入
grant
{
permission java.io.FilePermission "","";
};
5.測試時,確定金鑰庫 policy 和jar全在同一目錄下
qppletviewer -J-Djava.security.policy=applets.policy TestApplet.html
application -Djava.security.policy=applets.policy TestApplet.html
https://code.google.com/p/java-simple-serial-connector/wiki/jSSC_Terminal