Forum Stats

  • 3,838,625 Users
  • 2,262,385 Discussions
  • 7,900,710 Comments

Discussions

Error integrating a web applet and a SmartCard application

808981
808981 Member Posts: 27
edited Jan 13, 2011 12:49PM in Java Card
I have developed two codes separately: an applet who gets an String and makes some work with it and a console application that reads an String from a SmartCard (using javax.smartcardio package and some objects in JNA.jar).
The applet get the String from a constant String in the own class and the two codes works properly in a separate mode. The main purpose is to merge the two codes and get the applet to read the String from the Smartcard

In a first attempt to integrate the two codes, I get the following exception in the first line I try to access the SmartCard code:


java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.reflect.generics.reflectiveObjects)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
at sun.plugin2.applet.Applet2SecurityManager.checkPackageAccess(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at PinApplet.init(PinApplet.java:46)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Excepción: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.reflect.generics.reflectiveObjects)

After exhaust all the options in my mind, can anybody give me new ideas/reasons for this exception?
Tagged:

Answers

  • safarmer
    safarmer Member Posts: 2,829 Bronze Trophy
    edited Jan 11, 2011 1:42PM
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.reflect.generics.reflectiveObjects)
    	at java.security.AccessControlContext.checkPermission(Unknown Source)
    	at java.security.AccessController.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
    	at sun.plugin2.applet.Applet2SecurityManager.checkPackageAccess(Unknown Source)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at PinApplet.init(PinApplet.java:46)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Excepción: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.reflect.generics.reflectiveObjects)
    You need to sign your applet to access a smart card in the browser. Since it is a restricted resource (like the file system) you need extra security permissions.
    After exhaust all the options in my mind, can anybody give me new ideas/reasons for this exception?
    Google returned this: 1984190

    Cheers,
    Shane
  • 808981
    808981 Member Posts: 27
    The other thread you mentioned was started by me several months ago, but two of the users started to insult one to the other and I prefer to start a new one.
    About the sign of the applet, when I use the applet separately (without accessing to the SmartCard), the applet works properly and it's not signed.
    When I embedded the Smartcard access into the applet code, it's when the exception appears.
    By the way, my applet is not a .jar, it's an .class. It's possible to sign a .class file instead of a .jar file??

    Thanks for your contributions, Shane

    Dani
  • 808981
    808981 Member Posts: 27
    Reading the code, I have realized that the error was generated for the use of NotImplementedException exception from package sun.reflect.generics.reflectiveObjects
    I have used UnsupportedOperationException instead of the exception below.

    Anyway, I have to sign the applet, because when I am going to access the Smartcard code, the JVM launches an AccessControlException.
    I redirect this problem to another thread: 2159164

    Dani
  • safarmer
    safarmer Member Posts: 2,829 Bronze Trophy
    Hi,

    Even though your applet is only a single class, you need to package it in a JAR file so you can sign the JAR file. I am not aware of any way to sign a class file.

    Cheers,
    Shane
  • 808981
    808981 Member Posts: 27
    Thank you Shane. It's the same that other users have answered in the other thread and it's what I supposed :(

    Dani
  • safarmer
    safarmer Member Posts: 2,829 Bronze Trophy
    805978 wrote:
    Thank you Shane. It's the same that other users have answered in the other thread and it's what I supposed :(
    Is this a problem? Have you tried packaging as a JAR file so it can be signed?

    Cheers,
    Shane
This discussion has been closed.