Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, My original goal was to generate a password protected .xls file using Jasperreports. I was able to do the generation of said file. The problem is the "password ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    7

    How to password protect an existing file in linux using java


    Hi all,

    My original goal was to generate a password protected .xls file using Jasperreports. I was able to do the generation of said file. The problem is the "password protecting" part. I can't seem to find any tool or Api that would do the trick and that linux would accept.

    So now I am hoping to find a way to password protect an existing file (any file) in linux instead (using java codes).

    Thanks in advance for any suggestion that you could come up with. Please please do help. Thank you.

  2. #2
    Just Joined!
    Join Date
    Oct 2005
    Location
    Mesquite TX USA
    Posts
    6
    Quote Originally Posted by kazeopeia View Post
    Hi all,

    My original goal was to generate a password protected .xls file using Jasperreports. I was able to do the generation of said file. The problem is the "password protecting" part. I can't seem to find any tool or Api that would do the trick and that linux would accept.

    So now I am hoping to find a way to password protect an existing file (any file) in linux instead (using java codes).

    Thanks in advance for any suggestion that you could come up with. Please please do help. Thank you.
    what you really want to do is encrypt the file. Here is a thread from stackoverflow you may find very useful.

    stackoverflow.com/questions/5307499/how-to-encrypt-a-file-in-java-using-aes

  3. #3
    Just Joined!
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    33
    Actually (and for Java), look up the way to do it manually on the terminal in "shell command"
    THEN
    use System.exec() in your java code in the servlet or program.
    System class in Java represents the machine and OS running , the exec is a programmatic command line for the current OS shell.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,599
    dako has the right idea. You can't really do what you want in Linux. Encrypting the file with something like PGP is a reasonable alternative. I know that Microsoft has the ability to let you password protect any Microsoft Office file, but those are proprietary API's, and just creating an xls file won't let you do that from Linux. Not without a lot of pain and suffering to reverse-engineer their code and encrypted file structures...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •