Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

applet for accessing the clients files

Status
Not open for further replies.

BayK

Programmer
Aug 6, 2004
4
AT
Hi!

I have tried to create an applet which is able to access the clients file system.

The applet should be able to check the size of a file before uploading it. Therefore it should be able to be accessd via LiveConnect (javascript)...

The problem I have is that I a com.ms.security.SecurityExceptionEx[Unknown] is thrown when I try to access the file.

ps: the applet is signed with a valid signature

Everytime I call the function below with javascript I get the following error:

Code:
com.ms.security.SecurityExceptionEx[Unknown]: cannot access file C:\wsinst.log
	at com/ms/security/permissions/FileIOPermission.check
	at com/ms/security/PolicyEngine.deepCheck
	at com/ms/security/PolicyEngine.checkPermission
	at com/ms/security/StandardSecurityManager.chk
	at com/ms/security/StandardSecurityManager.checkRead
	at java/io/File.exists
	at CheckFileSize.setFile



Code:
	public String setFile(String filePath)
	{
		try
		{	Class.forName("com.ms.security.PolicyEngine"); // throws ClassNotFoundException
			PolicyEngine.assertPermission(PermissionID.FILEIO);
		}
		catch (ClassNotFoundException cnfe)
		{   
			   // ignore
		}
		catch (Exception x)
		{   x.printStackTrace ();
		}
		catch (Error e)
		{   e.printStackTrace ();
		}
		
		this.f = new File(filePath);

		if (!f.exists())
		{
			errMsg = "File \"" + f.getName() + "\" does not exist";
			repaint();
			return errMsg;
		}

		else if (!f.canRead())
		{
			errMsg = "Problems appeared reading the file";
			repaint();
			return errMsg;

		}

		try
		{
			setImageInfo(new FileInputStream(f));
		}
		catch (FileNotFoundException e)
		{
			errMsg = "File \"" + f.getName() + "\"not Found";
			repaint();
			return errMsg;
		}

		return "file \"" + f.getName() + "\" loaded successfully";
	}
 
That is because Applets are not allowed to. The client must relax security in order to make this work.
 
Also,

You can youe Keygen to generate a trusted applet.

Ed
 
egm2005 :

If you read the original post, they say the applet is actually signed, so this is probably not the problem.

BayK :

I notice your stack trace indicates that you are using the MSJVM. You should be aware that this product is now discontinued (due to legal wranglings between Sun and M$), and you/your clients should move to the Sun JVM plugin, available from .

I'm not saying this is the problem, but I would certainly uninstall the MSJVM, install the Sun JVM and then see if you still have problems. A signed applet should be able to operate out of the 'sandbox' restrictions, and access the client filesystem.

Links for help on the MSJVM discontinuation :


Good Luck !


--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top