Hi Everyone,
I have an applet loaded via the AppletLoader which loads and runs as expected. During the initialisation of this applet I call
java.awt.Image image = ImageIO.read(stream);
No problems the jpg gets loaded as expected. However when I call a public function of the applet (via getApplet()) the very same code generates the following exception
java.lang.SecurityException: Unable to create temporary file
The applet is signed, i've checked and double checked. Can anyone explain why this might be happening?
Thanks in advance.
care to paste the whole exception from the java console? bit difficult to tell from just that snippet you've provided.
hmm, hard to say.
which OS, Java version and browser are you using?
is it possible you could provide a link to the applet, so i can see if i can reproduce the error here?
Certainly,
Window XP SP3 & Java 1.6.18.
Can I email you the link? The site's under development and I can't have it indexed just yet :)
send me the link as a pm :)
thx, just tried but i'm on linux, it seems to be missing the linux_natives.jar
That should fix it.
now i get an unable to validate certificate chain error. remember the certificates in the natives jars, should be the same as that of the lwjgl_util_applet.jar
Hmm everything's signed with my own certificate cold it be a caching issue?
Hi,
Let me know if it's still not working for you. I'll create a new page with a simple applet that demonstrates the problem and send you the source.
Thanks.
i've just checked, the linux_natives.jar is not signed.
Lord, really sorry I copied the wrong one up. It is now.
Applolgies for that.
works great for me now. see a model in the middle of the page and you can rotate around it.
not sure why it's still not working for you, make sure you haven't corrupted your cache somehow with an older version of lwjgl, if you suspect that try change the al_title value and clear the java cache from the java control panel.
further check all your jars are signed, (just open them with a zip program and see if the META-INF folder has the certificates in there)
OK the problem occurs when you hit one of the image logos below the main window. That's when the public function gets called via javascript and the error occurs.
This is the code from the public the function
InputStream stream = null;
URL file = null;
try {
file = new URL(modelUrl + ".jpg");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
stream = file.openStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
java.awt.Image image = ImageIO.read(stream);
} catch (IOException e) {
e.printStackTrace();
}
The exception occurs when we get to the following line, but only when the function is called from Javascript not during initialisation.
java.awt.Image image = ImageIO.read(stream);
sound like a jre bug or that the calls from javascript are not allowed access outside the sandbox. not really sure what could be causing this, maybe its a browser restriction (tried in other browsers?)
OK I've done some more testing. It's not just ImageIO that has a problem. I just tested an applet that when initialising calls a functiom write a text file to disk. That works with no problems.
Call this same function via javascript (using the getApplet() function in AppletLoader) and and you get..
java.security.AccessControlException: access denied
Why would the access rights of the applet be different depending on how the function is called. I'm a bit stuck on this one.
Cheers,
Richard
might be because the "action" occurs from another thread/classloader than the signed one.
Try and wrap your stuff in
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
}
});
Ahh thank you,
It's because scripted calls in to signed applets operate without the permissions granted with the certificate. I've used the following now and it works..
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
// Your code here
return null;
}
});
I'm fairly new to Java else I guess I would have known that. Thanks for all you help.