java - can applet load jar dynamically? -
i load jar when specific button on applet clicked.
i want avoid user prompted security warning against jar when applet loaded, warning should appeared when button clicked.
i using webstart.
the code , errors follows.
policy.setpolicy(new policy() { public permissioncollection getpermissions(codesource codesource) { permissions perms = new permissions(); perms.add(new allpermission()); return (perms); } public void refresh() { } }); system.setsecuritymanager(null); classloader wcl = mainapplet.class.getclassloader(); url[] urls = new url[1]; string protocol="http"; string host="localhost"; int port = 8080; string file = "mb/download/ubikey-1.0.2.5.jar"; // string url = urlencoder("http://localhost:11090/multitoolkitdemo/download/ubikey-1.0.2.5.jar"); urls[0] = new url(protocol, host, port, file); try { ds = (downloadservice) servicemanager .lookup("javax.jnlp.downloadservice"); // determine if particular resource cached url url = new url( "http://localhost:8080/mb/download/ubikey-1.0.2.5.jar"); boolean cached = ds.isresourcecached(url, "1.0"); // remove resource cache if (cached) { ds.removeresource(url, "1.0"); } // reload resource cache downloadservicelistener dsl = ds.getdefaultprogresswindow(); ds.loadresource(url, "1.0", dsl); } catch (exception e) { e.printstacktrace(); } urlclassloader cl = new urlclassloader(urls, wcl); try { cl.loadclass("kr.co.jubikey.jubikeymanager"); } catch (classnotfoundexception e1) { // todo auto-generated catch block e1.printstacktrace(); }
error follows.
cache: memorycache replacing http://localhost:8080/mb/download/ubikey-1.0.2.5.jar (refcnt=2). was: url: http://localhost:8080/mb/download/ubikey-1.0.2.5.jar | /users/rnd/library/application support/oracle/java/deployment/cache/6.0/14/2e04ea0e-6e999798-1.0-.idx now: url: http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz | /users/rnd/library/application support/oracle/java/deployment/cache/6.0/32/5c664da0-4e2b1d6e.idx cache: reading signers 3607 http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz | /users/rnd/library/application support/oracle/java/deployment/cache/6.0/32/5c664da0-4e2b1d6e.idx cache: done readsigners(http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz) cache: read manifest http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz: read=130 full=7460 basic: plugin2classloader.istrustedbypolicy called basic: plugin2classloader.istrustedbypolicy returns false security: resource name "kr/co/jubikey/jubikeymanager.class" in http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz : java.lang.securityexception: attempted open sandboxed jar http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz trusted-library exception in thread "awt-eventqueue-2" java.lang.securityexception: attempted open sandboxed jar http://localhost:8080/mb/download/ubikey-1.0.2.5.jar.pack.gz trusted-library @ com.sun.deploy.security.cpcallbackhandler$parentelement.checkresource(unknown source) @ com.sun.deploy.security.deployurlclasspath$jarloader.checkresource(unknown source) @ com.sun.deploy.security.deployurlclasspath$jarloader.getresource(unknown source) @ com.sun.deploy.security.deployurlclasspath.getresource(unknown source) @ sun.plugin2.applet.plugin2classloader$2.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ sun.plugin2.applet.plugin2classloader.findclasshelper(unknown source) @ sun.plugin2.applet.jnlp2classloader.findclass(unknown source) @ sun.plugin2.applet.plugin2classloader.loadclass0(unknown source) @ sun.plugin2.applet.plugin2classloader.loadclass(unknown source) @ sun.plugin2.applet.plugin2classloader.loadclass(unknown source) @ java.lang.classloader.loadclass(classloader.java:411) @ java.lang.classloader.loadclass(classloader.java:357) @ com.ktnet.pki.multibrowser.util.jnlputil.loadjar(jnlputil.java:69) @ com.ktnet.pki.multibrowser.dialog.selectcertificatedlg$10.run(selectcertificatedlg.java:1945) @ java.awt.event.invocationevent.dispatch(invocationevent.java:251) @ java.awt.eventqueue.dispatcheventimpl(eventqueue.java:733) @ java.awt.eventqueue.access$200(eventqueue.java:103) @ java.awt.eventqueue$3.run(eventqueue.java:694) @ java.awt.eventqueue$3.run(eventqueue.java:692) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:76) @ java.awt.eventqueue.dispatchevent(eventqueue.java:703) @ java.awt.eventdispatchthread.pumponeeventforfilters(eventdispatchthread.java:242) @ java.awt.eventdispatchthread.pumpeventsforfilter(eventdispatchthread.java:161) @ java.awt.eventdispatchthread.pumpeventsforhierarchy(eventdispatchthread.java:150) @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:146) @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:138) @ java.awt.eventdispatchthread.run(eventdispatchthread.java:91)
i want avoid user prompted security warning against jar when applet loaded, warning should appeared when button clicked.
nope. not option. security checks performed before app. makes on screen.
Comments
Post a Comment