我正在尝试创建一个webstart应用程序。 它现在运行,但不会读取我的所有设置。
当我启动jnlp文件并尝试使用Inputstream读取另一个jar资源时,会出现问题。
我已经验证了我的罐子,他们都在使用相同的密钥库。
我有一个叫做浏览器的jar,试图读取另一个叫做Bone的jar。
这是我读取我的类BoneModule中的设置的方法:
InputStream settingsStream = IOUtil.getInputStream("bone.settings");
InputStream defaultSettintgsStream = IOUtil
.getResourceAsStream("/com/mee/bone/bone.settings", BoneModule.class);
SimpleProperties storage = new SimpleProperties(settingsStream,
new SimpleProperties(defaultSettintgsStream, null).getProperties());
storage.setStoreFilename("bone.settings");
boneSettings.addStorage(storage);
我已将我的jnlp文件设置为:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://ip-adress/lib" href="launch.jnlp">
<information>
<title>Bildlabbet</title>
<vendor>mee</vendor>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+" initial-heap-size="32m" max-heap-size="128m" />
<property name="jnlp.versionEnabled" value="false"/>
$dependencies
</resources>
<application-desc
name="Bildlabbet"
main-class="com.mee.browser.BildlabbetBrowser"
width="300"height="300">
</application-desc>
</jnlp>
我的堆栈跟踪:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mee.browser.Browser.initModuleModel(Browser.java:639)
at com.mee.browser.Browser.<init>(Browser.java:438)
at com.mee.browser.BildlabbetBrowser$1.run(BildlabbetBrowser.java:92)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "bone.settings" "read")
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.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at com.mee.io.IOUtil.getInputStream(IOUtil.java:143)
at com.mee.io.IOUtil.getInputStream(IOUtil.java:123)
at com.mee.bone.BoneModule.getBoneSettings(BoneModule.java:91)
at com.mee.bone.BoneModule.<init>(BoneModule.java:68)
... 21 more
正如你在这里看到的,我无法读取其他jar中的设置文件。 我的客户端和浏览器的策略设置是:
grant codebase "file:${jars}" {
permission java.security.AllPermission;
};
grant codebase "file:/var/www/lib/*" {
permisson java.security.AllPermisson;
};
grant codebase"file:/http://ip-adress/lib/*" {
permisson java.security.AllPermission;
};
grant codebase "file:/home/ubuntu/bildlabbet/lib/*"{
permission java.security.AllPermission;
grant {
permission java.util.PropertyPermission "*", "read, write";
};
grant {
permission java.security.AllPermission;
};
甚至可以这样读?因为现在我正在读取本地驱动器上的jar,因为它是webstart所做的。
要提到的是我从临时目录中读取jar。我已经尝试调试临时文件夹的文件权限。
如果我从服务器而不是本地读取jar资源,这是否已修复?
任何建议都会很好!
谢谢!
答案 0 :(得分:0)
试试这个:
grant {
permission java.io.FilePermission "/dir/yourfile", "read, write"
}