Jump to content

Sing applet in a web app


aggelos

Recommended Posts

hi all,

i'm programming a web app that shows a jasperreport in a jsp code and it has an option to print that report showing to the user the print dialog, so i programmed that the print button was an applet and the print dialog arise at the client and not in the server side. until here everethig is ok and all sounds good but when i'm trying to sign the applet to access to the .jrprint from the jasper report and trying to print i jave to sent to the applet two .jar's files: one to the jasper library and the other to the applet certification. Does any body knwos how can i sen two .jar's to the same applet?

 

i really apreciate if someone can takes a minute to help me with this problem.

 

Thanks a lot,

 

Viviana

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

You need to refer to the other library jar files in your applet tag for the print applet.

 

<applet code=Animator.class

archive="jars/animator.jar, jars/jasperreports.jar"

width=460 height=160>

<param name=foo value="bar">

</applet>

 

etc. etc. The archive tag will point to the relevant jar files. To print you will also need to sign your applet for appropriate security abilities. Do a google on this for more info.

Link to comment
Share on other sites

Hi all,

 

First of all, rsilver thanks for ur help, it was just on time... well, now i have other problem... When i want to print, i do the following steps:

1. Load the .jasper report

2. Fill the report

3. print

but when i try to load the .jasper, it returns me null.

I tryed to insert the .jasper file in the .jar and put it in the applet package, but nothing works...

 

please, Does any body knows how can i solve it? :(

 

Thanks,

 

Viviana

Link to comment
Share on other sites

I havn't loaded the report from within a jar file yet, although I am sure there is some mechanism to do so.

 

However, another option is to place the .jrxml file in the same folder on your web server as your APPLET jar... and then in the applet class you can call the getCodeBase() method which will return that folder as a URL. Then append the filename to it and it should work.

Link to comment
Share on other sites

Hi rsilver,

Thanks again for ur help :blush: ... I really like ur option and i implemmented it in my project, then i signed the applet like this:

jar cvf imprimir.jar *.class

keytool -genkey -alias signFiles -keystore appletstore -keypass XXX -dname "cn=echarry" -storepass XXX

jarsigner -keystore appletstore -storepass XXX -keypass XXX -signedjar impresion.jar imprimir.jar signFiles

keytool -export -keystore appletstore -storepass XXX -alias signFiles -file AppletImpresion.cer

keytool -import -alias viviana -file AppletImpresion.cer -keystore raystore -storepass viviana

 

and finylly i modified the .java.policy file with:

keystore "\C:\Documents and Settings\echarry.YCSA\jbproject\Applet\arte\applets\raystore";

grant signedBy "viviana", codeBase "fiel:{tomcat.home}/arte/applets"{

permission java.io.FilePermission "reportes/*","read";

};

 

but when i try the applet, it still shows me de message : java.security.AccessControlException: access denied (java.io.FilePermission arteappletsreportesComputador.jasper read)

 

Do u know how can i configure my .java.policy correctly?:S

 

THANKS A LOT,

 

Viviana

 

rsilver@bfm.bm wrote:

I havn't loaded the report from within a jar file yet, although I am sure there is some mechanism to do so.

However, another option is to place the .jrxml file in the same folder on your web server as your APPLET jar... and then in the applet class you can call the getCodeBase() method which will return that folder as a URL. Then append the filename to it and it should work.
:blush:
Link to comment
Share on other sites

I think you may have incorrectly signed the jar file. Your applet's web browser it is being run in should just read the jar file signature and take the authorization confirmation from there... if I was going to sign a jar file I would....

 

1. Generate a key:

c:\keytool -genkey -alias <ALIAS> -keystore <KEYSTORE FILE>

 

where <ALIAS> is alias for your cert... anything really.

<KEYSTORE_FILE> is file that the cert will be stored in... I prefer to use a .jks extension just for conventions sake.

 

2. Sign your jar file:

c:\jarsigner -keystore <KEYSTORE_FILE> -signedjar <FINAL_JAR_NAME> [uNSIGNED_JARFILE] <ALIAS>

 

3. Verify signature: jarsigner -verify <FINAL_JAR_NAME>

 

The example is a bit basic, but you should be able to follow through start to finish if you follow these basic guidelines.

Post edited by: rsilver@bfm.bm, at: 2006/09/26 18:10

Link to comment
Share on other sites

Try following the steps in that article up to where it talks about exporting a public key. If you do that, does it let you run your applet, but with first prompting for permission? That is what I usually did... prompts the user to approve the applet rather than an automatic approval. This is more feasible since you don't want to distribute the cert "always".

 

If you require more assistance lets take this offline till we resolve it, email me and we can start working on it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...