How to store the generated Key using KeyStore into the File

  • Follow


Hi,
    I have the code for reading the available key from the File using
the KeyStore. But, i have tried my best to store the generated key into
the File and i m not able to. Can some one help in these.

Thanks in Advance!

Regards,
Ganesh.G.

0
Reply ganesh.gulecha (1) 1/30/2006 7:39:41 AM

> I have the code for reading the available key from the File using the
> KeyStore. But, i have tried my best to store the generated key into the File
> and i m not able to. Can some one help in these.

Actually the only thing you'd need to do is taking a closer look at the
examples in the JDK documentation. The specification for the KeyStore class
also list an example how to load/store keys, check
http://java.sun.com/j2se/1.5.0/docs/api/java/security/KeyStore.html.

Another read which has helped me a lot is
http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html.

But summing up; the only thing you need is to add the key to the keystore using
the "KeyStore.setEntry" method. Once you've done that you can save it using an
FileOutputStream. From the top of my mind:

FileOutputStream fos = new FileOutputStream("name_of_keystore");
KeyStore.store(fos, "keystorepassword");
fos.close();


Now, do check this carefully. I'm not 100% positive that I got it all right,
but am pretty sure on the overall commands.


-- 
Groetjes, Peter

..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
0
Reply Lion 1/31/2006 5:04:48 PM


1 Replies
229 Views

(page loaded in 0.06 seconds)

5/20/2013 4:50:23 AM


Reply: