473,785 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a DLL from a Java Applet

4 New Member
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 10739
r035198x
13,262 MVP
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
smthames
4 New Member
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 MVP
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
smthames
4 New Member
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 MVP
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
smthames
4 New Member
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 RuntimePermissi on.loadLibrary for my library as well.
Jan 23 '07 #7
r035198x
13,262 MVP
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 RuntimePermissi on.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 New Member
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
9874
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 ********************************** package Celcom.Client;
5
13647
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 (running IIS 6). I've written a little test applet that should call a helloWorld function in the dll, but when I use System.loadLibrary, it gives me this security warning :
2
6928
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 a type mismatch. It is positively because of the boolean(java primitive)parameter. It goes fine if I change this parameter to int or String. This inteface has a lot more methods which works fine, it is just the
1
1845
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 JSObject scripting context to a javascript function. This function takes the object and reads the properties and updates a screen.
2
9520
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=".." jreversion="1.5"
2
9753
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 longer able to call my Java method, instead I get: Error: document.CameraViewer.setInterval is not a function How does one use the object tags and call Java methods? --
2
7374
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 and hangs. The Java console offers no clues. The server serves the aspx page that contains the control, view source shows the expected html. However, the applet does nothing. I'm integrating Quadbase ExpressReport into a site. TIA. <%@ Page...
5
3542
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 to read an object, that I have saved before in a file called "eco.net", in an applet with the readObject() method: import java.applet.*; import java.io.*; public class TestApplet extends Applet { public void init() {
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.