[Webfunds-commits] java/webfunds/x509 AsnObjectId.java

Jeroen C. van Gelderen gelderen@cypherpunks.ai
Fri, 21 Jul 2000 17:33:18 -0400 (AST)


gelderen    00/07/21 17:33:18

  Modified:    webfunds/x509 AsnObjectId.java
  Log:
  Hacks to make this work for WebFunds. I'll be cleaning this up before it
  moves to Cryptix.

Revision  Changes    Path
1.2       +16 -2     java/webfunds/x509/AsnObjectId.java

Index: AsnObjectId.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/x509/AsnObjectId.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AsnObjectId.java	2000/07/19 02:35:41	1.1
+++ AsnObjectId.java	2000/07/21 21:33:18	1.2
@@ -1,4 +1,4 @@
-/* $Id: AsnObjectId.java,v 1.1 2000/07/19 02:35:41 gelderen Exp $
+/* $Id: AsnObjectId.java,v 1.2 2000/07/21 21:33:18 gelderen Exp $
  *
  * Copyright (c) 2000 Systemics Inc. on behalf of
  * The WebFunds Development Team. All rights reserved.
@@ -11,7 +11,7 @@
 
 
 /**
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
  * @author  Jeroen C. van Gelderen (gelderen@webfunds.org)
  */
 public final class AsnObjectId extends AsnObject
@@ -19,6 +19,9 @@
     private final int[] components;
 
 
+    private byte[] data; // XXX hack
+
+
     public AsnObjectId(AsnInputStream is) throws IOException {
         super(AsnObject.TAG_OBJECT_ID);
 
@@ -26,7 +29,7 @@
         if( len < 2 )
             throw new IOException("Invalid OBJECT_ID.");
 
-        is.readBytes(len);
+        this.data = is.readBytes(len);
         this.components = null; // XXX: but this makes WebFunds work :-)
     }
 
@@ -43,6 +46,12 @@
 
     /** Write out payload. */
     protected void encodePayload(AsnOutputStream os) throws IOException {
+
+        if( this.components == null ) {
+            os.writeBytes(this.data);
+            return;
+        }
+
         os.writeByte( (byte)(40*components[0] + components[1]) );
         for(int i=2; i<components.length; i++)
             this.writeComponent( os, components[i] );
@@ -54,6 +63,11 @@
      * the given AsnOutputStream. Payload length does NOT include length.
      */
     protected int getEncodedLengthOfPayload(AsnOutputStream os) {
+
+        // XXX hack
+        if( this.components == null )
+            return this.data.length;
+
         int len = 1; // first two are special
         for(int i=2; i<this.components.length; i++)
             len += getEncodedComponentLen( this.components[i] );