[Webfunds-commits] java/webfunds/sox Account.java Armoury.java BasicAgent.java CertPackage.java CertificateReply.java CommsKeyReply.java Crypto.java Encodable.java Issuer.java RegisterRequest.java SimpleIssuer.java SmartIssuer.java Utils.java
Jeroen C. van Gelderen
gelderen@cypherpunks.ai
Fri, 21 Jul 2000 17:31:20 -0400 (AST)
gelderen 00/07/21 17:31:20
Modified: webfunds/sox Account.java Armoury.java BasicAgent.java
CertPackage.java CertificateReply.java
CommsKeyReply.java Crypto.java Encodable.java
Issuer.java RegisterRequest.java SimpleIssuer.java
SmartIssuer.java Utils.java
Log:
Change all occurrences of X509Cert to j.s.c.Certificate.
Revision Changes Path
1.70 +4 -5 java/webfunds/sox/Account.java
Index: Account.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Account.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- Account.java 2000/07/14 23:12:35 1.69
+++ Account.java 2000/07/21 21:31:17 1.70
@@ -1,4 +1,4 @@
-/* $Id: Account.java,v 1.69 2000/07/14 23:12:35 gelderen Exp $
+/* $Id: Account.java,v 1.70 2000/07/21 21:31:17 gelderen Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All rights reserved.
@@ -12,21 +12,20 @@
import java.security.KeyException;
import java.security.PrivateKey;
import java.security.PublicKey;
+import java.security.cert.Certificate;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
-import webfunds.x509.X509Cert;
-
/**
* This class contains all information needed about an
* account in order to be able to generate authentication
* information, except perhaps for holding a key passphrase,
* which is not stored in the Store (only in a runtime object).
*
- * @version $Revision: 1.69 $
+ * @version $Revision: 1.70 $
* @author Jeroen C. van Gelderen (gelderen@webfunds.org)
* @author Unknown
*/
@@ -380,7 +379,7 @@
}
else // 3 and earlier. certs. caused indeterminable exceptions
{
- X509Cert cert = new X509Cert(b);
+ Certificate cert = Utils.getCertificate(b);
pubKey = Crypto.getPublicKeyFromCert(cert);
try {
id = new AccountId(pubKey);
1.29 +15 -13 java/webfunds/sox/Armoury.java
Index: Armoury.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Armoury.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Armoury.java 2000/07/14 23:12:35 1.28
+++ Armoury.java 2000/07/21 21:31:18 1.29
@@ -1,4 +1,4 @@
-/* $Id: Armoury.java,v 1.28 2000/07/14 23:12:35 gelderen Exp $
+/* $Id: Armoury.java,v 1.29 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -7,8 +7,9 @@
import java.io.*;
import java.security.*;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
-import webfunds.x509.X509Cert;
import webfunds.sox.utils.Base64;
@@ -35,7 +36,7 @@
* <a href="http://www.imc.org/rfc2045">http://www.imc.org/rfc2045</a>
* </ol>
*
- * @version $Revision: 1.28 $
+ * @version $Revision: 1.29 $
*/
public abstract class Armoury
{
@@ -347,17 +348,17 @@
* @return the PEM encoded X509 certificate
* @see X509Cert
*/
- public static String encodeCert(X509Cert cert)
+ public static String encodeCert(Certificate cert)
{
- try
- {
+ try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- cert.encode(baos);
+ baos.write( cert.getEncoded() );
return encode("CERTIFICATE", baos.toByteArray());
- }
- catch (IOException e)
- {
- throw new InternalError("Unexpected IOException ("+e.getMessage()+")");
+ } catch(CertificateEncodingException e) {
+ throw new InternalError("Could not encode Certificate");
+ } catch(IOException e) {
+ throw new InternalError(
+ "Unexpected IOException ("+e.getMessage()+")");
}
}
@@ -369,12 +370,12 @@
* @return the X509Cert object
* @see X509Cert
*/
- public static X509Cert decodeCert(String buf)
+ public static Certificate decodeCert(String buf)
throws SOXKeyException // , InvalidChecksumException
{
try
{
- return new X509Cert(decode(buf) );
+ return Utils.getCertificate( decode(buf) );
}
catch (IOException ex)
{
@@ -382,6 +383,7 @@
}
catch(RuntimeException rtex)
{
+ rtex.printStackTrace();
System.err.println(rtex);
System.err.println("Exiting");
System.exit(1);
1.11 +4 -4 java/webfunds/sox/BasicAgent.java
Index: BasicAgent.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/BasicAgent.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- BasicAgent.java 2000/07/14 23:12:35 1.10
+++ BasicAgent.java 2000/07/21 21:31:18 1.11
@@ -1,5 +1,5 @@
/*
- * $Id: BasicAgent.java,v 1.10 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: BasicAgent.java,v 1.11 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,7 +8,7 @@
import java.io.PrintWriter;
import java.security.*;
-import webfunds.x509.X509Cert;
+import java.security.cert.Certificate;
import webfunds.utils.Debug;
@@ -85,7 +85,7 @@
/**
* Get the primary certificate for this issuer.
*/
- private /* public */ X509Cert getCertificate()
+ private Certificate getCertificate()
throws SOXPacketException, SOXKeyException,
SOXLaterException, SOXIssuerException
{
@@ -97,7 +97,7 @@
/**
* Get the current communications certificate for this issuer.
*/
- public X509Cert getCommsKey()
+ public Certificate getCommsKey()
throws SOXPacketException, SOXLaterException, SOXIssuerException
{
CommsKeyReply ckr;
1.7 +5 -5 java/webfunds/sox/CertPackage.java
Index: CertPackage.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/CertPackage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CertPackage.java 2000/07/14 23:12:35 1.6
+++ CertPackage.java 2000/07/21 21:31:18 1.7
@@ -1,4 +1,4 @@
-/* $Id: CertPackage.java,v 1.6 2000/07/14 23:12:35 gelderen Exp $
+/* $Id: CertPackage.java,v 1.7 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -8,22 +8,22 @@
import java.security.PrivateKey;
import java.security.PublicKey;
-import webfunds.x509.X509Cert;
+import java.security.cert.Certificate;
public class CertPackage
{
- X509Cert cert;
+ Certificate cert;
PrivateKey privkey;
- public CertPackage(X509Cert cert, PrivateKey privkey)
+ public CertPackage(Certificate cert, PrivateKey privkey)
{
this.cert = cert;
this.privkey = privkey;
}
- public X509Cert getCert()
+ public Certificate getCert()
{
return cert;
}
1.7 +5 -5 java/webfunds/sox/CertificateReply.java
Index: CertificateReply.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/CertificateReply.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CertificateReply.java 2000/07/14 23:12:35 1.6
+++ CertificateReply.java 2000/07/21 21:31:18 1.7
@@ -1,5 +1,5 @@
/*
- * $Id: CertificateReply.java,v 1.6 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: CertificateReply.java,v 1.7 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -7,8 +7,8 @@
package webfunds.sox;
import java.io.*;
-import webfunds.x509.X509Cert;
import java.security.PublicKey;
+import java.security.cert.Certificate;
public class CertificateReply
@@ -17,19 +17,19 @@
/**
* The certificate contained in the reply
*/
- protected X509Cert cert;
+ protected Certificate cert;
/**
* Get the certificate
*/
- public X509Cert getCertificate() { return cert; }
+ public Certificate getCertificate() { return cert; }
public PublicKey getKey() { return Crypto.getPublicKeyFromCert(cert); }
/**
* Create a reply containing a comms key
* @param cert The comms key reply
*/
- public CertificateReply(X509Cert cert)
+ public CertificateReply(Certificate cert)
{
this.cert = cert;
}
1.6 +5 -5 java/webfunds/sox/CommsKeyReply.java
Index: CommsKeyReply.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/CommsKeyReply.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CommsKeyReply.java 2000/07/14 23:12:35 1.5
+++ CommsKeyReply.java 2000/07/21 21:31:18 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: CommsKeyReply.java,v 1.5 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: CommsKeyReply.java,v 1.6 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -7,8 +7,8 @@
package webfunds.sox;
import java.io.*;
-import webfunds.x509.X509Cert;
import java.security.PublicKey;
+import java.security.cert.Certificate;
public class CommsKeyReply
@@ -17,12 +17,12 @@
/**
* The certificate contained in the reply
*/
- protected X509Cert cert;
+ protected Certificate cert;
/**
* Get the certificate.
*/
- public X509Cert getCertificate() { return cert; }
+ public Certificate getCertificate() { return cert; }
public PublicKey getKey() { return Crypto.getPublicKeyFromCert(cert); }
@@ -30,7 +30,7 @@
* Create a reply containing a comms key
* @param cert The comms key reply
*/
- public CommsKeyReply(X509Cert cert)
+ public CommsKeyReply(Certificate cert)
{
this.cert = cert;
}
1.39 +26 -7 java/webfunds/sox/Crypto.java
Index: Crypto.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Crypto.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- Crypto.java 2000/07/19 22:02:01 1.38
+++ Crypto.java 2000/07/21 21:31:18 1.39
@@ -1,4 +1,4 @@
-/* $Id: Crypto.java,v 1.38 2000/07/19 22:02:01 gelderen Exp $
+/* $Id: Crypto.java,v 1.39 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -9,6 +9,7 @@
import java.io.*;
import java.math.BigInteger;
import java.security.Cipher;
+import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyException;
@@ -24,6 +25,7 @@
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.SignatureException;
+import java.security.cert.Certificate;
import java.util.Date;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -41,7 +43,6 @@
import webfunds.x509.AsnBitString;
import webfunds.x509.AsnInteger;
import webfunds.x509.AsnSequence;
-import webfunds.x509.X509Cert;
/**
@@ -49,7 +50,7 @@
*
* Centralized crypto methods. Currently being overhauled.
*
- * @version $Revision: 1.38 $
+ * @version $Revision: 1.39 $
*/
public final class Crypto
{
@@ -143,12 +144,12 @@
* @param key The key used to sign the certificate
* @return true if the signature is valid, false if not
*/
- public static boolean verifyCertificate(X509Cert cert, PublicKey key)
+ public static boolean verifyCertificate(Certificate cert, PublicKey key)
{
try {
cert.verify(key);
return true;
- } catch (SecurityException e) { // XXX: do CertException again
+ } catch(Exception e) { // XXX: ought to be GeneralSecurityException
return false ;
}
}
@@ -159,7 +160,7 @@
* @param cert The X509 certificate containing the key
* @return the key from the certificate
*/
- public static PublicKey getPublicKeyFromCert(X509Cert cert)
+ public static PublicKey getPublicKeyFromCert(Certificate cert)
{
return cert.getPublicKey();
}
@@ -365,7 +366,7 @@
gzos.write(data, offset, len);
gzos.finish();
byte[] zipped = baos.toByteArray();
-
+
cipher.initEncrypt(key);
byte[] tmp = new byte[ cipher.outBufferSizeFinal(zipped.length) ];
cipher.doFinal(zipped, 0, zipped.length, tmp, 0);
@@ -560,6 +561,7 @@
// sr = new SecureRandom();
Cipher rsa = Cipher.getInstance(pk_alg);
+ pk = toCryptixKey(pk);
rsa.initEncrypt(pk);
byte[] keyData = key.getEncoded();
@@ -1250,6 +1252,23 @@
} catch (IOException e) {
throw new InternalError("Unexpected IOException");
+ }
+ }
+
+
+ // XXX: move out of Certificate.java. Can go for JCE 1.2
+ private static PublicKey toCryptixKey(PublicKey pk) {
+ try {
+ AsnInputStream is = new AsnInputStream(pk.getEncoded());
+ AsnSequence seq = (AsnSequence)is.read();
+ AsnBitString bs = (AsnBitString)seq.get(1);
+ is = new AsnInputStream(bs.toByteArray());
+ seq = (AsnSequence)is.read();
+ AsnInteger n = (AsnInteger)seq.get(0);
+ AsnInteger e = (AsnInteger)seq.get(1);
+ return new RawRSAPublicKey(n.toBigInteger(), e.toBigInteger());
+ } catch(IOException e) {
+ return null;
}
}
1.22 +12 -11 java/webfunds/sox/Encodable.java
Index: Encodable.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Encodable.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Encodable.java 2000/07/14 23:12:35 1.21
+++ Encodable.java 2000/07/21 21:31:18 1.22
@@ -1,5 +1,5 @@
/*
- * $Id: Encodable.java,v 1.21 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: Encodable.java,v 1.22 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,8 +8,10 @@
import java.util.*;
import java.io.*;
-import webfunds.x509.X509Cert;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.Certificate;
+
import webfunds.utils.Diagnostics;
/**
@@ -225,12 +227,14 @@
* @excep IOException An output error occurred whilst writing the stream
*/
public static
- void writeCertificate(DataOutputStream dos, X509Cert cert)
+ void writeCertificate(DataOutputStream dos, Certificate cert)
throws IOException
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- cert.encode(baos);
- writeByteArray(dos, baos.toByteArray());
+ try {
+ dos.write(cert.getEncoded());
+ } catch(CertificateEncodingException e) {
+ throw new IOException(e.toString());
+ }
}
/**
@@ -244,13 +248,10 @@
* @excep IOException An input error occurred whilst reading the stream
*/
public static
- X509Cert readCertificate(DataInputStream dis)
+ Certificate readCertificate(DataInputStream dis)
throws IOException
{
- // return new X509Cert(readByteArray(dis));
-
- byte[] b = readByteArray(dis);
- return new X509Cert(b);
+ return Utils.getCertificate( readByteArray(dis) );
}
1.19 +1 -2 java/webfunds/sox/Issuer.java
Index: Issuer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Issuer.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Issuer.java 2000/07/14 23:12:35 1.18
+++ Issuer.java 2000/07/21 21:31:18 1.19
@@ -1,5 +1,5 @@
/*
- * $Id: Issuer.java,v 1.18 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: Issuer.java,v 1.19 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,7 +8,6 @@
import java.io.*;
import java.security.*;
-import webfunds.x509.X509Cert;
import java.util.Date;
import webfunds.utils.Debug;
1.16 +4 -5 java/webfunds/sox/RegisterRequest.java
Index: RegisterRequest.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/RegisterRequest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- RegisterRequest.java 2000/07/14 23:12:35 1.15
+++ RegisterRequest.java 2000/07/21 21:31:18 1.16
@@ -1,4 +1,4 @@
-/* $Id: RegisterRequest.java,v 1.15 2000/07/14 23:12:35 gelderen Exp $
+/* $Id: RegisterRequest.java,v 1.16 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -7,15 +7,15 @@
import java.io.*;
import java.security.*;
+import java.security.cert.Certificate;
-import webfunds.x509.X509Cert;
/**
* A Request class that registers a client key with an issuer,
* by means of the "Register" request
*
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*/
public class RegisterRequest
extends Request
@@ -114,8 +114,7 @@
PublicKey k;
if (v == 1) // old code sends certs
{
- X509Cert cert;
- cert = readCertificate(dis);
+ Certificate cert = readCertificate(dis);
k = Crypto.getPublicKeyFromCert(cert);
}
else
1.11 +8 -8 java/webfunds/sox/SimpleIssuer.java
Index: SimpleIssuer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SimpleIssuer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SimpleIssuer.java 2000/07/14 23:12:35 1.10
+++ SimpleIssuer.java 2000/07/21 21:31:18 1.11
@@ -1,5 +1,5 @@
/*
- * $Id: SimpleIssuer.java,v 1.10 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: SimpleIssuer.java,v 1.11 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,7 +8,7 @@
import java.io.*;
import java.security.*;
-import webfunds.x509.X509Cert;
+import java.security.cert.Certificate;
import java.util.Date;
import webfunds.utils.Debug;
@@ -46,7 +46,7 @@
* The primary certificate for the issuer.
* Not used?
*/
- protected X509Cert issuerCert = null;
+ protected Certificate issuerCert = null;
/**
* The communications certificate (key) for the issuer.
@@ -59,7 +59,7 @@
* The connection between the legal issuer and the servers is
* not done yet. Placemarker.
*/
- protected X509Cert signer = null;
+ protected Certificate signer = null;
protected int reqNo = 0;
@@ -75,7 +75,7 @@
* @param signer the certificate which signs this issuers certificate
* @param agent the comms agent that sends requests at the transport layer
*/
- public SimpleIssuer(String name, X509Cert signer, CommsAgent agent,
+ public SimpleIssuer(String name, Certificate signer, CommsAgent agent,
PrintWriter bug)
{
debug(bug, " i ");
@@ -88,7 +88,7 @@
logmsg("SimpleIssuer(" + name + ", signer, " + agent + ", bug)");
}
- public SimpleIssuer(String name, X509Cert signer, CommsAgent agent)
+ public SimpleIssuer(String name, Certificate signer, CommsAgent agent)
{
this.name = name;
this.signer = signer;
@@ -126,7 +126,7 @@
// * @excep InvalidKeyException Problems encrypting requests
// */
// public static Issuer getInstance(String name,
-// X509Cert signer, CommsAgent agent, ClientStore store)
+// Certificate signer, CommsAgent agent, ClientStore store)
// throws IOException, SOXPacketException,
// InvalidKeyException, KeyException
// , SOXKeyException
@@ -243,7 +243,7 @@
logmsg("Fetching the SOX Server comms certificate");
- X509Cert commsCert;
+ Certificate commsCert;
try {
commsCert = basicAgent.getCommsKey();
} catch (SOXLaterException ex) {
1.12 +4 -4 java/webfunds/sox/SmartIssuer.java
Index: SmartIssuer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SmartIssuer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SmartIssuer.java 2000/07/16 19:34:41 1.11
+++ SmartIssuer.java 2000/07/21 21:31:18 1.12
@@ -1,5 +1,5 @@
/*
- * $Id: SmartIssuer.java,v 1.11 2000/07/16 19:34:41 iang Exp $
+ * $Id: SmartIssuer.java,v 1.12 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,9 +8,9 @@
import java.io.PrintWriter;
import java.io.Serializable;
-import webfunds.x509.X509Cert;
import java.net.URL;
import java.net.MalformedURLException;
+import java.security.cert.Certificate;
import java.util.Date;
import java.util.Vector;
@@ -33,7 +33,7 @@
protected Vector others;
protected int which;
protected int size;
- protected X509Cert cert;
+ protected Certificate cert;
/**
* Create a new Issuer object
@@ -45,7 +45,7 @@
* @param signer the certificate which signs this issuers certificate
* @param agent the comms agent that sends requests at the transport layer
*/
- public SmartIssuer(String[] rawUrls, X509Cert serverCert, PrintWriter bug)
+ public SmartIssuer(String[] rawUrls, Certificate serverCert, PrintWriter bug)
throws SOXIssuerException
{
debug(bug, " I ");
1.16 +20 -6 java/webfunds/sox/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Utils.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Utils.java 2000/07/14 23:12:35 1.15
+++ Utils.java 2000/07/21 21:31:18 1.16
@@ -1,5 +1,5 @@
/*
- * $Id: Utils.java,v 1.15 2000/07/14 23:12:35 gelderen Exp $
+ * $Id: Utils.java,v 1.16 2000/07/21 21:31:18 gelderen Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,7 +8,9 @@
import java.io.*;
import java.security.*;
-import webfunds.x509.X509Cert;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
import webfunds.sox.Crypto;
/**
@@ -35,17 +37,29 @@
return data;
}
+
+ public static Certificate getCertificate(byte[] data) throws IOException {
+ try {
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ return cf.generateCertificate(bais);
+ } catch(CertificateException e) {
+ throw new IOException("Uh :-(");
+ }
+ }
+
+
/**
- * Read an X509Cert from a file
+ * Read an Certificate from a file
*
* @param filename The filename containing the certificate
- * @return The X509Cert from the file
+ * @return The Certificate from the file
* @excep An input error occurred reading from the file
*/
- public static X509Cert getX509CertFromFile(String filename)
+ public static Certificate getCertificateFromFile(String filename)
throws IOException
{
- return new X509Cert(getDataFromFile(filename));
+ return Utils.getCertificate(getDataFromFile(filename));
}
/**