gpt4 book ai didi

java - 提供 Applet 安全异常的后备方案

转载 作者:行者123 更新时间:2023-12-01 15:27:37 27 4
gpt4 key购买 nike

我有一个小程序需要以某些权限运行,这意味着加载时会显示一条警告消息。如果用户拒绝警告消息,我想重定向到错误页面并解释发生了什么。有什么办法可以做到这一点吗?

我研究过让计时器运行并在特定时间段后重定向,但这并不那么准确,最好从弹出窗口中捕获响应。

如果用户拒绝警告,则会引发以下异常:

java.lang.SecurityException: attempted to open sandboxed jar [jar-file] 
as a Trusted-Library

在到达 init 函数之前抛出异常。

最佳答案

I looked in to having a timer running and redirect after a certain time period ..

..扩展它,添加一个取消计时器的 JS 函数,然后从小程序中调用该 JS,这就是您可以获得的最佳保护。

如果安全提示被拒绝,则对安全相关问题的 try/catch 可以适用于某些加载沙盒小程序的 JRE,但其他运行时(尤其是 Iced Tea JRE)在以下情况下根本不会加载小程序:安全提示被拒绝。

I have an Applet that is required to run with some privileges.. Basically we store a file there, the file can be any file and the size can therefore be any value. The user will choose this file themselves and they can choose anything from a 1kb textfile to a many-gigabyte movie. ..

如果可以保证用户拥有“下一代”- Plug-In 2 JRE(在 applet info. page 中提到),则可以在嵌入式小程序中使用 JNLP API。 JNLP 服务为沙盒应用程序提供对本地磁盘的访问。看这个demo of the JNLP file services

但是有一个小问题。没有选项可以保留用户选择的文件的路径。在这种安全性较低的环境中,JRE 不提供 File,而是提供 JNLP API FileContents 对象。它不会提供路径并且不可序列化。但如果用户愿意每次运行时选择文件,那么它是可行的。

<小时/>

..这让我想起了。也许是启动可信应用程序的更好选择。是使用 Java Web Start 提供自由 float (小程序或)框架。如果用户拒绝,它永远不会出现在屏幕上,但他们可以随时再次单击启动按钮(再次提示)。

关于java - 提供 Applet 安全异常的后备方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9978522/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com