https://github.com/threerings/getdown/wiki/Applet-Mode

——————————————————————————————————————————————————————————

如何以Applet模式运行Getdown。

以签名Applet模式运行Getdown,并下载和运行应用是可能的,这样可以提供一种”in the web browser“的体验。甚至可以让Getdown在同一个JVM(Getdown运行的JVM)中运行应用,允许应用占据Getdown窗口,这样可以提供一个非常像applet的体验。

Signing

因为Getdown必须以签名applet运行,这样它才有权限写入用户的文件系统并运行一个单独的JVM,所以你必须使用一个code signing certificate来签名getdown-client.jar文件。

Getdown是一个通用的启动机制,因此需要使用同样的签名来签Getdown的元数据,否则Getdown可以被任何人以你的签名运行任意程序,这是很糟糕的。

注意Getdown的签名必须是RSA,而不是DSA,用keytool生成签名时默认是DSA,确保传入-keyalg rsa参数。

Applet tag

以applet模式运行Getdown需要创建applet标签,包含基本的元数据,部分元数据会与getdown.txt文件中的重复,以允许applet启动更快一点,并提供更好的用户UI。

下面是applet标签的例子:

<object height="253" width="424" type="application/x-java-applet;version=1.5"
archive="http://myapp.com/client/getdown-client.jar">
<param name="archive" value="http://myapp.com/client/getdown-client.jar"/>
<param name="code" value="com.threerings.getdown.launcher.GetdownApplet"/>
<param name="appname" value="myapp"/>
<param name="appbase" value="http://myapp.com/client/"/>
<param name="bgimage" value="http://myapp.com/client//background.png"/>
<param name="errorbgimage" value="http://myapp.com/client/background_error.jpg"/>
<param name="ui.status" value="30, 60, 364, 80"/>
<param name="ui.status_text" value="FFEC48"/>
<div class="nojava">You must first install Java to play this game in your browser!</div>
</object>

大部分applet标签是标准的,包括属性width, height, type, archive, code等,Getdown特有的参数如下:

appname

用于决定应用数据被存储的目录名称的标识,随操作系统不同而不同

  • Windows Vista: %HOME%\AppData\LocalLow\myapp\
  • Windows XP, etc.: %HOME%\Application Data\myapp\
  • Mac OS: $HOME/Library/Application Support/myapp/
  • Linux: $HOME/.getdown/myapp/

appbase

与getdown.txt中的appbase相同,用于下载getdown.txt文件以获得所有其他的应用数据。

bgimage, errorbgimage

These should be fully qualified URLs that reference the same images in the ui.background and ui.error_background configuration values from the getdown.txt file. They are duplicated here so that the applet can immediately display a branded user interface without having to first download the getdown.txt file.

ui.status, ui.status_text

These should contain the same values as those specified in the getdown.txt file. These values are only used if there is a problem downloading the getdown.txt file, at which point Getdown needs to display feedback to the user and needs to know where on the errorbgimage to render that feedback.

jvmargN and appargN

You can augment the jvmarg and apparg configuration in getdown.txt with applet parameters (which can be dynamically generated when the user requests the page that contains the <applet> tag).

To do so, simply add jvmargN or appargN <param> tags with increasing values for N. For example:

<object ...>
<param name="jvmarg0" value="-Xmx256M"/>
<param name="jvmarg1" value="-Dsun.java2d.opengl=true"/>
<param name="apparg0" value="--username"/>
<param name="apparg1" value="someusername"/>
</object>

Note that the jvmarg and apparg configuration specified in the applet tag will appear after the jvmarg and apparg configuration from the getdown.txt file, on the command line.

Signature File

除了要对getdown-client.jar文件签名外,还必须为digest.txt生成签名文件,这可以在生成digest.txt的同时完成。很简单,提供你的Keystore的路径、密码、以及使用的key的别名给Ant的<digest>任务:

<taskdef name="digest" classname="com.threerings.getdown.tools.DigesterTask"
classpathref="getdown.classpath"/>
<property file="certificate.properties"/>
<digest appdir="${app_dir}" keystore="${sign.keystore}" storepass="${sign.storepass}"
alias="${sign.alias}"/>

就像你看到的一样,我们推荐你保存敏感的元数据信息到单独的属性文件中,以确保它不会被提交到版本管理系统中,或者泄露给外部的团体,certificate.properties包含下面的数据

sign.keystore = /path/to/keystore.dat
sign.storepass = s3cr3t
sign.alias = mycompanyalias

这样将会生成digest.txt.sig文件,必须放在digest.txt文件同目录。applet将会下载该文件来校验digest.txt文件的内容,如果不能找到digest.txt.sig文件,或者签名不匹配,applet将拒绝运行程序。

因为digest.txt包含了组成应用的所有代码和资源的加密散列值,这意味着别人不可能使用你签名过的getdown-client.jar去做任何除运行你签名过的应用的其他事情。

注意每次更新应用后都必须生成新的digest.txt.sig文件,以及新的digest.txt文件。

Signing getdown-client.jar

Signing the getdown-client.jar file is easily accomplished using the signjar Ant task (which is included with the standard Ant distribution). Here is an example:

<property file="certificate.properties"/>
<signjar keystore="${sign.keystore}" alias="${sign.alias}" storepass="${sign.storepass}">
<fileset dir="${app_dir}" includes="getdown-client.jar"/>
</signjar>

We assume you have a certificate.properties file configured as described above.

Ensuring User Has Java Plugin

Running Getdown as an applet is predicated on the user having at least Java 1.5 installed on their computer and properly configured as a browser plugin. The applet tag we have shown above should trigger the process of installing the Java plugin if the user does not already have it installed.

Note that we only require JDK 1.5 in our <object> tag above, you may wish to require JDK 1.6, or you may want to use Getdown's support for running intself in a 1.5 JDK and then automatically downloading and installing a 1.6 (or newer) JDK as a part of the application download process. See the documentation on getdown.txt for details.

Applet Mode的更多相关文章

  1. 《java小应用程序(Applet)和java应用程序(Application)分别编写的简单计算器》

    Application和Java Applet的区别.Java语言是一种半编译半解释的语言.Java的用户程序分为两类:Java Application和Java Applet.这两类程序在组成结构和 ...

  2. applet示例 WelcomeApplet.java <Core Java>

    import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Font; import java.awt.Grap ...

  3. Java—Applet

    1  Applet的定义 Applet是Java语言编写的,无法独立运行,但可以嵌入到网页中执行.它扩展了传统的编程结构和方法,可以通过互联网发布到任何具有Java编译环境浏览器的个体计算机上. 如下 ...

  4. The differences between Java application and Java applet

    在Java语言中,能够独立运行的程序称为Java应用程序(Application).Java语言还有另外一种程序--Applet程序.Applet程序(也称Java小程序)是运行于各种网页文件中,用于 ...

  5. Oracle EBS Java Applet报错:找不到类

    Oracle EBS Home Page可以打开,但是无法打开EBS的Form,查看Java控制台,有错误报出. java控制台报错,如下: Java Plug-in 1.6.0_07 使用 JRE ...

  6. Java小应用程序Applet,画布上新建按钮和文本

    <pre name="code" class="java">package com.hx; import java.applet.*; import ...

  7. atitit. 浏览器插件 控件 applet 的部署,签名总结 浏览器 插件 控件 的签名安全机制o9o

    atitit. 浏览器插件 控件   applet 的部署,签名总结 浏览器 插件 控件 的签名安全机制o9o 1. 服务器部署签名 1 2. 签名流程::生成密钥..导出cert正书,签名 1 3. ...

  8. atitit. applet 浏览器插件 控件 的环境,开发,提示总结o9o

    atitit. applet 浏览器插件 控件 的环境,开发,提示总结o9o 1. 建立applet:: 1 2. Applet 码 1 3. Applet (awt)跟japplet (swing) ...

  9. Java Applet与Java Application的区别

    转自:http://www.educity.cn/java/500609.html 在Java语言中,能够独立运行的程序称为Java应用程序(Application).Java语言还有另外一种程序-- ...

  10. jdk与eclipse版本问题解决applet的启动

    今天在中韩,遇到一个保全项目,需要调用applet显示打印批单,结果IE一直显示安全设置问题,去java程序的安全里面想下调等级,不好调,所以想改个jdk_32试试. 版本环境 原先是eclipse_ ...

随机推荐

  1. wap站、手机APP 接入支付宝、微信、银联支付。

    一.wap站 ①.支付宝接入 1.开发前准备:申请一个通过实名认证的企业支付宝账号,并申请开通手机WAP支付功能. 2.流程 参数准备: 企业支付宝账号的PID(也叫ParnerID)和KEY,如果使 ...

  2. 史上最简单的ButterKnife配置教程

    网上的教程感觉都是抄来抄去,没一个靠谱的 还是自己丰衣足食搞一个ButterKnife配置教程吧.. 我的Android Studio版本是3.3. 1.dependencies中添加依赖 imple ...

  3. 利用ARP和ICMP协议解释ping命令

    一.MTU 以太网和IEEE 802.3对数据帧的长度都有限制,其最大值分别是1500和1492字节,将这个限制称作最大传输单元(MTU,Maximum Transmission Unit).如果IP ...

  4. python解压压缩包的几种方法

    这里讨论使用Python解压例如以下五种压缩文件: .gz .tar  .tgz .zip .rar 简单介绍 gz: 即gzip.通常仅仅能压缩一个文件.与tar结合起来就能够实现先打包,再压缩. ...

  5. 杭电 1800 Flying to the Mars(贪心)

    http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Oth ...

  6. unity5 静态和动态cubmap

    一,静态cubemap: asserts窗口 右键->Create->Legacy->Cubemap,新建一个cubemap,命名为cubeMap,然后为其各面指定贴图,如图: 需要 ...

  7. 子墨庖丁Android的ActionBar源代码分析 (一)实例化

    假设你从事过Androidclient开发,相信你对ActionBar这套框架并不陌生,或者说你并不了解它,可是你应该时不时的要跟它打交道.抛开ActionBar的实现不说,ActionBar实际上是 ...

  8. bash脚本输入密码不回显问题的解决方法

    编写一个bash脚本时,需要用户输入一个密码,方可继续后续流程,但是又要保证用户输入的密码不会被别人看到,因此排除了通过参数将密码传入脚本的方案 不绕圈子,揭晓答案:设置终端状态为“字符不回显”(如果 ...

  9. Python2 获取两日期之间的每一天

    import datetime def getEveryDay(begin_date,end_date): date_list = [] begin_date = datetime.datetime. ...

  10. Python的sys.argv使用说明 通过终端写入环境变量

    刚开始使用这个参数的时候,很不明白其含义.网上搜索很多都是贴的官网上面的一则实例,说看懂,就明白.可是,我看不懂.现在在回头看这个参数使用,并不是很麻烦. 举几个小例子就明白了. 创建一个脚本,内容如 ...