I had to create a Java applet to invoke some code in a native DLL I wrote from the browser.

 

I use JNA to load a native DLL and invoke its methods. 

I have signed the applet using a self-signed certificate. 

The browser asks me whether or not to allow the execution of the applet. 

The applet code which loads my DLL is enclosed within `AccessController.doPrivileged` block. 

 

Like this:

 

public String Test()

{

    pHelper = AccessController.doPrivileged(new PrivilegedAction<IHelper>()

    {

         @Override

         public IHelper run()

         {

             return (IHelper)Native.loadLibrary("Helper", IHelper.class);

         }

    });

      return "test";

  }

 

The code works fine when debugged inside Eclipse. 

 

It does not work when invoked from JavaScript. Causes PrivilegedActionException.

 

If I remove the entire `AccessController.doPrivileged` block, the code runs when invoked from JavaScript. Any code that doesn't require privileges runs fine when invoked from JavaScript.

 

Any tips?

FacebookTwitterLinkedin
Pin It
Joomla Tutorials for Beginners