简体   繁体   English

发出将库负载授予Java代码的问题

[英]Issue granting library load to Java code

I'm using the Java security Manager with my app. 我在我的应用程序中使用Java安全管理器。 I'm going through granting permissions, and I came across one which I can't seem the grant. 我正在经历授予权限,并且遇到了一个似乎无法授予的权限。 It's permission to load a library. 允许加载库。 It's a java *.jar library in the $JAVA_HOME/lib/ext directory. 这是$ JAVA_HOME / lib / ext目录中的java * .jar库。

at com.theatsgroup.startup.startup_managers.startup(startup_managers.jav
a:98)
at com.theatsgroup.startup.app_startup.main(app_startup.java:357)
Caused by: java.security.AccessControlException: access denied ("java.lang.Runti
mePermission" "loadLibrary.sunec")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkLink(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)

My grant file is as follows: 我的授权文件如下:

grant codeBase "file:../bin/atsapp.jar" {
permission java.lang.RuntimePermission "loadLibrary.sunec";
};

Below is how I am invoking my Java app: 以下是我调用Java应用程序的方式:

java -Djava.security.manager -Djava.security.policy==..\cfg\atsapp.security.poli
cy -jar atsapp.jar

Any ideas? 有任何想法吗?

Thanks, 谢谢,

--Justin -贾斯汀

Since you are using "==", you are overriding the "default" permissions for the jvm. 由于您使用的是“ ==”,因此您将覆盖jvm的“默认”权限。 there is one important default grant which you most likely will need to replicate in your policy file in order to get the jvm to work. 有一项重要的默认授予,您很可能需要将其复制到策略文件中才能使jvm正常工作。 this permission grants all the extension libraries installed as part of the jvm the permissions they need to do all the "internal" stuff. 此权限授予作为jvm一部分安装的所有扩展库的权限,它们需要执行所有“内部”操作。 not sure why this isn't builtin, cause the jvm can't do much without this. 不知道为什么这不是内置的,因为没有这个,jvm无法做很多事情。

grant codeBase "file:${{java.ext.dirs}}/*" {
  permission java.security.AllPermission;
};

this is from the beginning of the "lib/security/java.policy" file installed with the jre. 这是从与jre一起安装的“ lib / security / java.policy”文件的开头开始的。 you might want to investigate the rest of this file to see if there are other important, basic permissions you might need. 您可能需要研究此文件的其余部分,以查看是否还需要其他重要的基本权限。

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

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