# Re: Your Message Sent on Mon, 20 Apr 1998 23:53:53 PDT

Jan Luehe (Jan.Luehe@Eng)
Tue, 21 Apr 1998 09:42:55 -0700 (PDT)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jan Luehe: "Re: regarding keytool and javakey mapping"
- Previous message: Jan Luehe: "Re: Keytool"

    Date: Tue, 21 Apr 1998 09:42:55 -0700 (PDT)

    From: Jan Luehe <Jan.Luehe@Eng>

    Subject: Re: Your Message Sent on Mon, 20 Apr 1998 23:53:53 PDT

    To: java-security@web2.javasoft.com, bharatil@hotmail.com

Bharati:

> I'd been using "javakey" for generating public and private keys for a
> particular ID. I am not able to use the same in jdk1.2beta3. If you
> could tell me how to use my exisiting program(written in jdk1.1.5) in
> jdk1.2beta3 for a particular ID.

JDK1.2beta4 will provide a keytool command option ("-identitydb")
that lets you import your trusted "javakey" identities into your
keystore.

> Also, pl. tell me how do I get the public and private key generated by
> keytool programmitically?More precisely I want to know an eqivalent of
> IdentityScope ss = IdentityScope.getSystemScope();
> Signer sig = (Signer) ss.getIdentity(args[0]);
> PrivateKey priv = sig.getPrivateKey();
> PublicKey pub = sig.getPublicKey();
> Kindly help.

Assuming your keystore is stored in <filename>, and you would
like to retrieve the public/private keypair of alias "foo"
whose private key is protected with the password "password":

KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream(<filename>));
PrivateKey privKey = (PrivateKey)ks.getKey("foo", "password");
PublicKey pubKey = ks.getCertificate("foo").getPublicKey();

This will work with the upcoming JDK1.2beta4.
(Note that "getPrivateKey" in JDK1.2beta3 has been changed to
"getKey" in JDK1.2beta4, to allow you to store any kind of keys
- including symmetric keys - in your keystore.)

Jan

- Next message: Jan Luehe: "Re: regarding keytool and javakey mapping"
- Previous message: Jan Luehe: "Re: Keytool"