close
寫一支 web start 的程式其實還蠻有意思的,感覺得安全性相當的高,但難免有點囉嗦及不方便。
事隔二年了,都快要忘了,來吧它整理一下吧--


1。server side
2。client side
3。client server 的溝通
4。描述檔 (jnlp)
5。sign-jar




1。server side --> see code
  • extends HttpServlet
  • overwrite doPost() & doGet()
  • 依 client 傳來的參數 ex: http://127.0.0.1/path/servlet.do?method=xxx 處理
  • 由 response.getOutputStream() 取得 stream, 寫回結果

2。client side (GUI 為 SWT)

  • abstract class BasicFramework (from :org.eclipseguide.swt) --> see code
  • myClass extends BasicFramework --> see code

3。client server 的溝通 --> see code
  • 透過幾個 inner class 與 web 溝通
  • 主要為 implements Listener & implements Runnable
  • client 傳參數給 web ,但 web 傳回的 stream 要再自行處理使成為 SomeSortofClass

4。描述檔 (jnlp)
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://10.2.2.219/vote" href="resolve.jnlp">
 <information>
  <title>Resolve Vote</title>
  <vendor>jihsun securities co.</vendor>
  <homepage href="index.html"/>
  <description>表決議案計票</description>
 </information>
  <security>
     <all-permissions/>
  </security>
 <resources>
  <j2se version="1.4"/>
  <jar href="vote.jar"/>
  <nativelib href="swt-lib.jar"/>
 </resources>
 <resources os="Windows">  
     <jar href="swt.jar"/>
     <jar href="pg74.215.jdbc3.jar"/>
     <jar href="servlet-api.jar"/>
     <jar href="struts.jar"/>
 </resources>
 <resources os="Linux">  
     <jar href="swt-linux.jar"/>
     <jar href="swt-pi.jar"/>     
     <jar href="pg74.215.jdbc3.jar"/>
     <jar href="servlet-api.jar"/>
     <jar href="struts.jar"/>
 </resources>
 <application-desc main-class="org.eclipseguide.swt.Resolve"/>
</jnlp>

ps. 來源 ip 很重要,當產生 sign-jar 時會加入 keystore 中,當 web 的 ip 更新時 web-start 便會不能做用,這應該是安全上的考量。

5。sign-jar
<target name="sign-jars" depends="package-swtlib">
    <echo level="info">Signing JARS...</echo>
    <signjar jar="${dist.dir}/swt-lib.jar" keystore="${keystore}" alias="myself" storepass="key"/>
    <signjar jar="${dist.dir}/${myname}.jar" keystore="${keystore}" alias="myself" storepass="key"/>
     
    <copy file="${eclipse.dir}/windows/swt.jar" todir="${dist.dir}"/>
    <signjar jar="${dist.dir}/swt.jar" keystore="${keystore}" alias="myself" storepass="key"/>
    
    <copy file="${eclipse.dir}/unix/swt-linux.jar" todir="${dist.dir}"/>
    <signjar jar="${dist.dir}/swt-linux.jar" keystore="${keystore}" alias="myself" storepass="key"/>
    
    <copy file="${eclipse.dir}/unix/swt-pi.jar" todir="${dist.dir}"/>
    <signjar jar="${dist.dir}/swt-pi.jar" keystore="${keystore}" alias="myself" storepass="key"/>
 
    <signjar jar="${dist.dir}/pg74.215.jdbc3.jar" keystore="${keystore}" alias="myself" storepass="key"/>
    <signjar jar="${dist.dir}/servlet-api.jar" keystore="${keystore}" alias="myself" storepass="key"/>
    <signjar jar="${dist.dir}/struts.jar" keystore="${keystore}" alias="myself" storepass="key"/>
</target>
 
arrow
arrow
    全站熱搜

    identical 發表在 痞客邦 留言(0) 人氣()