This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes file read/write permissions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "file read/write permissions" Watch "file read/write permissions" New topic
Author

file read/write permissions

John Mack
Greenhorn

Joined: Jan 17, 2002
Posts: 2
Hi, my question is:
In the server (or client) security policy file, do you have to give the db.db file a java.io.FilePermission setting?
I pass the location (as a full pathname) of the db.db file on the command line so that I can create a Data object. If I don't specify the full pathname of this file in the security policy file I get a 'java.security.AccessControlException: access denied (java.io.FilePermission..'
The problem is that the specification states 'allow the user to specify the location of the database', so if they move the database, the location will differ from the location in the policy file, and this exception will occur. Is there any way of setting policy file attributes after starting the program, or is there another way of making sure there is access to the file, wherever it is, without using 'permission java.security.AllPermission' which I don't think is a good idea.
please advise!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I just put one permission in my policy file that gave full access to everything.
grant {
permission java.security.AllPermission "", "";
};

I didn't lose points for it.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
John Mack
Greenhorn

Joined: Jan 17, 2002
Posts: 2
Hi Mark,
thanks for your reply. I have got a policy file now that basically allows all access to the files below the current user directory. But,if it goes pear-shaped it's good to know I can use the simple permission and not lose marks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: file read/write permissions
 
Similar Threads
java .security .AccessControlException
java.policy file
location of DB.DB file
Slashes in the policy file
Can JFileChooser select server-side file?