我有一個JAVA Applet來執行數字簽名,證書驗證等。它有一個有效的證書籤名,它有一個正確的清單(我想)與值:JNLP「JVM共享,不允許設置安全管理器」錯誤
Permissions: all-permissions
Specification-Title: Applet Certificados digitales
Specification-Version: v1.3
Specification-Vendor: mycompany
Application-Name: Applet Java mycompany
而且,它完美的作品,變成「小程序」標籤,由於NPAPI友好的瀏覽器(僅適用於Firefox的測試和IExplorer)。它已經運行了很多年...
現在我想讓Chrome和Edge用戶使用它,通過使用JNLP。 而這裏幾乎沒關係。我說「幾乎」,因爲我可以讀取商店證書,訪問我的ASP.NET WebApi,執行數字簽名......但現在我無法打開智能卡來讀取證書,因爲SecurityException在設置安全管理器時:
public SmartCardProvider_SecurityManager(final ApduConnection conn) {
super(NAME, VERSION, INFO);
defaultConnection = conn;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
if (!(System.getSecurityManager() instanceof SmartCardProvider_SecurityManager)) {
System.setSecurityManager(new SmartCardProvider_SecurityManager(System.getSecurityManager()));
// Exception -> JVM Shared, not allowed to set security manager
}
....
凡
private static final class SmartCardProvider_SecurityManager
extends SecurityManager { .....
這是我的JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="" href="thefile.JNLP">
<information>
<title>mycompany - JAVA apps</title>
<vendor>mycompany</vendor>
<homepage href="http:\\www.mycompany.com" />
<description>the description</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="APPLET_NAME.jar" main="false" />
</resources>
<applet-desc documentBase=""
name="the_name"
main-class="myjavanamespace.clsApplet"
width="450"
height="250">
<param name="..... /> some ciphred params ...
<param name="permissions" value="all-permissions" />
</applet-desc>
我最後的嘗試是添加此參數:
<param name="separate_jvm" value="true"/>
但我得到同樣的異常。我沒有想法,所以任何幫助將不勝感激。
當前運行環境:
Java插件11.72.2.15
使用JRE 1.8.0_72-b15的Java的熱點(TM)64位服務器VM
該applet是否需要嵌入到網頁中?我懷疑在一個自由浮動(非嵌入式)applet中獲取單獨的JVM會容易得多。 –
@AndrewThompson嗨,事實上,當它嵌入到網頁中時,我使用JSObject通過JS + Web方法與服務器交互。在這裏所有的確定。對於chrome和edge,通過JNLP打開它,然後使用ASP.NET WebApi。也許我可以在這種情況下使用另一個「主」void來打開它在JFrame,例如(或者我可以投降,並開發一個獨立的Java應用程序)? – Caveman
*「我使用JSObject通過JS + Web方法與服務器交互。」* [嵌入式applet的天數編號](https://blogs.oracle.com/java-platform-group/entry/moving_to_a_plugin_free)。要麼將功能遷移到純JS(如果可能的話,我會推薦)或者啓用更多的桌面應用程序。直接與Web服務層進行通信。別的什麼都會浪費時間。 –