No Grant Permissions Dialog Showing

Hey guys, I am trying to write a simple applet that executes a file on the users local filesystem. I have signed the applet by first creating a keystore and then using jarsigner to self-sign the applet. However, when the applet is executed it throws an AccessControlException when trying to execute the file (a FilePermission error on the execute)

The applet is compiled in 1.5.0_09 and run in the 1.5.0_09 JRE. I have tried running the applet from an HTML page both locally through the filesystem and remotely through my webserver on 2 separate machines.

The problem is, it just throws an exception and doesn't even ask the user to grant it permissions which I imagine is what I need to do

Here is the code:

package Jim;

import java.awt.*;

import java.applet.*;

import java.io.*;

import java.util.*;

import java.security.*;

import netscape.javascript.*;

publicclass WinampConnect2extends Applet{

private String msg;

publicvoid init()

{

GetWinampInfo();

}

publicvoid paint(Graphics g){

g.drawString("MSG: " + this.msg, 50, 60 );

}

publicvoid GetWinampInfo()

{

String msg2 = (String) AccessController.doPrivileged(new PrivilegedAction()

{

public Object run()

{

try

{

FilePermission MyPerm =new java.io.FilePermission("c:\\WinampMagic.exe","execute" );

Runtime runtime = Runtime.getRuntime();

Process process =null;

process = runtime.exec("c:\\WinampMagic.exe");

DataInputStream in =new DataInputStream(process.getInputStream());

// Read and print the output

String line =null;

return in.readLine();

}

catch (Exception e)

{

System.out.print(e);

System.out.flush();

return"error";

}

}

});

this.msg = msg2;

}

}

If anyone could offer me any advice on what I am doing wrong or how to correct this I would be very appreciative. Thanks in advance guys.

Jim.

[3533 byte] By [Jimmmeha] at [2007-11-26 14:22:15]
# 1

The only option I see is to deploy this program through webstart instead of presenting this as an applet. Applets are by default very limited in the things they can do, and it also heavily depends on how the user has setup its permissions (/security manager).

Still, depending on settings and policies this is possible. I'd recommend reading up on applet security in the sun java tutorial, to be found here: http://java.sun.com/docs/books/tutorial/security/tour1/step1.html.

Lion-Oa at 2007-7-8 2:14:14 > top of Java-index,Security,Signed Applets...
# 2

Thanks for the input but that seems a bit of a cop-out. I realise that Applets are by default limited in their abilities which is why there is the ability to sign them in the first place.

I know permissions aren't a problem as other applets I have tried which request permissions pop up the grant permissions dialog which my applet does not.

I need this applet to run from a webpage and communicate with the DOM/Javascript on the page from my website for an experiment I am working on. I have worked with applets before and not had this problem with security so am wondering if there is something wrong with my code or a known bug that I am encountering.

Please don't get me wrong, Lion-O, I appreciate your response, I just would really like to learn from this problem by fixing it rather than giving in.

Can anyone else help?

Jimmmeha at 2007-7-8 2:14:14 > top of Java-index,Security,Signed Applets...
# 3

Just signing your applet doesn't imply that the client side will trust it. Does it actually know about the signing authority and have it in its keystore as trusted? You failed to mention that in your first message. And on that subject: where is your policy file and whats in it?

So far you haven't given us much to go by, not even the full exception itself, and it seems to me as if you are now basicly blaming others for that. But; suit yourself.

Lion-Oa at 2007-7-8 2:14:14 > top of Java-index,Security,Signed Applets...