如何配置 Java SecurityManager 以允许从给定文件读取所有属性

发布于 2024-08-01 19:33:26 字数 416 浏览 5 评论 0原文

我目前正在尝试为 Tomcat 上运行的 Nexus 存储库管理器创建一个策略文件。

Nexus 尝试读取文件 WEB-INF/plexus.properties (我已经授予了该文件的权限),并且似乎尝试从那里读取所有属性,但由于缺少以下权限而失败:

java.security.PropertyPermission * read,write

如何配置 SecurityManager 以允许从此特定文件读取所有属性? 如果我将其添加到策略文件中:

permission java.security.PropertyPermision "*", "read,write"

我将授予读取和更改所有属性(甚至系统属性)的权限,不是吗?

I'm currently trying to create a policy file for the Nexus repository manager running on Tomcat.

Nexus tries to read the file WEB-INF/plexus.properties (for which I already granted permission), and seems to try to read all properties from there, which fails because it is missing the following permission:

java.security.PropertyPermission * read,write

How do I configure the SecurityManager to allow reading all properties from this specific file? If I add this to the policy-file:

permission java.security.PropertyPermision "*", "read,write"

I'll grant the permission to read and alter all Properties, even System properties, won't I?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

感悟人生的甜 2024-08-08 19:33:26

java.security.PropertyPermission 应该是有效的类名。
它的限定名称用作策略文件中的 perm_class_name ,如 jaas 规范中所定义:
http://docs.oracle.com/javase /1.4.2/docs/guide/security/PolicyFiles.html#FileSyntax

grant <signer(s) field>, <codeBase URL> 
  <Principal field(s)> {
    permission perm_class_name "target_name", "action";
    ....
    permission perm_class_name "target_name", "action";
  };

Joachim Sauer 是对的 -> 它仅检查系统属性。

我认为你应该使用 java.io.FilePermission 作为 perm_class_name 。
该类的 JavaDoc 将向您解释其参数(是的,这是一个 java 类!!)

BR

java.security.PropertyPermission should be a valid class name.
Its qualified name is used as a perm_class_name in policy file as defined in jaas spec :
http://docs.oracle.com/javase/1.4.2/docs/guide/security/PolicyFiles.html#FileSyntax

grant <signer(s) field>, <codeBase URL> 
  <Principal field(s)> {
    permission perm_class_name "target_name", "action";
    ....
    permission perm_class_name "target_name", "action";
  };

Joachim Sauer is right -> It is only checked for system properties.

I think you should use java.io.FilePermission as perm_class_name.
JavaDoc for this class will explain you its parameters (yes this is a java class !!)

BR

黑色毁心梦 2024-08-08 19:33:26
  1. 没有 java.security.PropertyPermission,您可能是指 java.util.PropertyPermission
  2. 据我了解 java.util.PropertyPermission 有与从用户定义的 .property 文件读取属性无关。 它仅检查系统属性(即 System.getProperty()System.setProperty())。

您遇到哪些错误使您认为您需要除读取之外的任何内容- 文件权限?

  1. There is no java.security.PropertyPermission, you probably meant java.util.PropertyPermission
  2. As far as I understand the java.util.PropertyPermission has nothing to do with reading properties from user-defined .property-files. It is only checked for system properties (i.e. System.getProperty() and System.setProperty().

Which errors do you get that make you think you need anything but the read-file permission?

行雁书 2024-08-08 19:33:26

指定属性文件的名称,而不是“*”。

Instead of "*", specify the name of the properties files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文