Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

How to load resource from plugin (.jar or .jfx) without RequiresFullAccess?
 Post subject: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Sat 10 Jan, 2015, 13:03 
User avatar

User rating: 0
Joined: Fri 05 Dec, 2014, 18:27
Posts: 4
Location: Russian FederationRussian Federation
Hello!
Is there a way to load resource file that stored in jar file without resort to RequiresFullAccess annotation?
When I'm using getResourceAsStream:
InputStream is = getClass().getResourceAsStream("/resource.dat");

I'm seeing the error:
java.security.AccessControlException: access denied ("java.net.NetPermission" "specifyStreamHandler")


 
 Post subject: Re: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Mon 12 Jan, 2015, 12:48 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Are you sure your jar library is located in IContext.getFilesDir() directory?


 
 Post subject: Re: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Mon 12 Jan, 2015, 13:42 
User avatar

User rating: 0
Joined: Fri 05 Dec, 2014, 18:27
Posts: 4
Location: Russian FederationRussian Federation
I tried to launch my plugin from %USERPROFILE%\Documents\JForex\Plugins\ and %USERPROFILE%\Documents\JForex\Strategies\files\ (IPluginContext.getFilesDir()) folders but there is always this error.


 
 Post subject: Re: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Mon 12 Jan, 2015, 15:24 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Maybe this helps, not sure...


 
 Post subject: Re: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Mon 12 Jan, 2015, 16:28 
User avatar

User rating: 0
Joined: Fri 05 Dec, 2014, 18:27
Posts: 4
Location: Russian FederationRussian Federation
I already tried next ways:
getClass().getResourceAsStream(path);
getClass().getClassLoader().getResourceAsStream(path);
Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
com.dukascopy.dds2.greed.util.IOUtils.class.getResourceAsStream(path);
MyPlugin.class.getResourceAsStream(path);

and nothing works.


 
 Post subject: Re: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Tue 13 Jan, 2015, 09:42 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We made some investigations. Right now @RequiresFullAccess is the only option.
Although it seems naturally that plugin should be able to read resources from it's own jar, we are not sure that adding required permission won't produce any security holes. We will investigate this problem more carefully and if we won't find any security problems we will add that ability in future releases.


 
 Post subject: Re: How to load resource from plugin (.jar or .jfx) without RequiresFullAccess? Post rating: 0   New post Posted: Tue 13 Jan, 2015, 11:24 
User avatar

User rating: 0
Joined: Fri 05 Dec, 2014, 18:27
Posts: 4
Location: Russian FederationRussian Federation
Thanks for your labour and response. I'll keep resource file in byte array and then I'll record it in getFilesDir() folder.


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com