签署导致问题的 jar

发布于 2024-10-12 11:48:12 字数 1665 浏览 1 评论 0原文

我在小程序中有以下代码,基本上将一些数据写入作为参数传递给 writeFile 方法() 的文件中,

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;
    }
}
}

我已使用以下命令对 jar 进行自签名

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

,但仍然没有获得在本地计算机上写入文件的所有权限正在获取文件许可被拒绝任何想法为什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江湖正好 2024-10-19 11:48:12

问题可能是签名小程序不允许访问所有内容。取决于您的浏览器 JRE 设置。默认设置是在 JRE 中定义的(在 JRE 文件夹中搜索属性文件 - 其中之一定义它)。但浏览器可以覆盖它。

尝试在用户主文件夹中创建该文件。

The problem could be signed applet is NOT allowed to access everything. Depends on your browser JRE setting. The default setting is defined within the JRE (search for a property file in your JRE folder - one of these defines it). But browsers can override that.

Try to create the file in the users home folder.

迷荒 2024-10-19 11:48:12

如果以下两个都是正确的 - 我会建议一种完全不同的方法。

链接的演示。 (由我编写)是沙盒的,只有当用户打开文件时,JRE 才会询问他们是否要授予该权限。

沙盒代码不需要进行数字签名。

从新一代插件开始,演示中使用了JNLP API。可以通过嵌入网页中的小程序进行访问。 GIFanim 小程序 中可以看到这样的示例。

If both the following are true - I would suggest an entirely different approach.

The linked demo. (written by me) is sand-boxed, and only when the user goes to open a file does the JRE ask them if they want to give it permission.

It is not necessary for sand-boxed code to be digitally signed.

Since the new generation plug-in, the JNLP API used in the demo. can be accessed by applets that are embedded in a web page. An example of that can be seen in the GIFanim applet.

假装不在乎 2024-10-19 11:48:12

感谢您的回复
我自己得到了答案,实际上,小程序中允许权限,只有来自外界的调用不允许我获得权限。我正在从 javascript 拨打电话,并希望也获得权限

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文