I currently have a finance calculator applet that at the users request generates a PDF of the information calculated for the user. When it is generated, the PDF is created locally, and a JFileChooser allows the user to move the PDF to the destination on their machine of their choosing.
A certificate is required for the JFileChooser to run. What can I do to deliver the PDF to the user as an alternative to the JFileChooser and signing the applet?
From the official Java Applet tutorial:
When launched by using JNLP, unsigned applets can also perform the
following operations:
* They can open, read, and save files on the client.
Check this out as an example.
If you have to stick to traditional applets, you should sign the jar, even if that means self-signing (I think in this case a warning is displayed, but the user can proceed).
Use this method:
URL url = new URL(getCodeBase().getProtocol(),
getCodeBase().getHost(),
getCodeBase().getPort(),
"/your_pdf_file");
getAppletContext().showDocument(url);
It would just prompt the user to download the file or view it inline
EDIT: This is only useful if the Server is generating the PDF and not the Client Applet
Related
I would like to create a notes mail from some html source (with possibly inline image and attachments) using java through DIIOP. I tried to use mime item to do that, but sign and encrypt would need internet certs. So rich text seems to be the only choice, but I could not find any java API to import html into richtext. In notes client GUI, one can import from text/html. And also I noticed that MIME mail exported from inbox are "Itemized by DIIOP Server". Is there any way I can programmatically import html into lotus notes message so that sign and encrypt can be used with Lotus Notes internal certs.
Thanks and Regards,
Shing
You should be able to encrypt using Java via DIIOP, but you can't sign that way.
You need a private key in order to sign a message or document. The low-level Notes APIs expect the private key to be located in the current ID file for the session. When you are using DIIOP. Your Java code is running locally and it does not have access to your user ID file. The low-level Notes APIs don't run on the same machine that the Java is running on. There usually isn't even a Notes or Domino installation on the code where the Java code is running, so the code for the low-level APIs isn't even available to the JVM.
In a DIIOP configuraiton, the low-level Notes API code is running on the Domino server. The only ID file it has access to is the server ID file, and it will not allow you to sign using the server's private key.
Eventually find a solution, abeit rather hacky. create a document using MIME, then save to database, then close the session. The open a new session, and get the saved document, it is converted to richtext by the Domino Server, but there are some traces of MIME, export to DXL using DXLExporter. In the exported DXL, remove the items "MIME_Version" and "$MIMETrack". Inline image of type other than jpg and gif (png and gif) are not handled properly, have to play around the XML DOM a bit to fix it, then import the fixed DXL using DXLImporter, and there you have a converted Richtext document, rather like what you get from importing HTML file in Note Client GUI. Better than none.
I know solution of the above problem using HTML form in which user chooses a file from computer and upload it and then download it but how to do it without using HTML with the already given path of file.
Thank you For your concern in Advance.
I assume the scenario is that the user accesses your server from a browser.
In this case you will not be able to access the file system given file paths. Only the user can grant access to certain files by selecting them in a file upload input.
If the user uses a mobile/desktop application that sends the file to your server, you must implement the upload in the app itself.
I have generated a PDF object from scratch using PDFjet in a Java Applet i.e. I did NOT generate it on the server. But how can I invoke a "file download" prompt to serve this PDF without sending it to the server? I do not have a HTTPRequest or response.
There are two options I can think of for saving the document to disk.
Digitally sign the applet, get the user to accept the trusted code when prompted, offer the user a file chooser to specify a location, then save it to that location.
Use the JNLP API files services to do basically the same thing.
There is any way (from browser) to read local file without open dialog?
Can be used: javascript, flash, or java.
Goal: when you paste text in WYSIWYG with images from MS Word, there will be links to image files. Like "file:///C:/Users/username/AppData/Local/Temp/msohtmlclip1/01/clip_image001.jpg". I want to read this files, upload to server and replace local path.
Accessing the disk contents from the browser without the user permission is a security risk. As such, to do that with Java you need your applet signed and the user allowing it to run.
A Java applet can do this, but it would need to be signed with an SSL certificate from a trusted authority, otherwise the applet would not be run with a security exception thrown.
You'd use any standard Java approach to loading and uploading the file (Apache Commons FileUtils and HttpClient?); if you're new to Java then there may be simpler solutions.
Scenario: server provides same Webstart Applet to many different (but authenticated) clients. Each Applet has to "know" which client it is on. Therefor the server has to be able to pass some parameters to the client, which is then read by the Applet, running on that client.
Is it possible for a Webstart Applet to access the cookies of the web browser from which it was launched?
Is it possible for a Webstart Applet to access the URL by which it was identified?
Some other options?
EDIT: Perhaps Webstart Applet is a wrong term. I mean just a Webstart Client App.
See the applet-desc element in JNLP File Syntax for details.
Addendum: See also Accessing Cookies.
More pertaining to your 2nd point. URL query parameters can be parsed using JavaScript and added to the applet element. Attributes in the applet element will add to, or overwrite, the values set in the JNLP file.