Problemas de permisos de comunicaciones al llamar a Java desde javascript

I have a little graphics editing Java applet embedded in an HTML/Javascript/jquery page.

I have a save button on the page that pops up a jquery dialogue which calls a Java function.

When that function tries to access the server it dies on a permission error. The identical code works to load the graphics object.

I am currently assuming that the call to Java from Javascript is not in the applet context (separate thread?), so there is no place it was loaded from and therefor cannot talk to it.

Is there any way to get into the correct context?

I expect I can work around it by putting the save button in the Java applet and using a Java dialogue to get the other data. Long term going to HTML5 canvas is the solution I think.

preguntado el 08 de enero de 11 a las 21:01

No, I don't want people to need to trust it. -

3 Respuestas

La modelo de seguridad of JavaScript -> Java calls says that even calls into a signed applet are treated as untrusted. To avoid this, if you know what method is being called, you can use AccessController.doPrivileged() to allow the call to execute with the right privileges. However, be aware that anyone can embed your applet and use their own JavaScript to call into it, so this solution does have security consequences that you should consider carefully.

Respondido el 09 de enero de 11 a las 01:01

It's a little annoying since I already don't trust the applet (server side validation and sanitization), but at least this is an explanation. - Jim Rootham

You either have set permission in policy file (${user.home}.java.policy) - you can do it manually or with polictool (in JDK bin directory). See Set up a Policy File to Grant the Required Permission.This has to be done for on each client's machine that will use your applet.

Another way is to sign your applet.

More details on applet security can be found at wiki y en Java Plug-in Developer Guide.

Respondido el 09 de enero de 11 a las 01:01

It is important to note that an unsigned applet can only communicate with the server from which it was served. To communicate with a different server, the applet needs to be signed. More info Aquí.

Respondido el 09 de enero de 11 a las 02:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.