Re: [Jsdsi-users] KeyPair
Status: Pre-Alpha
Brought to you by:
sajma
From: Sean R. <sra...@ae...> - 2004-08-20 07:41:07
|
Marek Lány wrote: >Hi Luis, > >Still does not work. It always write this error after read KeyPair from >file: >Exception in thread "main" java.lang.NullPointerException > at Certif1.main(Certif1.java:150) > >And line 150 is siple console command: > System.out.println( gk.getPublic().toString() ); > >I have feeling that on read KeyPair from file Java can't read correctly >after that is KeyPair structure empty.Have you another idea? > > Marek Lany >Basically to write out a certificate, > > What is giving the NPE, the KeyPair or the public key of the KeyPair? I guess the latter? What implementation of KeyPair / Private Key are you using? Does that support straight serialisation? I've noticed some odd things with the standard sun RSA keys - I have a case where the PrivateKey does not implement java.security.PrivateKey. Though I doubt something odd is happening and it probably is your code. Can you give me a clean list of your source? Sean >-----Original Message----- >From: Sean Radford [mailto:sra...@ae...] >Sent: Thursday, August 12, 2004 12:30 PM >To: Luis Pedro >Cc: mar...@or...; jsd...@li... >Subject: Re: [Jsdsi-users] KeyPair > > >Luis Pedro wrote: > > > >>Marek, >> >>It help if u send the exact error. But try this: >> - If the error is "SPKI not found", then u have to load jsdsi >>provider, i.e, jsdsi.Provider.install() and cryptix provider. >> >>But, if your problem is a ClassCastException then u have an error on >>your code and u should change this(following your code): >> >> java.security.KeyPair gk = >> >> >jsdsi.util.KeyPairFactory.create("RSA", > > >>2048); >> java.io.FileOutputStream fos = new >>java.io.FileOutputStream("gde/tests/test.pub"); >> java.io.ObjectOutputStream oos = new >> >> >java.io.ObjectOutputStream(fos); > > >>// I have changed things here, tooked "toString()" >> oos.writeObject(gk); >>// Doesn't make sense writing an object like gk.toString()!! >>// writeObject serializes the object. U can't cast from "String" to >>"KeyPair" >> oos.close(); >> >> java.security.KeyPair gk; >> java.io.FileInputStream fos = new >>java.io.FileInputStream("gde/tests/test.pub"); >> java.io.ObjectInputStream oos = new >> >> >java.io.ObjectInputStream(fos); > > >> gk = (java.security.KeyPair)oos.readObject(); >> oos.close(); >> >> -- Luís Pedro >> >> >>_____________________ >>yahoo: lpv_pt >> msn: lp...@ne... >> >> >> >> >> >>> -----Original Message----- >>> From: jsd...@li... >>> [mailto:jsd...@li...] On >>> Behalf Of Marek Lány >>> Sent: quarta-feira, 11 de Agosto de 2004 19:16 >>> To: jsd...@li... >>> Subject: [Jsdsi-users] KeyPair >>> >>> Hi >>> >>> I will save and load a KeyPair, but i can't it. I trying >>> with this: >>> KeyPair gk = >>> >>> >jsdsi.util.KeyPairFactory.create("RSA",2048); > > >>> FileOutputStream fos = new FileOutputStream("gk.pub"); >>> ObjectOutputStream oos = new ObjectOutputStream(fos); >>> oos.writeObject(gk.toString()); >>> oos.close(); >>> >>> How can't I load this object and retype in a KeyPair? >>> This code don't >>> work: >>> >>> KeyPair gk; >>> FileInputStream fos = new FileInputStream("gk.pub"); >>> ObjectInputStream oos = new ObjectInputStream(fos); >>> gk = (KeyPair) oos.readObject(); >>> oos.close(); >>> >>> Thanx. >>> >>> Marek Lany >>> >>> >>> >>> ------------------------------------------------------- >>> SF.Net email is sponsored by Shop4tech.com-Lowest price >>> on Blank Media >>> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 >>> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. >>> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 >>> _______________________________________________ >>> Jsdsi-users mailing list >>> Jsd...@li... >>> https://lists.sourceforge.net/lists/listinfo/jsdsi-users >>> >>> >> >>------------------------------------------------------- >>SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media >>100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save >>50% off Retail on Ink & Toner - Free Shipping and Free Gift. >>http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 >>_______________________________________________ >>Jsdsi-users mailing list >>Jsd...@li... >>https://lists.sourceforge.net/lists/listinfo/jsdsi-users >> >> >> >> >> >> >Marek, did Luis help you out? > >An alternative is to use jsdsi.sexp.ObjOutputStream and >jsdsi.sexp.ObjInputStream instead of the java.io.ObjectXxxStream classes > >though both approaches should work (with Luis's suggestions). > >Sean > > > -- Dr. Sean Radford, MBBS, MSc sra...@ae... http://www.aegeus-technology.com/ |