Search code examples
javaappletsigned-applet

Signing a jar causing issue


i have following code in applet that basically writes some data to a file being passed as parameter to writeFile method()

public class appletToWrite extends Applet{
public int writeFile(String asPath, String asData, int aiOverwrite)
{
    int j = JOptionPane.showConfirmDialog(null,asPath+ "testing gng on", "data mil gaya!!!", 0);
    try {
        File localFile = new File(asPath);
        if (localFile.exists()) {
            if(aiOverwrite==1){
                localFile.delete();
                j =JOptionPane.showConfirmDialog(null,"overwrite = 1", "data mil gaya!!!", 0);
            }
            else{
                j = JOptionPane.showConfirmDialog(null, "overwrite = 0", "data mil gaya!!!", 0);
                return 0;
            }
        }
        j = JOptionPane.showConfirmDialog(null, "niche aa gaye", "data mil gaya!!!", 0);
        localFile.createNewFile();
        BufferedWriter localBufferedWriter = new BufferedWriter(new FileWriter(localFile, true));
        String str1;
        localBufferedWriter.write(asData);
        localBufferedWriter.close();
        return 1;
    }
    catch (Exception localException) {
        j = JOptionPane.showConfirmDialog(null, "catch mein aa gaya "+localException.getMessage(), "data nahi gaya!!!", 0);
        localException.printStackTrace();
        return 0;
    }
}
}

i have self signed the jar using following commands

javac appletToWrite.java
jar cvf AppletClass.jar *.class
keytool -genkey -validity 3650 -keystore pKeyStore -alias formBuilder
keytool -selfcert -keystore pKeyStore -alias formBuilder -validity 3650
jarsigner -keystore pKeyStore AppletClass.jar formBuilder

but still its not getting all the permission to write the file on local machine am getting file permission denied any idea why?


Solution

  • thanks for the replies got answer myslef actually thing was permissions are allowed with in applet only a call from outside world is not letting me get the permissions. I was making a call from javascript and was hoping to get permissions as well