This is related to my  [other question](https://stackoverflow.com/questions/14581578/how-to-disable-function-keys-in-a-pdf-displayed-in-a-jsp-using-object-and-henc)... hope this one has a solution.

The requirement is to display a password-protected PDF in the browser but to pass the User password programatically. I create a PDF using Jasper and set the user password as follows:  

 exporter.setParameter(JRPdfExporterParameter.USER\_PASSWORD, userPassword);

As soon as the PDF is created, it has to be displayed in the screen. While displaying in the browser, the user should not be prompted to key in the password ans hence the password should be supplied by the application However, if the user downloads the PDF and then tries to open it, he should be prompted to enter the password.  

[Edit]: I am looking for an approach that does NOT involve licensed tools