I have a self signed
applet - I verified that its self signed with jarsigner -verify, so it is without a doubt signed.
Its running on a
Tomcat 6.0 server on localhost, and I'm trying it with both Firefox and IE, with the same result.
I'm trying to access the filesystem, and it simply will not do it, giving me AccessControlExceptions when I try that look like this :-
java.security.AccessControlException: access denied (java.io.FilePermission C:\ read)
(it makes no difference where I attempt to read on the filesystem, I've already fiddled around with that).
The root of it all is to use a file chooser to save a .png to the hard drive. The above error is caused by it attempting to set a default path to save the .pngs too, but if I take that out it still falls over, just on writing the file instead of reading. All the (many) tutorials I've read just talk about the requirement to sign the applet, but it is signed and the certificate accepted, still no joy. There is some talk about
Java Web Start and bugs I noticed after rooting through Google, but that doesn't apply to me.
public void doSaveAs() throws IOException {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs);
ExtensionFileFilter filter = new ExtensionFileFilter(
localizationResources.getString("PNG_Image_Files"), ".png");
fileChooser.addChoosableFileFilter(filter);
int option = fileChooser.showSaveDialog(this);
if (option == JFileChooser.APPROVE_OPTION) {
String filename = fileChooser.getSelectedFile().getPath();
if (isEnforceFileExtensions()) {
if (!filename.endsWith(".png")) {
filename = filename + ".png";
}
}
ChartUtilities.saveChartAsPNG(new File(filename), this.chart,
getWidth(), getHeight());
}
}
Thats the code for sake of completeness - its actually open source and well tested so I doubt theres anything to see there. The issue isnt really a codey one but some sort of signing/sandbox issue.
Any takers?