8 Replies - 35361 Views - Last Post: 10 February 2010 - 10:47 PM Rate Topic: -----

#1 jacob23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-January 07

Creating password protected files through java

Posted 09 January 2007 - 05:20 AM

hi,
I want to create password protected files using java api so that when the user tries to open a file, he is prompted for a password and only when he enters the correct password should he be allowed to open that file.
How do i achieve this in java?
Any help regarding this will be highly appreciated !!
Is This A Good Question/Topic? 0
  • +

Replies To: Creating password protected files through java

#2 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Creating password protected files through java

Posted 09 January 2007 - 07:02 AM

The answer heavily depends on which way you want to open your protected files.
If it is opened by your (java) program, you can simply encrypt it with a password upon saving, and decrypt it with something the user provides, and use some checksum or header to see if the result is valid - or some garbage due to bad password, some crypto APIs will do it for you right out of the box - rtm.
On the otherhand, if you meant encrypting files with a program (like a notepad file, or something), and you expect windows or notepad to ask you for the password, then it depends on the format of the file you use. Some can be password protected, some can not -like text files usually associated with notepad). In this case password protection works as described in the format's own documentation, and you have to research it a bit. I think password protection of zip files is possible with the core Java API, but you'll have to find the corresponding libraries or develop your own ones in all other cases.
Was This Post Helpful? 0
  • +
  • -

#3 jacob23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-January 07

Re: Creating password protected files through java

Posted 10 January 2007 - 12:03 AM

Thanks for the reply.
What i want is quite similar to your second point i.e.- I want to encrypt the file (which could be html,pdf,excel or ascii format) with a user saved password;save the file on the application unix server; and then send either the file (if its size is less than 2MB) or a link to the file location to the user in a mail. Now when the user tries to open this file, he should be prompted for a password and only if he enters the correct password should he be allowed to open the file.

I have found java apis which can achieve this for pdf and zip files. I was wondering if similar apis exist for the other formats as well?
Was This Post Helpful? 0
  • +
  • -

#4 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Creating password protected files through java

Posted 10 January 2007 - 05:39 AM

Good question, I think the OpenOffice libraries cover a pretty wide range of document formats, if you have the guts to dig into them. I'm not sure about the others.
However you could simply put every file into a password protected zip, although this way your users could save the files without the protection once uncompressed, and it would make putting password protection on the web access of the files more compelling, than protecting the files themselves.
Was This Post Helpful? 0
  • +
  • -

#5 sss1234jj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-December 07

Re: Creating password protected files through java

Posted 05 December 2007 - 04:49 AM

View Postjacob23, on 10 Jan, 2007 - 12:03 AM, said:

Thanks for the reply.
What i want is quite similar to your second point i.e.- I want to encrypt the file (which could be html,pdf,excel or ascii format) with a user saved password;save the file on the application unix server; and then send either the file (if its size is less than 2MB) or a link to the file location to the user in a mail. Now when the user tries to open this file, he should be prompted for a password and only if he enters the correct password should he be allowed to open the file.

I have found java apis which can achieve this for pdf and zip files. I was wondering if similar apis exist for the other formats as well?

Hi,i have a similar requirement.
As mentioned by u ,there is some way in core java api
to password protect a zip file..can u please give some light on that..
Thanks in advance..
Was This Post Helpful? 0
  • +
  • -

#6 hirachna  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-January 08

Re: Creating password protected files through java

Posted 15 February 2008 - 02:17 AM

View Postsss1234jj, on 5 Dec, 2007 - 04:49 AM, said:

View Postjacob23, on 10 Jan, 2007 - 12:03 AM, said:

Thanks for the reply.
What i want is quite similar to your second point i.e.- I want to encrypt the file (which could be html,pdf,excel or ascii format) with a user saved password;save the file on the application unix server; and then send either the file (if its size is less than 2MB) or a link to the file location to the user in a mail. Now when the user tries to open this file, he should be prompted for a password and only if he enters the correct password should he be allowed to open the file.

I have found java apis which can achieve this for pdf and zip files. I was wondering if similar apis exist for the other formats as well?

Hi,i have a similar requirement.
As mentioned by u ,there is some way in core java api
to password protect a zip file..can u please give some light on that..
Thanks in advance..



Hi,

I am looking for the similar solution, only difference is i will send those pdf by email. when user will try to open it , he has to enter the correct password.

I want to do it with java API, please guide me how can i do it. I have the code for zipping but not for passwrod protection.

Kindly help
Was This Post Helpful? 0
  • +
  • -

#7 robinxc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-April 09

Re: Creating password protected files through java

Posted 16 April 2009 - 09:03 PM

Did you get a solution for workbook protection using Java API?
Was This Post Helpful? 0
  • +
  • -

#8 Guest_Techfunda248*


Reputation:

Re: Creating password protected files through java

Posted 10 February 2010 - 10:43 PM

I Guess iText (http://itextpdf.com/) can be solution to it, but we might have to digg into a bit.
Was This Post Helpful? 0

#9 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10492
  • View blog
  • Posts: 38,876
  • Joined: 27-December 08

Re: Creating password protected files through java

Posted 10 February 2010 - 10:47 PM

@techfunda248: We appreciate your willingness to help. However, I think you're a day (or a couple of years to be more specific) late, as this thread was started in 2007 and has long since been dead. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1