一个 JApplet
是否可以使用 JFileChooser
,以便用户可以在硬盘驱动器上选择文件?或者这会违反Java applet安全性?(我假设正在使用默认安全设置。我不想要求我的用户授予我额外的权限。)
一个 JApplet
是否可以使用 JFileChooser
,以便用户可以在硬盘驱动器上选择文件?或者这会违反Java applet安全性?(我假设正在使用默认安全设置。我不想要求我的用户授予我额外的权限。)
这个帖子表明在使用JFileChooser
之前,您需要对applet进行数字签名。
Validating the origin of the applet code.
URL appletUrl = MyApplet.class.getProtectionDomain().getCodeSource().getLocation();
if(appletUrl.toString().equalsIgnoreCase(safeAppletUrl) == false)
return false;
Verifying the base URL from which the applet was run.
URL documentUrl = this.getDocumentBase();
if(documentUrl.toString().equalsIgnoreCase(safeDocumentUrl) == false)
return false;
你可能需要使用PrivilegedAction来读取用户硬盘上的任何内容。正如@mmyers所说,你还需要对你的小程序进行签名。
所以你的答案是肯定的,我以前做过这个,所以我知道它是可行的。