如何配置 Java SecurityManager 以允许从给定文件读取所有属性
我目前正在尝试为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
java.security.PropertyPermission 应该是有效的类名。
它的限定名称用作策略文件中的 perm_class_name ,如 jaas 规范中所定义:
http://docs.oracle.com/javase /1.4.2/docs/guide/security/PolicyFiles.html#FileSyntax
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
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
java.security.PropertyPermission
,您可能是指java.util.PropertyPermission
java.util.PropertyPermission
有与从用户定义的.property
文件读取属性无关。 它仅检查系统属性(即System.getProperty()
和System.setProperty()
)。您遇到哪些错误使您认为您需要除读取之外的任何内容- 文件权限?
java.security.PropertyPermission
, you probably meantjava.util.PropertyPermission
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()
andSystem.setProperty()
.Which errors do you get that make you think you need anything but the read-file permission?
指定属性文件的名称,而不是“*”。
Instead of "*", specify the name of the properties files.