简体   繁体   English

如何对Java Applet进行签名并设置权限以读取系统属性,例如客户端的登录用户

[英]How to sign a java applet and setting permissions to read system properties such as the logged on user of a client

Could someone please help me with how to sign an applet and make it successfully get the value of System.getProperty("user.name"). 有人可以帮助我如何签名小程序并使它成功获取System.getProperty(“ user.name”)的值。 Shall have to edit user policy files and how do I do this. 必须编辑用户策略文件,以及如何执行此操作。 Thank you. 谢谢。

Don't mess with policy files, they are impractical for real world deployment. 不要搞乱策略文件,它们对于实际部署是不切实际的。

To get trust, digitally sign the code, and explain to the user why it is necessary for them to accept trusted code. 为了获得信任,请对代码进行数字签名,并向用户解释为什么他们必须接受可信代码。

There is a small archive at my JNLP API demos. 我的JNLP API演示文件中有一个小型存档。 page that contains code & build files for a trusted JWS app. 该页面包含用于受信任的JWS应用程序的代码和构建文件 . Import that into an IDE and see how it works. 将其导入IDE,并查看其工作原理。 It is for an application, but the same signing techniques apply to an applet. 它用于应用程序,但是相同的签名技术适用于applet。


And as a 'fall-back method' for Sun JREs on Windows, which will load the applet as sand-boxed if the user refuses the digitally signed code. 作为Windows上Sun JRE的“后备方法”,如果用户拒绝数字签名的代码,它将把小程序加载为沙盒。

Pop a JOptionPane.showInputDialog() that requests the user provide their own user name. 弹出一个JOptionPane.showInputDialog() ,要求用户提供自己的用户名。 Heck if they can't do that, it is doubtful they could be trusted to use an app. 如果他们不能做到这一点,那就值得怀疑他们是否可以使用应用程序。 that requires log-in. 需要登录。 ;) ;)

Even better for Windows (and *nix) machines that have the plug-in 2 architecture JRE, use the PeristenceService of the JNLP API of Java Web Start to serialize the user names and present a list at start up (probably in an editable JComboBox to accommodate new users). 对于具有插件2架构JRE的Windows(和* nix)计算机,甚至更好,请使用Java Web StartJNLP API的PeristenceService对用户名进行序列化,并在启动时显示一个列表(可能在可编辑的JComboBox以容纳新用户)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM