7 Replies Latest reply: Jun 3, 2010 8:20 AM by 843811 RSS

    How to create a scriptable signed applet

    843811
      Hello,

      I am working on a signed applet. This applet is signed because it requires specific security permission.
      My applet works as expected, until then everything is fine.

      Now I am trying to transform this applet into a scriptable one. As I tested this version of my applet, I noticed that only the functions that didn't require a specific security permission worked.
      I have checked my Javascript console and notice this was an error due to a security exception : after a few research I found that my javascript needed to be signed too.

      Signing javascript doesn't seem to me as something trivial, I have found a few resources about it online, all of those seem to refer to this page : http://www.mozilla.org/projects/security/components/signed-scripts.html which seems to be for Firefox only.

      Is there any other solution? Something a bit more easy to implement?
      Is there any other source on how to sign Javascript?
      How about signing JavaScript for other browsers?

      Thank you in advance for any help/tip given
        • 1. Re: How to create a scriptable signed applet
          843811
          Duplicate thread removed.
          • 2. Re: How to create a scriptable signed applet
            843811
            Sorry about that, the page seemed to load undefinitely (more than 40s) so I sent it again (it then posted in less than 5s)
            • 3. Re: How to create a scriptable signed applet
              843811
              Bilss wrote:
              Sorry about that, the page seemed to load undefinitely (more than 40s) so I sent it again (it then posted in less than 5s)
              :-) No problem. It's happened to me in the past and will happen to me again.
              • 4. Re: How to create a scriptable signed applet
                baftos
                Search this forum for "AccessController.doPrivileged javascript".
                • 5. Re: How to create a scriptable signed applet
                  843811
                  Hi baftos,

                  Thank you for your tip.

                  Have a few research on this forum on this subject, I have transformed my code from :
                  public void Connect(String protocol)
                       {
                            try {
                                 card = WorkingReader.connect(protocol);
                                 if(card != null)
                                 {
                                      butTransmit.setEnabled(true);
                                 }
                            } catch (CardException e) {
                                 // TODO Auto-generated catch block
                                 e.printStackTrace();
                            }
                       }
                  into
                  public void Connect(final String protocol){
                            // this code allows us to run the code with the Applet security privs
                            try {
                                 AccessController.doPrivileged(new PrivilegedExceptionAction<Integer>() {
                                 public Integer run(){
                                      try {
                                           card = WorkingReader.connect("*");
                                           if(card != null)
                                           {
                                                butTransmit.setEnabled(true);
                                           }
                                      } catch (CardException e) {
                                           // TODO Auto-generated catch block
                                           e.printStackTrace();
                                      }
                                      return null;
                                 }
                                 },AccessController.getContext());
                            } catch (PrivilegedActionException e) {
                                 // TODO Auto-generated catch block
                                 e.printStackTrace();
                            }
                            }
                       
                  However, I still have this error from the FireFox error console :

                  "uncaught exception : java.security.AccessControlException : access denied"

                  I have singed again the applet after modifying my code, and changed a bit the displays to make sure I was running the newer version of the applet.

                  Is there anything I did wrong?
                  • 6. Re: How to create a scriptable signed applet
                    baftos
                    I don't know, it looks ok to me.
                    In my code, I never pass the AccessController.getContext() parameter, but I don't think this is the problem.
                    You may try to omit it, see what happens.
                    • 7. Re: How to create a scriptable signed applet
                      843811
                      baftos wrote:
                      I don't know, it looks ok to me.
                      In my code, I never pass the AccessController.getContext() parameter, but I don't think this is the problem.
                      You may try to omit it, see what happens.
                      Hi baftos,

                      I omitted AccessController.getContext() as you advised, and it solved the problem!

                      Thanks!