Linux 无法使 RMI 安全策略生效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3677153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Having Trouble Getting RMI Security Policy Working
提问by Ultimate Gobblement
I'm having trouble getting RMI security policies working. I have a .policy file on both the server and client, each of which is running a SecurityManager.
我在使用 RMI 安全策略时遇到了麻烦。我在服务器和客户端上都有一个 .policy 文件,每个文件都运行一个 SecurityManager。
When I try and run the client its failing. My policy file grants everything atm. Heres the content:
当我尝试运行客户端时,它失败了。我的政策文件授予一切 atm。内容如下:
grant { permission java.security.AllPermission };
I have the file client.policy in the root directory of my JAR file (I tried running it with the policy file outside the jar too). Then I run the client with this:
我的 JAR 文件的根目录中有文件 client.policy(我也尝试使用 jar 外的策略文件运行它)。然后我用这个运行客户端:
java -jar PagePlanner.jar -Djava.security.policy=client.policy -Djava.rmi.codebase=http://192.168.0.88:2077/home/me/NetbeansProjects/PageServer/dist/PageServer.jar -Djava.security.debug=access
Specifying my policy file and the path to my code base. I'm not sure if either of these are correct. I also tried setting the debug switch as I read somewhere it should give me extra info about whats going wrong, but it does not seem to make a difference.Heres the output when I run the client:
指定我的策略文件和我的代码库的路径。我不确定这些是否正确。我还尝试设置调试开关,因为我在某处阅读它应该给我关于出了什么问题的额外信息,但它似乎没有什么区别。 这是我运行客户端时的输出:
Exception in thread "main" java.security.AccessControlException: access denied (java.awt.AWTPermission setWindowAlwaysOnTop)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.awt.Window.setAlwaysOnTop(Window.java:2038)
at gui.LoginForm.<init>(LoginForm.java:59)
at main.Main.main(Main.java:21)
From which point the client just hangs. Any ideas what I'm doing wrong here? The policy setup on the server-side is pretty much the same. I can post the details if that helps.
从这一点上客户端就挂了。任何想法我在这里做错了什么?服务器端的策略设置几乎相同。如果有帮助,我可以发布详细信息。
Cheers.
干杯。
采纳答案by user207421
Run the client with -Djava.security.debug=access,failure. Most probably your .policy file isn't being found.
使用 -Djava.security.debug=access,failure 运行客户端。很可能没有找到您的 .policy 文件。
BTW you don't need to set the codebase at the client unless the client has its own implementations of abstract classes/interfaces and the server doesn't know about them. The codebase is normally only set at the server, so as to annotate classes that are downloaded to the client and the Registry.
顺便说一句,除非客户端有自己的抽象类/接口实现并且服务器不知道它们,否则您不需要在客户端设置代码库。代码库通常只在服务器上设置,以便对下载到客户端和注册表的类进行注释。