Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2008, 06:51 PM
Member
 
Join Date: Dec 2007
Posts: 81
willemjav is on a distinguished road
security permissions are causing my sleepless nights.
Their Java-cast
Problems with java security permissions are causing my sleepless nights.
I wrote a small java applet that needs to load in image files from a folder called Imagestore at my website folder.
1) the applet works just fine on the sun applet viewer (because it grants all file i/o permissions).
2) once launching from a web browser the trouble starts. After finding out how to activate the console on my intel Mac book the following message appears: java.security.AccessControlException: access denied (java.io.FilePermission Imagestore read).
3) I modified the applet.policy file into:
grant codeBase "file:/webwillem/*" {
permission java.security.AllPermission;
}; (when everything Works all right I probably should specify a read only condition for the Imagestore folder of the webwillem folder at the userdir.
a) So my first question is how to setup the content of the applet.policy file.
b) And where sits that file in order to work correctly (for the moment it gets copied automatic into my jar-applet file without having much effect I believe).
c) After having the correct content of the policy file and having it put at the right spot, the applet should work correctly (when I take out e.g. the file download content of the applet, it does appear on my webpage).
Please keep in mind that I work on a mac osx (10.4) system, so pc information, I believe does help me much. Though I even do not really understand where the problem lies (java app, netbeans, web browser or mac system). It is pretty confusing all (there might come a message from a ¨helpful-dude¨saying ¨stop complaining start learning the languages”…. But there is precisely where leis the dilemma of it all….
Rephrasing my (unanswered) question really helps (me and maybe others) to come each time a bit closer to the solution of this nightmare-problem. I wonder, can’t these things be a little easier (or is it all a result of big company wars such as sun Microsoft apple etc) or am I just to limited to understand this all.

willemjav
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-08-2008, 08:18 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
Besides policy files and the signing of applets, a couple of possiblities/suggestions:
Applets seem to balk at the creation of files.
Sometimes you can get around this by avoiding the File constructors and using URLs instead.
Code:
URL url = getClass().getResource(imagePath); BufferedImage image = ImageIO.read(url);
Another possibility can be to load the images in a class that is declared outside the body of the applet.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-08-2008, 08:54 PM
Member
 
Join Date: Dec 2007
Posts: 81
willemjav is on a distinguished road
I used following method which is, I think, ok (I used URLs before having the same problem).
I did not think yet of going around the problem... that might be a good one
to try out,
thanks willemjav

private Image downloadImage(String filename) {


Image images = getImage(getCodeBase(), "Imagestore/" + filename); //getDocumentBase()
if (images==null)
JOptionPane.showMessageDialog(infoPane, " no file " + filename);

try {
picwidth = images.getWidth(this);
}
catch (Exception e) {
JOptionPane.showMessageDialog(infoPane, "can not get image width " + e);
}
try {
picheight = images.getHeight(this);
}
catch (Exception e) {
JOptionPane.showMessageDialog(infoPane, "can not get image height " + e);
}

return images;
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
one more try, applets security willemjav Java Applets 0 03-09-2008 02:19 PM
Midlet Permissions Access fernando CLDC and MIDP 1 08-07-2007 04:21 PM
difference between code based security and role based security boy22 New To Java 1 07-24-2007 12:59 AM
What could be causing the browser to close? Marcus Java Applets 2 07-04-2007 08:26 AM
Acegi Security 1.0.4 levent Java Announcements 0 05-26-2007 01:16 PM


All times are GMT +3. The time now is 07:21 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org