數位簽章(java)

來源:互聯網
上載者:User

 

數位簽章

用Applet寫的java小程式如果沒有經過簽名,那麼訪問用戶端程式下載後會受到安全限制;怎樣對java小程式簽名受到很多人的關注,網上也有這些方面可供參考的文檔,但都不是完整,在這裡我給出一份可具體操作的文檔,希望能給大家一些協助。

 

情境:test.jar:內含待簽名的java小程式

結果:簽名後,用戶端能自動下載java小程式,且java小程式能訪問用戶端的任何資源

 

步驟:

(1)    將java小程式打包

jar cvf test.jar test.class

(2)    產生名為chinani.store的密鑰庫,別名為chinani

keytool -genkey -keystore chinani.store -alias chinani

密碼:123456 (根據需要自己輸入)

以下根據需要輸入,最後確認:y

(3)    匯出chinani.cer數位憑證

keytool -export -keystore chinani.store -alias chinani -file chinani.cer

密碼:123456 (根據需要自己輸入)

(4)    對test.jar檔案進行簽名

jarsigner -keystore chinani.store  test.jar chinani

密碼:123456 (根據需要自己輸入)

 

最後寫一個html檔案,運行此檔案即可自動下載安裝運行java小程式

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 1</title>

</head>

<body>

<!--能自動下載jre包-->

<OBJECT

    classid="clsid:CAFEEFAC-0014-0000-0000-ABCDEFFEDCBA"

    WIDTH = 300 HEIGHT = 300 

    codebase="jinstall-1_4_0-win.cab#Version=1,4,0,0">

    <PARAM NAME = CODE VALUE = "test.class" >

       <PARAM NAME = ARCHIVE VALUE = "test.jar" >

    <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4">

       <PARAM NAME = "scriptable" VALUE = "false" >

</object>

</body>

</html>

 

 


<

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.