Web Analytics Made Easy -
StatCounter RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper - CodingForum

Announcement

Collapse
No announcement yet.

RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper

    Sr about my E!
    i'm building a applet project about digital certificate.when i start my applet in cmd with appletviewer,throw "java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper"

    Code:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper)
            at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
            at java.security.AccessController.checkPermission(AccessController.java:546)
            at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
            at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1512)
            at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:266)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:298)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            at VNPT_CA.SmartCardSigner.VNPT_CA_Lib$1.run(VNPT_CA_Lib.java:74)
            at java.security.AccessController.doPrivileged(Native Method)
            at VNPT_CA.SmartCardSigner.VNPT_CA_Lib.VNPT_CA_Initialize(VNPT_CA_Lib.java:70)
            at VNPT_CA.Applet.VNPT_CA_Certificate.ListCert_Initialize(VNPT_CA_Certificate.java:81)
            at VNPT_CA.Applet.SmartCardSignerApplet.signSelectedFile(SmartCardSignerApplet.java:64)
            at VNPT_CA.Applet.SmartCardSignerApplet.access$000(SmartCardSignerApplet.java:20)
            at VNPT_CA.Applet.SmartCardSignerApplet$1.actionPerformed(SmartCardSignerApplet.java:40)
            at java.awt.Button.processActionEvent(Button.java:392)
            at java.awt.Button.processEvent(Button.java:360)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    java.lang.NullPointerException
            at VNPT_CA.SmartCardSigner.VNPT_CA_Lib.VNPT_CA_Initialize(VNPT_CA_Lib.java:92)
            at VNPT_CA.Applet.VNPT_CA_Certificate.ListCert_Initialize(VNPT_CA_Certificate.java:81)
            at VNPT_CA.Applet.SmartCardSignerApplet.signSelectedFile(SmartCardSignerApplet.java:64)
            at VNPT_CA.Applet.SmartCardSignerApplet.access$000(SmartCardSignerApplet.java:20)
            at VNPT_CA.Applet.SmartCardSignerApplet$1.actionPerformed(SmartCardSignerApplet.java:40)
            at java.awt.Button.processActionEvent(Button.java:392)
            at java.awt.Button.processEvent(Button.java:360)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    the code following cause above exception:

    Code:
      p11Getinstance = PKCS11.class.getMethod("getInstance", String.class,
                                    String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE);

    i was edit java.policy file in (java_home)/jre6/lib/security/ by adding permission:

    grant {
    .....
    .....
    permission java.util.PropertyPermission "java.home", "read";
    permission java.security.SecurityPermission "authProvider.SunPKCS11-FeitianPKCS";
    permission java.lang.RuntimePermission "createClassLoader";
    permission java.lang.RuntimePermission "getClassLoader";
    }
    and edit my code:
    Code:
      AccessController.doPrivileged(new PrivilegedAction() {
    
                    public Object run() {
                        try {
                            p11Getinstance = PKCS11.class.getMethod("getInstance", String.class,
                                    String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE);
                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                        return null;
                    }
                });
    but my applet does not still run success
    Please help me!
    Last edited by tsar4ever; Aug 19, 2011, 03:58 AM.
Working...
X