java 库中的权限
我有一个使用 JNA 库(由 Maven 管理)的程序。程序本身拥有所有权限(我遇到了FilePermission
错误,更改了策略文件,现在我可以随意读/写)。但是,当我使用 JNA 时,出现以下错误:
Exception in thread "main" java.security.AccessControlException: access denied (java.util.PropertyPermission jna.encoding read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
at java.lang.System.getProperty(System.java:669)
at com.sun.jna.Pointer.getString(Pointer.java:682)
at com.sun.jna.Function.invokeString(Function.java:598)
at com.sun.jna.Function.invoke(Function.java:356)
at com.sun.jna.Function.invoke(Function.java:276)
at com.sun.jna.Library$Handler.invoke(Library.java:216)
我的策略文件是(最后的授权显然不起作用):
grant codeBase "file:/home/tm/workspace/-" {
permission java.security.AllPermission;
};
grant codeBase "file:/home/tm/.m2/repository/net/java/dev/jna/jna/-" {
permission java.util.PropertyPermission "jna.encoding", "read";
};
我正在 eclipse 中从工作区目录中的项目运行该程序。有什么想法我需要将哪些权限分配给什么?
I have a program that uses the JNA library (managed with maven). The program itself has all permissions (I got a FilePermission
error, changed the policy file, and now I can read/write at will). However, when I use JNA, I get the following error:
Exception in thread "main" java.security.AccessControlException: access denied (java.util.PropertyPermission jna.encoding read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
at java.lang.System.getProperty(System.java:669)
at com.sun.jna.Pointer.getString(Pointer.java:682)
at com.sun.jna.Function.invokeString(Function.java:598)
at com.sun.jna.Function.invoke(Function.java:356)
at com.sun.jna.Function.invoke(Function.java:276)
at com.sun.jna.Library$Handler.invoke(Library.java:216)
My policy file is (that last grant obvioulsy doesn't work):
grant codeBase "file:/home/tm/workspace/-" {
permission java.security.AllPermission;
};
grant codeBase "file:/home/tm/.m2/repository/net/java/dev/jna/jna/-" {
permission java.util.PropertyPermission "jna.encoding", "read";
};
I'm running the program in eclipse, from a project in the workspace directory. Any ideas which permissions I need to assign to what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为它是一个分布式程序,所以我有 RMISecurityManager。当我删除对 setSecurityManager 的所有调用时,问题就停止了。我认为 System.setSecurityManager(new RMISecurityManager()); 没有获取策略文件。
I had
RMISecurityManager
s in place since it was a distributed program. When I removed all calls tosetSecurityManager
, the problem stopped. I presumeSystem.setSecurityManager(new RMISecurityManager());
doesn't pick up the policy file.