jnlp 尝试使用 pdf 文件调用 showDocument 时权限被拒绝

发布于 2024-12-22 19:14:29 字数 907 浏览 7 评论 0原文

我需要一些有关 jnlp 应用程序中的 showDocument 的帮助。 我试图在浏览器的另一个选项卡中显示 pdf 文件,但 java 插件拒绝了。

我的 JNLP 文件有一个

  <security>
        <all-permissions/>
  </security>

,我的代码是:

    AccessController.doPrivileged(new PrivilegedAction()
    {
        @Override
        public Object run()
        {
            try
            {
                applet.getAppletContext().showDocument(new URL("file:///C:/Contrato.PDF"), "_blank");
            }
            catch(Exception e)
            {
                e.printStackTrace();
                showException("Erro ao exibir arquivo:" + e.getMessage());
            }
            return null;
        }
    });

但我收到异常

    java.lang.SecurityException: showDocument url permission denied

如果我尝试执行 showDocument(google.com, _blank) 有效...但当我尝试显示任何文件时,它不起作用。

I need some help with this showDocument in my jnlp aplication.
I trying to show a pdf file in another tab from browser, but the java plugin denied.

My JNLP file has a

  <security>
        <all-permissions/>
  </security>

and my code is:

    AccessController.doPrivileged(new PrivilegedAction()
    {
        @Override
        public Object run()
        {
            try
            {
                applet.getAppletContext().showDocument(new URL("file:///C:/Contrato.PDF"), "_blank");
            }
            catch(Exception e)
            {
                e.printStackTrace();
                showException("Erro ao exibir arquivo:" + e.getMessage());
            }
            return null;
        }
    });

but I receive the exception

    java.lang.SecurityException: showDocument url permission denied

If I try to do showDocument(google.com, _blank) that works...but when I try to show any file, it does not work.

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

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

发布评论

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

评论(1

爱冒险 2024-12-29 19:14:29

AppletContextshowDocument(URL) 方法从未用于从本地文件系统启动文件(即使指定为 file 协议 URL )。

至少有两种选择:

  1. JNLP 片段表明这是一个受信任的应用程序。因此,对于 1.6+ 应用程序,Desktop.browse(URI) 可以被调用。
  2. JNLP API 的 BasicService 提供 showDocument(URL) 方法。

The showDocument(URL) method of AppletContext was never intended for launching files off the local file-system (even when specified as a file protocol URL).

There are at least two alternatives:

  1. The JNLP snippet indicates this is a trusted app., so for a 1.6+ app., Desktop.browse(URI) can be invoked.
  2. The BasicService of the JNLP API offers the showDocument(URL) method.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文