File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create password protected file

 
deca leni
Ranch Hand
Posts: 49
Java Java ME PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please I want to create "fileName.anyExtention" with Password protected. that file must not be able to read/write/delete without the correct password. can anybody tell me the methods or tricks that I can use for this.it is better if you can give code example also

thank you...
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've edited your post and removed the formatting. Please don't use colours and different sizes other than for highlighting.
 
deca leni
Ranch Hand
Posts: 49
Java Java ME PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:I've edited your post and removed the formatting. Please don't use colours and different sizes other than for highlighting.


it's OK dear.. thank for that.but I wanted to highlight some of part of it... so what about that....I'm really confused..
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You made your entire post blue and with a bigger size. That isn't really highlighting. Also making about half your post bold isn't neither. Feel free to edit your post to add some highlighting but be selective about it.
 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out CipherOutputStream wrapped around FileOutputStream for writing, CipherInputStream wrapped around FileInputStream for reading. You'll need a proper encryption algorithm like AES to create the Cipher objects needed.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Check out CipherOutputStream wrapped around FileOutputStream for writing, CipherInputStream wrapped around FileInputStream for reading. You'll need a proper encryption algorithm like AES to create the Cipher objects needed.


Based on his original posting I don't think the OP wants to encrypt the file. On can certainly write to and delete a a password encrypted file and one can read it though not make sense of what one is reading without knowing the password. It sounds to me like the OP requires a password protected file system.
 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, without the proper key (password) the data is gibberish, so it comes close. I don't think Java allows files or file systems to become password protected without JNI.
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have answered the question the same way Rob did, but on closer reading, I can see James's point. Encrypting a file certainly wouldn't prevent someone from deleting or writing to the file. That could be accomplished by setting the file's owner and read, write, execute bits on Mac, Unix, or Linux. You'd then have to "su" to the correct user and enter a password to be able to read, write, or delete that file. Windows has a different set of capabilities, but you can protect files more or less the same way. All of this is OS-related though. It would be tricky to get a Java interface to it, but maybe not impossible.
 
deca leni
Ranch Hand
Posts: 49
Java Java ME PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deca leni wrote:please I want to create "fileName.anyExtention" with Password protected. that file must not be able to read/write/delete without the correct password. can anybody tell me the methods or tricks that I can use for this.it is better if you can give code example also

thank you...


can anybody tell me methods or technical information about file protection that we can use to protect a file?
 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what do you want to protected the file against? From deletion, overwriting, or only reading?
 
deca leni
Ranch Hand
Posts: 49
Java Java ME PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mmmm ok imagine. that I want to save some valuable data (like sensitive data) in file.. if some one get that file he/she can read it without any problem or it can be deleted.it is better if I make that file read/write/delete protected.isn't it? so?
 
deca leni
Ranch Hand
Posts: 49
Java Java ME PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can I do this thing in java?
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on how sensitive the data is. If it is really sensitive then making the file read/write/delete protected isn't enough, then you'll need to encrypt it. See previous comments about how to accomplish that. If it is not so sensitive then you could make the file private to your windows/linux/unix/whatever user. Then you need your password to be able to open it.
 
Arun Chidam
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dunno wether it hepls in your case....what about PGP encryption???

PGP Encryption
 
Jack Bearden
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have the application you are writing store the information on a remote, password protected database. That should be fairly easy to set up.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion is setting up a database, making it accessible to the world, making sure it rule 24/7 (otherwise you won't be able to access your files) and securing communication with the database a whole lot more complicated than invoking "a couple" java methods.
 
deca leni
Ranch Hand
Posts: 49
Java Java ME PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not want to save the file in database.

I found these things in this thread,

1. encrypting -> if I use this,which type of encrypting is good ?
2.JNI(java native interface) -> in which way can I use this?
3.CipherOutputStream wrapped around FileOutputStream for writing, CipherInputStream wrapped around FileInputStream for reading -> how helpful is this?

my main idea is to make the that file must not be able to read/write/delete without the correct password.that file is used store sensitive Data(like passwards)

so please can anybody enplane me how useful and ways of using them...

thank you all
 
Carey Brown
Ranch Hand
Pie
Posts: 1075
11
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the book "Core Java - Volume II - Advanced Features - Java SE 6 - Eighth Edition" (Sun Press) There is a complete source code listing of an encryption/decryption program. This book is the latest in the "Core Java" series. This one covers SE 6.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:In the book "Core Java - Volume II - Advanced Features - Java SE 6 - Eighth Edition" (Sun Press) There is a complete source code listing of an encryption/decryption program. This book is the latest in the "Core Java" series. This one covers SE 6.


Encryption has already been suggested but the OP has stated more than once that he want to read,write and delete protect the file and encryption does not achieve this.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic