Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Password Protect a File or Directory

 
Ketul Parikh
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to make an application where in from a servlet a file is to be created and stored on local pc, which contains some important info..

Now What I want is that When I create a file it should be password protected so that when anybody tries to open it directly (i.e. by double clicking on the file) it would not be accessible without password..

Is it Possible??

If not, can I have such directory..
so as to implement "vault" like mechanism.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ketul Parikh wrote:Hi All,

I need to make an application where in from a servlet a file is to be created and stored on local pc, which contains some important info..


Any ideas how you were going to do that with a Servlet? Servlets run on the server, they can't interact with the file system on the client.


Now What I want is that When I create a file it should be password protected so that when anybody tries to open it directly (i.e. by double clicking on the file) it would not be accessible without password..

Why would you allow download of a file the client (potentially) cannot open?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best thing to do would to not allow download except for people that should see the file in the first place. Failing that, perhaps a password-protected PDF might work?

In any case, not really a Servlets question.
 
Ketul Parikh
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to create that file on Server only, I want that no user of Server can access it without password..

No client side interaction or downloading is going to be done.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Bear mentioned a password protected PDF would probably work for you.

You can also password protect zip files.
Unfortunately, Java (last I checked) can't create password protected zip files so you would need to look for a third party library to do this.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ketul Parikh wrote:No client side interaction or downloading is going to be done.

Then what did you mean by:
Ketul Parikh wrote:... a file is to be created and stored on local pc

?

Local PC == client
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic