1

I asked a question on here once before and got some great help and advice from a lot of knowledgeable people so I thought I'd try this again with another programming issue I'm having.

Here is the basic problem. I've created a small Java applet that takes four images and combines them into one large image. To be more specific, I combine four images into one large image that will fold up to be a greeting card when printed out. Everything works just fine, but I'm going to be embedding the applet on my website and so I'll have users select the four images they want from a list of images on my website, and then with their selections I'll create the large image.

Now here's the trouble... when I create the large image I want the user to be able to download it. Is it necessary to create a signed applet? And if so, how do I go about signing my applet? Or is it somehow possible for the applet to just display the image in such a way so the user can just right-click the image and save it to their file system. Any advice/suggestions would be much appreciated!!

4

3 回答 3

3

如果图像是从下载小程序类本身的同一位置加载的,则无需对小程序进行签名。但是,从未签名的小程序本地保存图像会出现问题。对于该功能,您需要对小程序进行签名。

或者,对于在 Web 浏览器中运行的小程序,可以使用以下命令在单独的浏览器框架中显示图像:

applet.getAppletContext().showDocument(imageURL, frameTarget);

从此页面/框架中,可以使用 Javascript 将图像保存在本地

于 2013-01-18T00:53:29.997 回答
1

根据 Java 和浏览器版本,我看到 3 个选项:

  1. 对 Jar 进行数字签名并鼓励最终用户信任数字签名的代码。
  2. Jar 应用程序,使用Java Web Start部署它并使用 JNLP API 服务保存生成的图像。这可以使用自 Java 1.2 起的自由浮动小程序或自 1.6.0_10+ 起的嵌入式小程序来完成。这是一个演示。的文件服务GIFanim还提供了一个嵌入式小程序,该小程序使用保存动画 GIF 的服务。
  3. 将图像编码为Base64 URL以将其直接显示在网页中。这需要更新的浏览器,较旧的浏览器对图像大小设置了 32Kb 的限制。 J2SE 最近只添加了一个方法,可以为我们进行转换。看DatatypeConverter.printBase64Binary(byte[])
于 2013-01-18T02:03:01.783 回答
0

要将文件写入文件系统,需要对小程序进行签名。

然而,自签名小程序非常容易,除非您的用户非常谨慎,否则自签名将起作用。

按照这些说明签署小程序。PS这些说明适用于linux设置。您可能需要在 windows 中设置环境变量。

罐子签名链接

于 2013-01-18T01:07:46.577 回答