Scripting applet and security permissions strange behaviour
I have a following problem
I need to use JFileChooser in Applet. Applet is signed, of course. When I call JFileChooser from method invoked from applet's GUI everything works. But when I call JFileChooser in public method called from javascript in browser the AccessControlException is thrown.
public String getFile()
{
// TODO add your handling code here:
String retval =null;
System.err.println("BROWSING FOR FILE METOD");
try
{
JFileChooser fileChooser =new JFileChooser();
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
if(fileChooser.showOpenDialog(new JFrame())==JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
retval = file.getAbsolutePath();
edtFile.setText(retval);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return retval;
}
Calling from applet
privatevoid jButton2ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
getFile();//WORKS
}
Calling from javascript - function test fail with AccessControlException: access denied (java.util.PropertyPermission user.dir read)
<script language="JavaScript">
<!--
function test()
{
var UNI = document.applets.TestApp;
var subor = UNI.getFile();
alert(subor);
returnfalse;
}
//-->
</script>
</head>
<body>
<applet width="300" height="300" code="TestJApplet.class" name="TestApp" id="TestApp" ARCHIVE="TestApp.jar" MAYSCRIPT>
Missing JAVA
</applet>
...
I am able to reproduce this problem on the following PC configuration:
Windows XP, JRE (java plug-in) 1.6.0 with IE 7 and Firefox 2.0 browser
Your comments would be really appreciated.
Thank you in advance for your feedback.
Regards,
Ivan

