Current Position:Home > Java Applets and .java.policy

Java Applets and .java.policy

Update:10-11Source: network consolidation
Advertisement
Hi.
We are developing an applet that need to access to the file systems and anothers properties, like user.home. To do this and don't modify the java.policy of the jre, we create a .java.policy file into user home. The content is:
grant {
permission java.util.PropertyPermission "user.name", "read";
permission java.util.PropertyPermission "user.home", "read, write";
permission java.util.PropertyPermission "java.library.path", "read, write";
permission java.lang.RuntimePermission "accessClassInPackage.org.mozilla.jss.*";
permission java.io.FilePermission "${user.home}/", "read";
permission java.io.FilePermission "${user.home}/-", "read, write";
With this configuration it works fine in Linux with Iceweasel, but in windows it's not work (firefox nor internet explorer)!.
The error is:
[SignApplet]: M�dulo iniciado.
[SignApplet]: Cliente de firma iniciado.
[ESignatureFormatFactory]: Buscando formato 'CMS'... encontrado!
[SignManager]: Firmando digitalmente...
java.lang.NullPointerException
     at java.util.Properties$LineReader.readLine(Unknown Source)
     at java.util.Properties.load(Unknown Source)
     at com.telventi.afirma.cliente.utilidades.MimeTypeHelper.<init>(MimeTypeHelper.java:23)
     at com.telventi.afirma.cliente.utilidades.MimeTypeHelper.getInstance(MimeTypeHelper.java:32)
     at com.telventi.afirma.cliente.actions.ACommonAction.<clinit>(ACommonAction.java:59)
     at com.telventi.afirma.cliente.signatureformat.signaturemanager.ASignManager.warn(ASignManager.java:405)
     at com.telventi.afirma.cliente.signatureformat.signaturemanager.SignManagerMSIEWin32.signDigitally(SignManagerMSIEWin32.java:63)
     at com.telventi.afirma.cliente.signatureformat.CMSSignatureFormat.createSignedInfo(CMSSignatureFormat.java:1562)
     at com.telventi.afirma.cliente.signatureformat.CMSSignatureFormat.signExplicitHash(CMSSignatureFormat.java:265)
     at com.telventi.afirma.cliente.signatureformat.signaturemanager.ASignManager.signHashElectronically(ASignManager.java:139)
     at com.tsol.afirma5.util.impl.AppletServiceImpl.generarFirma(AppletServiceImpl.java:60)
     at com.tsol.validacionCertificado.applet.TSolApplet.obtenerFirmaGenerada(TSolApplet.java:105)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
     at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
     at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
     at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
     at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
java.lang.ExceptionInInitializerError
     at com.telventi.afirma.cliente.signatureformat.signaturemanager.ASignManager.warn(ASignManager.java:405)
     at com.telventi.afirma.cliente.signatureformat.signaturemanager.SignManagerMSIEWin32.signDigitally(SignManagerMSIEWin32.java:63)
     at com.telventi.afirma.cliente.signatureformat.CMSSignatureFormat.createSignedInfo(CMSSignatureFormat.java:1562)
     at com.telventi.afirma.cliente.signatureformat.CMSSignatureFormat.signExplicitHash(CMSSignatureFormat.java:265)
     at com.telventi.afirma.cliente.signatureformat.signaturemanager.ASignManager.signHashElectronically(ASignManager.java:139)
     at com.tsol.afirma5.util.impl.AppletServiceImpl.generarFirma(AppletServiceImpl.java:60)
     at com.tsol.validacionCertificado.applet.TSolApplet.obtenerFirmaGenerada(TSolApplet.java:105)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
     at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
     at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
     at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
     at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
Caused by: com.telventi.afirma.cliente.exceptions.ClienteFirmaRuntimeException: Error al mapear el archivo de tipos.
     at com.telventi.afirma.cliente.utilidades.MimeTypeHelper.<init>(MimeTypeHelper.java:26)
     at com.telventi.afirma.cliente.utilidades.MimeTypeHelper.getInstance(MimeTypeHelper.java:32)
     at com.telventi.afirma.cliente.actions.ACommonAction.<clinit>(ACommonAction.java:59)
     ... 21 more
Caused by: java.lang.NullPointerException
     at java.util.Properties$LineReader.readLine(Unknown Source)
     at java.util.Properties.load(Unknown Source)
     at com.telventi.afirma.cliente.utilidades.MimeTypeHelper.<init>(MimeTypeHelper.java:23)
     ... 23 more
java.lang.Exception: java.lang.ExceptionInInitializerError
     at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
     at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
[SignApplet]: Invocando isInitialized.
Code where it fail is:
TYPES.load((com.telventi.afirma.cliente.utilidades.MimeTypeHelper.class).getResourceAsStream("mimetypes.properties"));
TYPES is Properties object.
When we modify the .java.policy file with permission java.security.AllPermission it work fine too, and this make to us think that this is a permission problem!.
Somebody has an idea???
Sorry for my english!

The Best Answer

Advertisement
Having to modify the policy file defeats the whole point of using applets in the first place. If you have to install anything (such as a new policy file) on the client machine, you may as well install a GUI program.
Either get yourself a digital certificate and sign the applet, or use an independent program instead.
  • File Access with unsigned Applet through editing the java.policy file Update:10-11

    I'am starting to lose my hair on this... I am trying to get an applet to run so that it can access the file system to move files on my local maschin. Because this applet is only running on my VM i can change the java.policy to avoid the signing of th

  • Java Applets and .java.policy Update:10-11

    Hi. We are developing an applet that need to access to the file systems and anothers properties, like user.home. To do this and don't modify the java.policy of the jre, we create a .java.policy file into user home. The content is: grant { permission

  • Applets et Java.policy Update:11-30

    I need some help to undestand the permissions associated to applets. My applet, created from a servlet app, needs data files, xml files in input and temporary xml files in output / input. When running it, I have the message : Error : Java.lang.except

  • How to handle the java.policy file ? Update:10-11

    Can somebody tell me how to handle the java.policy file? I always get java.net.SocketExceptions and java.security.AccessControlExceptions while connecting to an appserver from an applet. What do I have to write in the java.policy file, where do I hav

  • How add grant permission in java.policy Update:10-11

    hi master sir serch in my system C:\Program Files\j2sdk_nb\j2sdk1.4.2\jre\lib\security C:\Program Files\j2sdk_nb\_jvm\lib\security C:\Program Files\Java\j2re1.4.1_03\lib\security C:\Program Files\Java\jre1.5.0_10\lib\security sir i have many java.pol

  • ClassLoader & java.policy Update:10-11

    Hi , I am facing problem with the following code. ClassLoader loaderPrev = Thread.currentThread().getContextClassLoader(); ClassLoader loader = URLClassLoader.newInstance(new URL[]{new URL(CodeBase)} , loaderPrev ); ClassLoader loader = new URLClassL

  • Can distribution of a .java.policy file be eliminated Update:11-30

    Sorry for the stupid question, but I'm fairly new to the realm of dealing with Java security... I have an applet that I want to deploy worldwide as part of an upgrade to an existing website, but I've run into the following error: "Error getting conne

  • Does Java Plug-in Ignore java.policy Permissions? Update:11-30

    I am running Firefox 3.6.12 on Ubuntu Karmic with Java plug-in 1.6.0_22. I'm trying to run an Aventail OnDemand applet, and I keep getting I/O file-reading permissions exceptions in the Java console. I tried granting the permission in /usr/lib/jvm/ja

  • Java.policy setting Update:11-30

    Hi, I am writing an web based application using applets nadn eed to contact a MYSql database. I am getting Access Denied exception. In my java.policy file I added the following two lines : grant codeBase "http://mywebpage/"{ permission java.secu

  • Java.policy codebase ignored Update:11-30

    I've recently been trying to allow an applet on a local webpage to write to a file in the same folder. I've been using the following .java.policy file: grant codeBase "file:${user.home}/My Documents/folder/*" {   permission java.io.FilePermissio