Reputation: 5734
I'm geting Access Errors, only when I call the functions with Javascript (LiveConnect).
The applet calls a function postData and displays the response (this works great). Now if I call this function from Javascript via the applets[] array like document.applets[0].postData
i get the Socket/Permissions Error: uncaught exception: java.security.AccessControlException: access denied (java.net.SocketPermission 174.132.167.66:80 connect,resolve)
the same function called internally works great, but I get Access Control errors when called from javaScript.
Anyone had issues like this before?
Upvotes: 0
Views: 720
Reputation: 7604
I've recently run into the same problem, in particular with Firefox on the Mac. I was using SwingUtilities.invokeLater()
in my block though.
The way I worked around it was to wrap the invokeLater
call in an AccessController.doPrivileged()
block. For example, if I have a method on my applet called someAction()
that's callable from JavaScript, I would do:
void someAction() {
AccessController.doPrivileged( new PrivilegedAction() {
public Object run() {
SwingUtilities.invokeLater( new Runnable() {
public void run() {
// some privileged action here
}
});
}
});
}
This approach seemed to fix the issue for me in Firefox. It does not get around Same Origin problems in Safari, though, for example if you want to serve the Javascript from a different domain than the applet.
Update
I should mention that the invokeLater
part isn't required for this to work; it's just what I happened to be using.
Upvotes: 3