• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Under Java Security Manager, accessing a file inside a jar

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to read a file[resource] inside jar under Java Security Manager?
Ex- in myApp.jar , I want to read file placed under com/mystuff/queries/abc.sql
myApp.jar
|
|-com/mystuff/queries/abc.sql


I am using Class.class.getResourceAsStream("")to read the content of a file which is packaged inside a jar. This works fine if not run under Java Security manager. This fails under Java Security Manager. I am getting a NULL InputStream under security manager. Probably I need to give "read" permission to "queries" folder recursively.

What is the syntax to be used in policy file to give permission recursively to folder inside a jar?

OR Please let me know if this is the correct syntax-
 
Master Rancher
Posts: 5026
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a copy of an entry from my .java.policy file:

grant codeBase "file:/D:/JavaDevelopment/Testing/ForumQuestions/-" {
permission java.io.FilePermission "C:/autoexec.bat", "read";
permission java.lang.RuntimePermission "queuePrintJob";
permission java.awt.AWTPermission "readDisplayPixels";
};

 
Sandeep P Kulkarni
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Norm ,

I want to give permissions to file packaged inside a jar.
 
Slime does not pay. Always keep your tiny ad dry.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic