简体   繁体   English

Java从代码授予许可

[英]Java granting permission from code

I am currently setting a policy file using: 我当前正在使用以下策略文件:

policyURL =cl.getResource("res/policy/abc.policy");
System.out.println(policyURL.toString());
System.setProperty("java.security.policy", policyURL.toString());

The problem is that the file interferes with other running applications. 问题在于该文件干扰了其他正在运行的应用程序。

Is it possible to grant a permission from code and remove it when the application stops? 是否可以从代码中授予权限并在应用程序停止时将其删除? I don't want to modify the java.policy from ProgramFiles. 我不想从ProgramFiles修改java.policy。

Can't you set it on the JVM through the following properties: 您不能通过以下属性在JVM上进行设置:

java -Djava.security.manager -Djava.security.policy=res/policy/abc.policy

I would suspect this would not impact other running applications. 我怀疑这不会影响其他正在运行的应用程序。

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

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