简体   繁体   English

设置OSGi包的权限

[英]Setting permissions for OSGi bundles

I've run into a problem trying to limit actions that the OSGi bundle can perform. 我试图限制OSGi包可以执行的操作时遇到了问题。 According to the documents I've read, permissions for OSGi bundles should be set in OSGI-INF/permissions.perm file within bundle's JAR. 根据我读过的文档,应该在bundle的JAR中的OSGI-INF / permissions.perm文件中设置OSGi包的权限。 However, no matter what I write in that file (and no matter if this file exists or not), bundles seem to have AllPermissions. 但是,无论我在该文件中写什么(无论该文件是否存在),bundle似乎都有AllPermissions。 More specifically, I start OSGi from command line with command 更具体地说,我使用命令从命令行启动OSGi

D:\temp\2>java -jar org.eclipse.osgi_3.3.2.R33x_v20080105.jar -console
-Djava.security.manager=org.eclipse.osgi.framework.internal.core.FrameworkSecurityManager

Then I install bundle with command 然后我用命令安装bundle

osgi> install file:/d:/temp/2/J1.jar

and start it. 然后开始吧。 When I try to perform an operation that should be restricted (eg, accessing a file, loading a library, etc.), operation always succeeds, even with empty permissions.perm file. 当我尝试执行应该受限制的操作(例如,访问文件,加载库等)时,操作总是成功,即使使用空的permissions.perm文件也是如此。 How do I make permissions specified in permissions.perm file active? 如何在permissions.perm文件中指定权限?

The permissions.perm does not specify what the bundle may do. permissions.perm没有指定bundle可以执行的操作。 It specifies what the bundle wants to do: See http://www.javacodegeeks.com/2012/11/permissions-in-osgi.html 它指定了捆绑包想要做的事情:请参阅http://www.javacodegeeks.com/2012/11/permissions-in-osgi.html

So this file seems to be there to be able to fail fast if permissions are missing. 因此,如果缺少权限,此文件似乎可以快速失败。 You can even leave it out if this is not necessary for you. 如果您不需要,您甚至可以将其遗漏。

The real security settings have to be done on the framework. 真正的安全设置必须在框架上完成。 See this for felix: https://felix.apache.org/documentation/subprojects/apache-felix-framework-security.html 有关felix的信息,请访问: https//felix.apache.org/documentation/subprojects/apache-felix-framework-security.html

Managed to get the thing working - checked in my code if the SecurityManager was available or not. 管理以使工作正常 - 如果SecurityManager可用或不可用,请在我的代码中进行检查。 It seemed that on old version of OSGi JAR I've used security manager was not working. 似乎在旧版本的OSGi JAR上我使用过安全管理器无法正常工作。 I've tried org.eclipse.osgi_3.7.2.v20120110-1415.jar instead, and permissions set for bundle in OSGI-INF/permissions.perm file work fine. 我已经尝试过org.eclipse.osgi_3.7.2.v20120110-1415.jar,并且在OSGI-INF / permissions.perm文件中为bundle设置的权限工作正常。

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

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