Password Protection for a file

girma
girma used Ask the Experts™
on
Hello,
is there any way to protect a file by a password through java programming.I need to protect the file,so that any steps in reading (FileReader,FileInputStream)or writing to that file could be done only if the password is given.
Hoa iam i to achieve all this thro' JAVA PROGRAMMING.
kindly help me with an example
thanking you,
regards
girma
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
There is no way that you can protect a file by password unless at the operating system level.  Java is just an apps accessing file using service provided by the operating system.  In your java apps, you can require the user to supply a password before you allow the user to access the file but it won't stop user to access the file through another apps, eg Window Explorer or OS level copy/move/etc.  Do you mean you want to be able to accept a password without displaying it?

Commented:
well there would be one way.....

setting up a ntfs system with proper acl(Access Control List) and have it so that only a "unique" user can axx it (as well as administrator). make a program that has the equiv of "RunAsContextOfUser" for java(which I dont know  btw just guessing here) and ensure that program is the only user with that context. this should solve quiet a few troubles if you can get it to work correct. hope this helps some.......

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-  Points for ttung11

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venabili
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial