Java 执行 jnlp 文件期间出现安全异常(主 jar 中缺少必需的权限清单属性)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21404830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 08:31:26  来源:igfitidea点击:

SecurityException during executing jnlp file (Missing required Permissions manifest attribute in main jar)

javajava-web-startjnlp

提问by Ripon Al Wasim

OS: Windows 7 64 bit

操作系统:Windows 7 64 位

Java: jdk1.7.0_51

Java:jdk1.7.0_51

I have a jnlp file. When I double click on this, exception is occurred as below:

我有一个 jnlp 文件。当我双击它时,发生如下异常:

Application Error: Unable to launch the application
Exception: java.lang.SecurityException: Missing required Permissions manifest attribute in main jar

采纳答案by moskito-x

JAR File Manifest Attributes for Security

用于安全性的 JAR 文件清单属性

The JAR file manifestcontains information about the contents of the JAR file, including security and configuration information.

JAR 文件清单包含有关 JAR 文件内容的信息,包括安全性和配置信息。

Add the attributes to the manifest before the JAR file is signed.
See Modifying a Manifest Filein the Java Tutorial for information on adding attributes to the JAR manifest file.

在签署 JAR 文件之前将属性添加到清单。
有关向 JAR 清单文件添加属性的信息,请参阅Java 教程中的修改清单文件。

Permissions Attribute

权限属性

The Permissions attribute is used to verify that the permissions level requested by the RIA when it runs matches the permissions level that was set when the JAR file was created.

Permissions 属性用于验证 RIA 在运行时请求的权限级别是否与创建 JAR 文件时设置的权限级别相匹配。

Use this attribute to help prevent someone from re-deploying an application that is signed with your certificate and running it at a different privilege level. Set this attribute to one of the following values:

使用此属性有助于防止有人重新部署使用您的证书签名的应用程序并以不同的权限级别运行它。将此属性设置为以下值之一:

  • sandbox - runs in the security sandbox and does not require additional permissions.

  • all-permissions - requires access to the user's system resources.

  • 沙箱 - 在安全沙箱中运行,不需要额外的权限。

  • all-permissions - 需要访问用户的系统资源。

Changes to Security Slider:

安全滑块的变化:

The following changes to Security Slider were included in this release(7u51):

此版本 (7u51) 中包含对安全滑块的以下更改:

  • Block Self-Signed and Unsigned applets on High Security Setting
  • Require Permissions Attribute for High Security Setting
  • Warn users of missing Permissions Attributes for Medium Security Setting
  • 在高安全设置中阻止自签名和未签名小程序
  • 需要高安全设置的权限属性
  • 警告用户缺少中等安全设置的权限属性

For more information, see Java Control Paneldocumentation.

有关更多信息,请参阅Java 控制面板文档。

enter image description here

在此处输入图片说明

sampleMANIFEST.MF

样本MANIFEST.MF

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_51-b13 (Oracle Corporation)
Trusted-Only: true
Class-Path: lib/plugin.jar
Permissions: sandbox
Codebase: http://myweb.de http://www.myweb.de
Application-Name: summary-applet

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_51-b13 (Oracle Corporation)
Trusted-Only: true
Class-Path: lib/plugin.jar
Permissions: sandbox
Codebase: http://myweb.de http://www.myweb.de
Application-Name: summary-applet

回答by bcjenkins

If you'd like to set this globally for all users of a machine, you can create the following directory and file structures:

如果您想为机器的所有用户全局设置此项,您可以创建以下目录和文件结构:

mkdir %windir%\Sun\Java\Deployment

Create a file deployment.config with the content:

使用以下内容创建文件 deployment.config:

deployment.system.config=file:///c:/windows/Sun/Java/Deployment/deployment.properties
deployment.system.config.mandatory=TRUE

Create a file deployment.properties

创建文件 deployment.properties

deployment.user.security.exception.sites=C\:/WINDOWS/Sun/Java/Deployment/exception.sites

Create a file exception.sites

创建一个文件exception.sites

http://example1.com
http://example2.com/path/to/specific/directory/

Reference https://blogs.oracle.com/java-platform-group/entry/upcoming_exception_site_list_in

参考https://blogs.oracle.com/java-platform-group/entry/upcoming_exception_site_list_in