473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Calling a DLL from a Java Applet

I have a pretty sophisticated applet running from several JARs. The main applet is in a signed JAR and performs local file accesses. This works fine. However, the applet in this signed JAR is instantiating a class from another JAR which inherits a class from yet another JAR and this superclass does a loadLibrary() call to load a local DLL. This is getting an access denied error.

All of these JARs are loaded as part of the APPLET tag. All these JARs are signed. Yet, I'm still getting the access denied error.

The reason for so many JARs is that the main applet does not always require access to this local library. In these cases, the library is not loaded.

Does anyone know the answer to these question:

If you have an applet running from a signed JAR that performs local system accesses (files, DLLs, etc.), is it required by the security layer that all local accesses occur from classes within the signed JAR from which the main applet was loaded?

Is it not possible to instantiate classes that perform local accesses from another JAR--even if the other JAR is signed as well?

Is there a way I can have the security layer allow this without loading all my local accesses into the signed JAR from which the main applet runs?
Jan 23 '07 #1
8 10713
r035198x
13,262 8TB
I have a pretty sophisticated applet running from several JARs. The main applet is in a signed JAR and performs local file accesses. This works fine. However, the applet in this signed JAR is instantiating a class from another JAR which inherits a class from yet another JAR and this superclass does a loadLibrary() call to load a local DLL. This is getting an access denied error.

All of these JARs are loaded as part of the APPLET tag. All these JARs are signed. Yet, I'm still getting the access denied error.

The reason for so many JARs is that the main applet does not always require access to this local library. In these cases, the library is not loaded.

Does anyone know the answer to these question:

If you have an applet running from a signed JAR that performs local system accesses (files, DLLs, etc.), is it required by the security layer that all local accesses occur from classes within the signed JAR from which the main applet was loaded?

Is it not possible to instantiate classes that perform local accesses from another JAR--even if the other JAR is signed as well?

Is there a way I can have the security layer allow this without loading all my local accesses into the signed JAR from which the main applet runs?
The jar that contains the class that loads the library must be signed as well otherwise the whole point of signing applets is defeated (People would sign only one applet and call all other naughty applets from it). Signing an applet affects the operations perfomable by instances of that applet not the performance/permissions of objects executing within the same context.
Jan 23 '07 #2
Thank you for responding. All the JARs in question are signed but I still get the access denied error.

The main applet class A, in JAR1, instantiates class B in JAR2. Class B instantiates class C from JAR2. Class C inherits class D from JAR3. Class D constructor calls loadLibrary(). All JARs are signed.

How should I change this to overcome the security violation?
Jan 23 '07 #3
r035198x
13,262 8TB
Thank you for responding. All the JARs in question are signed but I still get the access denied error.

The main applet class A, in JAR1, instantiates class B in JAR2. Class B instantiates class C from JAR2. Class C inherits class D from JAR3. Class D constructor calls loadLibrary(). All JARs are signed.

How should I change this to overcome the security violation?
Tricky then. Are sure you have followed all the steps mentioned here
Jan 23 '07 #4
Yes. The applet class A is loaded from signed JAR1 and performs several local accesses including file read/write and printing. However, all of these local accesses are performed by classes instantiated by class A and loaded from the same JAR (JAR1). Classes B, C, and D are loaded from other signed JARs.

I'm trying to determine if its necessary that classes B, C, and D must all be loaded from JAR1 as this is the JAR from which applet class A is loaded.

This would not be great as classes C and D will be used by other applets and, in some cases, applet class A does not always require classes B, C, and D so these JARs need not always be loaded.

BTW, classes C and D from signed JAR3 are JNI and access a DLL that reads the local USB ports. I don't know if this is significant.

Is there a way to configure the security polity that will allow this architecture or must I put all classes performing local accesses into the same signed JAR from which the applet class is loaded?

Here is the APPLET tag:

Expand|Select|Wrap|Line Numbers
  1. <applet archive="JAR3.jar, JAR1.jar, JAR2.jar" code="A.class" height="1" name="Editor" width="1">
  2. <param name="scriptable" value="yes">
  3. <param name="mayscript" value="yes">
  4. </applet>
Jan 23 '07 #5
r035198x
13,262 8TB
Yes. The applet class A is loaded from signed JAR1 and performs several local accesses including file read/write and printing. However, all of these local accesses are performed by classes instantiated by class A and loaded from the same JAR (JAR1). Classes B, C, and D are loaded from other signed JARs.

I'm trying to determine if its necessary that classes B, C, and D must all be loaded from JAR1 as this is the JAR from which applet class A is loaded.

This would not be great as classes C and D will be used by other applets and, in some cases, applet class A does not always require classes B, C, and D so these JARs need not always be loaded.

BTW, classes C and D from signed JAR3 are JNI and access a DLL that reads the local USB ports. I don't know if this is significant.

Is there a way to configure the security polity that will allow this architecture or must I put all classes performing local accesses into the same signed JAR from which the applet class is loaded?

Here is the APPLET tag:

Expand|Select|Wrap|Line Numbers
  1. <applet archive="JAR3.jar, JAR1.jar, JAR2.jar" code="A.class" height="1" name="Editor" width="1">
  2. <param name="scriptable" value="yes">
  3. <param name="mayscript" value="yes">
  4. </applet>
If you have the time to check you could try but did you check the exact origin of the exception? Which class is throwing the exception?
Jan 23 '07 #6
Ok, I've learned something.

I moved the loadLibrary() call to the init() method of the applet and was able to load the library. The way this applet works, the init() method does nothing more than read some parameters. The actual functioning of the applet begins when the web page calls another method in the applet class using JavaScript.

Up until now, I have had no local access security problems when accessing the applet this way. I seem to be having a problem with loadLibrary().

Is it a security violation to call an applet class method from within Javascript? Is the security policy file superflous in this case? If so, why am I not having any problems with doing local file accesses and printing?

Obviously, I'm not well versed in the Java security architecture. Any help here is appreciated.

Currently, my applet policy file indicates 'AllPermission'. I added a RuntimePermission.loadLibrary for my library as well.
Jan 23 '07 #7
r035198x
13,262 8TB
Ok, I've learned something.

I moved the loadLibrary() call to the init() method of the applet and was able to load the library. The way this applet works, the init() method does nothing more than read some parameters. The actual functioning of the applet begins when the web page calls another method in the applet class using JavaScript.

Up until now, I have had no local access security problems when accessing the applet this way. I seem to be having a problem with loadLibrary().

Is it a security violation to call an applet class method from within Javascript? Is the security policy file superflous in this case? If so, why am I not having any problems with doing local file accesses and printing?

Obviously, I'm not well versed in the Java security architecture. Any help here is appreciated.

Currently, my applet policy file indicates 'AllPermission'. I added a RuntimePermission.loadLibrary for my library as well.
I'm afraid it looks as if this is going over my head. I hope someone will be able to give you the answers you want. I will post if I think up anything I think might be of use.
Jan 23 '07 #8
twall
1
Applet methods called from JavaScript need to explicitly invoke the proper security context.

Expand|Select|Wrap|Line Numbers
  1.          AccessController.doPrivileged(new PrivilegedAction() {
  2.             public Object run() {
  3.                 // do your stuff here
  4.                 return null;
  5.             }
  6.         });
Sep 8 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
5
by: Rowland | last post by:
Hi, I know this question has prob. been asked a million times, but I couldn't find it in the FAQ, so here goes : I'm trying to write a Java applet to call a dll that resides on the web server...
2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
1
by: SPG | last post by:
Hi, We have an applet that has to support the SUN VMs as well as the MS VM. The applet receives updates from a server (via tcp or http) and wraps them up as objects and passes them using the...
2
by: Blondie21 | last post by:
Hi, I have a .jsp file in the following format: .... html headers, jsp code, html code... <jsp:plugin type="applet" code="path.in.packet.appletclassname.class" codebase=".."...
2
by: Neil Cherry | last post by:
I've done a fair amount of searching on this subject and I can call my Java methods with Javascript if I use the <applet></applet> tags but when I switch over to <object></object> tags I'm not...
2
by: MarkMurphy | last post by:
Is there a limitation in ASP.NET in this regard? From the aspx code below, I can successfully call a Java applet. If I try the identical thing in a user control ascx however, the control loads...
5
by: verteidi | last post by:
Hello everyone, I have been searching this forum for a solution to my problem, but unfortunately couldn't find anything so far. It would be very kind if you could take a look at this. I am trying...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.