• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

sharing classes among signed applets

I have quite a number of signed applets, and all applets need to use some common classes, is there any good way to share the classes?

Currently the common classes are put in some JAVA packages, although recompilation is not needed, they have to be included in each applet (another inconvenience is that I have to duplicate the common class files for each applet during signing) which is quite troublesome, especially when some code is to be changed in the common class.

Any good solution?  (must work for both IE/Netscape)
0
faster
Asked:
faster
  • 4
  • 3
  • 3
1 Solution
 
vladi21Commented:
try:

a.jar - classes of 1st applet
b.jar - classes of 2nd applet common.jar - common clases
 
HTML for 1st applet
<applet arhcive="a.jar;common.jar">
 
HTML for 2nd
<applet arhcive="b.jar;common.jar">

make all methods public in common jar
0
 
JodCommented:
The bearer of bad news...

I thought you had to use a cab file to get signed code in IE?

Also Netscape before 4.5 will only open the first jar file.

To get reliable signed code that is fairly backwardly compatible in both IE and NN I think you are going to need something like this:

<applet code="MyApplet.class" ARCHIVE="MyApplet.jar" width=600 height=350>
<param name="CABBASE" value="MyApplet.cab">
</applet>

with separate signed cab and jar files. I would be interested to know if there is a way around this that works.

[
EG: from MSDN:

Question 5
Can I sign a Java class file for use with Internet Explorer?

A. Although it is possible to digitally sign a Java class file and verify the signature using the ChkTrust utility, Internet Explorer does not recognize the class as signed and present a certificate to the user at runtime, furthermore, the class is not considered trusted by the Microsoft VM. Presently, you need to place the classes within a CAB file, which can then be signed.


Question 6
Will the Microsoft virtual machine support the JAR file format?


Answer
JAR support is the same as ZIP. JAR = ZIP + manifest. It will support uncompressed and compressed JAR levels 0 and 1, but not signed JAR. If you need Java security (beyond sandbox), on Internet Explorer 4.0 you need to use a signed CAB file. This applies to all fine grained Java security (including running in a sandbox on the local computer using the package manager).
]


A definitive resource on signing is here, that may help you:

http://www.suitable.com/CodeSigningBoth.shtml#top

There is also a script here for creating and packaging both jar and cab files in one easy(er) step.

0
 
fasterAuthor Commented:
I am only interested in the sharing of class, not how to use signed applet.  Yes I use cab for IE and JAR for Netscape.

I need a way that works for both IE and Netscape, and I need to support Netscape 4.0
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
JodCommented:
If you need to support nescape 4.0 then you can only have one jar file.

So for NN you would need to combine the common.jar vladi21 suggests with the b.jar, for example, and make a single jar file. IE is fine with 1 or more jar files or cab files.

The classes live in a common package which is imported into and used in many applets, so I'm a bit unclear about what else you mean by sharing the classes other than to package them in with your applets as valdi21 suggests.
0
 
fasterAuthor Commented:
that is what i am doing now, but I want to avoid generating each jar file again when I change the common class
0
 
fasterAuthor Commented:
I tried Netscape 4.06 but it works fine for two .jar files.  what is the lowest version of netscape that supports this feature? Where I can get information on this?
0
 
vladi21Commented:
Does Netscape support multiple JAR files per archive tag?
In 4.0.5, yes, this feature is supported.  In prior versions, it is not.  You will have to create one single JAR archive containing all of your files.

also look:
Use a JAR/ZIP/CAB file with an Applet
http://codeguru.developer.com/java/articles/547.shtml

Code signing resources:
Creating Signed, Persistent Java Applets
http://www.ddj.com/articles/1999/9902/9902h/9902h.htm

http://www.javasoft.com/products/jdk/1.1/docs/guide/security/index.html
http://java.sun.com/security/signExample/index.html 
http://www.verisign.com/library/guide/developer/signing/index.html
http://www.suitable.com/Doc_CodeSigning.shtml
http://www.securingjava.com/appdx-c/
http://tactika.com/realhome/javaht/java-s1.html
http://www.fastlane.net/~tlandry/javafaq.txt

MS:
http://www.thawte.com/support/developer/ms.html
http://www.developer.com/journal/techworkshop/curr.html
http://www.verisign.com/library/guide/developer/authenticode/index.html
http://msdn.microsoft.com/library/psdk/crypto/cryptotools_6cdv.htm
http://msdn.microsoft.com/library/psdk/crypto/portaltool_3u3p.htm

NN:
http://developer.netscape.com/docs/manuals/signedobj/
http://developer.netscape.com/docs/manuals/signedobj/javadoc/Package-netscape_security.html
http://developer.netscape.com/docs/manuals/signedobj/targets/contents.htm
http://developer.netscape.com/support/faqs/objfaq.html
http://developer.netscape.com/docs/manuals/deploymt/4_5PREFS.HTM

NN: Bypass the need for a certificate
Netscape provides a way to accept a codebase as trusted (then a certificate is not needed). This can be useful during development or in a private Intranet. In the Netscape Users directory, there is a file called prefs.js. Adding the line user_pref("signed.applets.codebase_principal_support", true);

will enable JAR file without a certificate to request privileges on your machine. If you agree, it will be possible for an Applet to lauch a program, write a file on your hard disk or print on the printer. You will still have to ask for privileges in your program using the Netscape capabilites classes.
Another way is to lower general security setting to more allow more freedom when running applets locally. Add or modify the following entries in the prefs.js: user_pref("unsigned.applets.low_security_for_local_classes", true);
user_pref("signed.applets.local_classes_have_30_powers", true);
user_pref("signed.applets.low_security_for_local_classes", true);
user_pref("signed.applets.verbose_security_exception", true);


Then you don't need to asked for privileges for local classes.
When adding or modifying the file prefs.js, Netscape must not be running because your modification will be overwritten. So shut down Netscape, edit the prefs.js and then restart Netscape.
0
 
fasterAuthor Commented:
do you any restriction in Netscape JNI for versions prior to 4.06?  I have a JNI DLL which works for 4.06 and above but crash for lower versions.
0
 
vladi21Commented:
0
 
JodCommented:
FYI faster...

I've been looking for this stuff (http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=10215402
) regarding this q but couldn't find it, from one of my previous PAQ's.

This link here gives the info I originally found out about NN 4.5 not supporting multiple Jar files.

As luck would have it The Swing Connection site is only partially working at the moment, but when it is up again look here for a page of useful info on explorer and navigators handling of archive files:

http://java.sun.com/products/jfc/tsc/web/applets/applets.html 


Also, from the second page here:

http://www.javaworld.com/jw-07-1998/jw-07-jar.html 

To quote...

"Navigator will throw a java.lang.NoClassDefFoundError when a class file in A.jar references a class in B.jar. Navigator 4.05 and the JDK1.1 support patch for Navigator 4.04 supposedly fix this problem..."

So you may be able to fix older versions of NN if necessary anyway.



0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now