Applet 签名抛出:java.security.AccessControlException。我怎样才能让它运行?

发布于 2024-09-08 03:27:07 字数 1658 浏览 4 评论 0原文

经过几个小时的工作(我不是 java 程序员),我已经成功打包并放入一个小程序中,该小程序可以通过 ftp 上传到远程服务器。主文件是“invia.jar”内的“prova.class”;我使用第三方库,放置在“edtftpj.jar”中。我已经对这两个文件进行了签名,并使用以下代码将它们包含在页面中:

Index.html

<applet width="300" height="300"  classpath="./" code="prova.class" archive="invio.jar,edtftpj.jar"> </applet>

现在,当我将浏览器指向我的页面时,我在控制台上发现了此消息:

Could not read property 'edtftp.log.level' due to security permissions
Could not read property 'edtftp.log.log4j' due to security permissions
Could not read property 'edtftp.log.log4j' due to security permissions
java.security.AccessControlException: access denied (java.net.SocketPermission www.artkiller-web.com resolve)
 at java.security.AccessControlContext.checkPermission(Unknown Source)
 at java.security.AccessController.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkConnect(Unknown Source)
 at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
 at java.net.InetAddress.getAllByName0(Unknown Source)
 at java.net.InetAddress.getAllByName(Unknown Source)
 at java.net.InetAddress.getAllByName(Unknown Source)
 at java.net.InetAddress.getByName(Unknown Source)
 at com.enterprisedt.net.ftp.FTPClient.connect(FTPClient.java:966)
 at com.enterprisedt.net.ftp.FileTransferClient.connect(FileTransferClient.java:386)
 at prova.start(prova.java:44)
 at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

Any Idea of​​ how to work -它周围?

提前谢谢你

ArtoAle

After hours of work (I'm not a java programmer) I've managed to pack and put inside an applet wich make an ftp-upload to a remote server. The main file is "prova.class" inside "invia.jar"; I use a third-part library, placed in "edtftpj.jar". I have signed both file and included them in the page with the following code:

Index.html

<applet width="300" height="300"  classpath="./" code="prova.class" archive="invio.jar,edtftpj.jar"> </applet>

now, when I point the browser to my page I found this message on the consolle:

Could not read property 'edtftp.log.level' due to security permissions
Could not read property 'edtftp.log.log4j' due to security permissions
Could not read property 'edtftp.log.log4j' due to security permissions
java.security.AccessControlException: access denied (java.net.SocketPermission www.artkiller-web.com resolve)
 at java.security.AccessControlContext.checkPermission(Unknown Source)
 at java.security.AccessController.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkConnect(Unknown Source)
 at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
 at java.net.InetAddress.getAllByName0(Unknown Source)
 at java.net.InetAddress.getAllByName(Unknown Source)
 at java.net.InetAddress.getAllByName(Unknown Source)
 at java.net.InetAddress.getByName(Unknown Source)
 at com.enterprisedt.net.ftp.FTPClient.connect(FTPClient.java:966)
 at com.enterprisedt.net.ftp.FileTransferClient.connect(FileTransferClient.java:386)
 at prova.start(prova.java:44)
 at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

Any Idea of how to work-it around?

thank u in advance

ArtoAle

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

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

发布评论

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

评论(1

逆光飞翔i 2024-09-15 03:27:07

您需要将连接 URL 包装在特权代码块中。

看起来您在读取属性文件时也遇到了问题,您可以将属性文件直接打包到 jar 中,如果您尝试从客户端计算机读取属性文件,则需要将该代码包装在特权代码块中,如下所示出色地。

这是我在另一个答案中使用的一段代码,用于通过访问控制器获取 URL。

 try 
 {
     final String imageURL = "http://www.google.com/intl/en_ALL/images/logo.gif";
     URL url = (URL) AccessController.doPrivileged(new PrivilegedAction() 
     {

         public Object run() 
         {
             try
             {
               return new URL(imageURL);
             }
             catch (MalformedURLException e)
             {
               e.printStackTrace();
               return null;
             }

        }  
      });  

     if(url == null)
     {
        // Something is wrong notify the user
     }
     else
     {
        // We know the url is good so continue on
         img = ImageIO.read(url);
     }

  } 
  catch (IOException e) 
  {
   System.out.println(e);
  }  

You need to wrap the connection url in a privileged block of code.

Also looks like you are having issues reading from the properties file, The properties file you can package right in your jar, if your trying to read the properties file from the client machine you will need to wrap that code in a privileged block of code as well.

Here is a block of code I used in a another answer for getting a URL through the access controller.

 try 
 {
     final String imageURL = "http://www.google.com/intl/en_ALL/images/logo.gif";
     URL url = (URL) AccessController.doPrivileged(new PrivilegedAction() 
     {

         public Object run() 
         {
             try
             {
               return new URL(imageURL);
             }
             catch (MalformedURLException e)
             {
               e.printStackTrace();
               return null;
             }

        }  
      });  

     if(url == null)
     {
        // Something is wrong notify the user
     }
     else
     {
        // We know the url is good so continue on
         img = ImageIO.read(url);
     }

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