Java permissions in Libraries
•
Java
I have a program using JNA Library (managed by Maven) The program itself has all permissions (I received a filepermission error and changed the policy file. Now I can read / write at will) However, when I use JNA, I receive 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 (last granted to obvioulsy does not 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 a program in eclipse from a project in the workspace directory What permissions do I need to assign?
Solution
I have RMI security managers because it is a distributed program When I delete all calls to setsecuritymanager, the problem stops I assume system setSecurityManager(new RMISecurityManager()); Did not pick up the policy document
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码