java.lang.SecurityException : JAR manifest requested to run in all-permissons only

标签 java security manifest java-web-start manifest.mf

我们有一个通过 Java Web Start 下载并在本地计算机上运行的 Swing 应用程序。但是自动启动下载的 JNLP 文件后出现错误:

Application Blocked by Security Settings Name: Somename Location: http://localhost:8080 The Java security settings have prevented this application from running. You may change this behavior in the Java Control Panel.

此 URL 已添加到异常(exception)站点列表中。

Java 控制台此时不起作用,但如果在控制台中通过命令启动此 JNLP 文件:

javaws -verbose filename.jnlp

我们在跟踪中遇到一些异常:

java.lang.SecurityException: JAR manifest requested to run in all-permissons only: http://localhost:8080/path/to/jar/jarname.jar
    at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
    at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
    at com.sun.deploy.security.SandboxSecurity.isPermissionGranted(Unknown Source)
    at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
    at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main.access$000(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

该 Jar 文件的 list :

Manifest-Version: 1.0
version-time: 1926
version-number: 01.030.02.02
Ant-Version: Apache Ant 1.9.4
Application-Name: Somename
Permissions: all-permissions
version-date: March 4 2015
Created-By: 1.7.0_75-b13 (Oracle Corporation)
debug: on
Codebase: *

JNLP文件的结构:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="/warname/jnlp/filename.jsp">
    <information>
        <title>Title</title>
        <vendor>Company</vendor>
        <homepage href="http://www.foo.com"/>
        <description>Description</description>
        <offline-allowed/>
    </information>
    <resources>

        <j2se max-heap-size="512m" initial-heap-size="128m"
              version="1.3+"/>

        <jar href="/warname/jnlp/lib/jarname.jar"/>
        <jar href="/warname/jnlp/lib/jarname-2.jar" />

        <extension href="/warname/jnlp/help.jsp" name="Java Help"/>
    </resources>
    <application-desc
            main-class="path.to.class.Starter">
        <argument>-java.naming.provider.url=someurl</argument>
        <argument>-java.naming.factory.initial=someinitial</argument>
        <argument>-java.naming.security.principal=login</argument>
        <argument>-java.naming.security.credentials=password</argument>
        <argument>-locatorConfig=server</argument>
        <argument>-verbose</argument>
    </application-desc>
</jnlp>

Java 版本:1.7.0_75。

该异常的原因是什么?应用程序无法启动?

最佳答案

“所有权限”设置意味着应用程序需要访问您的某些系统资源。

在这种情况下,Oracle 表示您必须在 JNLP 和 list 文件中定义相同的权限。您应该查看 JNLP 文件的“安全”元素:

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

您可以找到更多信息here .

您可能必须更改 Java 安全设置。在 Windows 下,您的控制面板上应该有一个 Java 图标。对于Linux,您可以在JDK的bin目录中运行“ControlPanel”应用程序。

在“安全”选项卡下,您可以添加有关“localhost”的异常(exception)。这应该可以帮助您解决问题。

关于java.lang.SecurityException : JAR manifest requested to run in all-permissons only,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28873375/

相关文章:

visual-c++ - 为 VS2008 编译的二进制文件需要 DebugCRT 并行汇编,在 VS2010 中不起作用

java - 无法解析 "com.google.android.gms.gcm.GcmReceiver"?

java - 如何使用 JBOSS 调用 Java Web 服务

javascript - 验证 javascript 请求是否来自网站

spring - 为什么秒 :authentication ="name" show all user information?

c# - 添加应用程序 list 以确保跨 Windows XP、Vista 和 7 提升权限的可靠性如何?

java - 需要在Alfresco中通过aspose给word文档加水印

java - InvocationRequest.setInteractive() 在 maven-invoker-3.0.1 中不存在

php - 动态包括安全

java - 如何读取没有 list 的 war/jar 文件