Wednesday, August 08, 2012

Java Applet Security Issue - java.io.FilePermission


A while ago I ran into this issue where an applet was used to upload files.

Security manager class: sun.plugin2.applet.AWTAppletSecurityManager
Exception in thread "Thread-45" java.security.AccessControlException: access denied (java.io.FilePermission ...) 

The solution is to create a .java.policy file and explicitly give the applet permissions to access your file system.
Path in Windows Vista: C:\Users\<username>\.java.policy


grant {
  permission java.security.AllPermission;
  permission java.io.FilePermission "file://C:/Users/username/Documents/special/*", "read, write";
};

Here, you will need to replace the path to something of your choice.

No comments: