java permissions in libraries
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 d开发者_Python百科enied (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?
I had RMISecurityManager
s in place since it was a distributed program. When I removed all calls to setSecurityManager
, the problem stopped. I presume System.setSecurityManager(new RMISecurityManager());
doesn't pick up the policy file.
精彩评论