How to Develop a Signed Applet
Read/write the local machine file system using a signed applet
Introduction
The information in this article helps in answering the following questions:
- What are the tools needed to develop a signed applet?
- How to make a test certificate using Microsoft Sign Tool?
- How to read/write the local machine file system using a signed applet?
Summary
This article shows how to develop a signed applet using the Microsoft sign Tool.
Reading and writing file system through an applet is possible provided you have signed that applet using Microsoft Sign tool for Internet Explorer or Netscape sign tool for Netscape. The example that I showed here is just an example of how to create a test certificate. This is not recommended if you are going to publish your applet over the Web. In that case, you will have to get the certificate from Verisign or Thawte certificate for publishing. Unless the content in your applet is insecure, it may corrupt itself or corrupt other resources where it is playing.
Tools Required
- Microsoft Internet Explorer 3.0 or upgrade version
- Microsoft Sign tool which encompasses the following EXEs and DLLs
- makecert.exe
- signcode.exe
- setreg.exe
- ChkTrust.exe
- cert2spc.exe
- cabarc.exe
- javasign.dll
- signer.dll
More Information
Part I: Java Applet Read/Write File System using Applet
Part I provides the source code for the read/write applet.
Collapse
import java.applet.*;import com.ms.security.*;import java.awt.*;import java.io.*;import java.lang.*;import java.applet.*;
public class WriteFile extends Applet
{
String myFile = "G:\\test.foo";
File f = new File(myFile);
DataOutputStream dos;
{
String myFile = "G:\\test.foo";
File f = new File(myFile);
DataOutputStream dos;
public void paint(Graphics g)
{
try
{
//create the output stream
dos = new DataOutputStream(new BufferedOutputStream
(new FileOutputStream(myFile),128));
//write chars to that file
dos.writeChars("Cats can hypnotize you when you least expect it\n");
//flush stream to that file
dos.flush();
g.drawString("Successful attempt to write to " + myFile, 10, 10);
}
catch (SecurityException e)
{
g.drawString("writeFile: caught security exception", 10, 10);
}catch (IOException ioe)
{
g.drawString("writeFile: caught i/o exception", 10, 10);
}
}
}
{
try
{
//create the output stream
dos = new DataOutputStream(new BufferedOutputStream
(new FileOutputStream(myFile),128));
//write chars to that file
dos.writeChars("Cats can hypnotize you when you least expect it\n");
//flush stream to that file
dos.flush();
g.drawString("Successful attempt to write to " + myFile, 10, 10);
}
catch (SecurityException e)
{
g.drawString("writeFile: caught security exception", 10, 10);
}catch (IOException ioe)
{
g.drawString("writeFile: caught i/o exception", 10, 10);
}
}
}
-- MD WASHIM AKHTAR