aggelos Posted September 23, 2006 Share Posted September 23, 2006 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 More sharing options...
rsilverns.sympatico.ca Posted September 25, 2006 Share Posted September 25, 2006 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 More sharing options...
aggelos Posted September 26, 2006 Author Share Posted September 26, 2006 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 report2. Fill the report3. printbut 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 More sharing options...
rsilverns.sympatico.ca Posted September 26, 2006 Share Posted September 26, 2006 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 More sharing options...
aggelos Posted September 27, 2006 Author Share Posted September 27, 2006 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 *.classkeytool -genkey -alias signFiles -keystore appletstore -keypass XXX -dname "cn=echarry" -storepass XXXjarsigner -keystore appletstore -storepass XXX -keypass XXX -signedjar impresion.jar imprimir.jar signFileskeytool -export -keystore appletstore -storepass XXX -alias signFiles -file AppletImpresion.cerkeytool -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 More sharing options...
rsilverns.sympatico.ca Posted September 27, 2006 Share Posted September 27, 2006 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 More sharing options...
aggelos Posted September 27, 2006 Author Share Posted September 27, 2006 Hi rsilver,i'm following the same steps showed in the sun web, here is the url http://java.sun.com/developer/technicalArticles/Security/Signed/ ... it's very similar to your steps, but i really don't understand where i give the rigth permissions to a specific file.... i really, really appreciate ur help THANKS a LOT Viviana Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted September 27, 2006 Share Posted September 27, 2006 When I used the methods above, I never really worried about signing permissions... since I am signing my applet I wanted the applet to be able to print and do File IO so I just signed for all permissions I guess. As for implementing specific permissions I am not sure... why not just implement them all? Link to comment Share on other sites More sharing options...
aggelos Posted September 28, 2006 Author Share Posted September 28, 2006 i just did it, but it doesn't work yet :S:( Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted September 28, 2006 Share Posted September 28, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now