resolve darcs stupidity
[org.ibex.core.git] / src / org / bouncycastle / asn1 / x509 / V2TBSCertListGenerator.java
index 92b82a3..1260b2b 100644 (file)
@@ -1,5 +1,6 @@
 package org.bouncycastle.asn1.x509;
 
+import java.io.*;
 import java.util.Vector;
 import java.util.Enumeration;
 
@@ -34,7 +35,7 @@ public class V2TBSCertListGenerator
 
     AlgorithmIdentifier     signature;
     X509Name                issuer;
-    DERUTCTime              thisUpdate, nextUpdate=null;
+    Time                    thisUpdate, nextUpdate=null;
     X509Extensions          extensions=null;
     private Vector          crlentries=null;
 
@@ -58,15 +59,26 @@ public class V2TBSCertListGenerator
     public void setThisUpdate(
         DERUTCTime thisUpdate)
     {
-        this.thisUpdate = thisUpdate;
+        this.thisUpdate = new Time(thisUpdate);
     }
 
     public void setNextUpdate(
         DERUTCTime nextUpdate)
     {
-        this.nextUpdate = nextUpdate;
+        this.nextUpdate = new Time(nextUpdate);
+    }
+
+    public void setThisUpdate(
+        Time thisUpdate)
+    {
+        this.thisUpdate = thisUpdate;
     }
 
+    public void setNextUpdate(
+        Time nextUpdate)
+    {
+        this.nextUpdate = nextUpdate;
+    }
 
     public void addCRLEntry(
         DERConstructedSequence crlEntry)
@@ -78,15 +90,34 @@ public class V2TBSCertListGenerator
 
     public void addCRLEntry(DERInteger userCertificate, DERUTCTime revocationDate, int reason)
     {
+        addCRLEntry(userCertificate, new Time(revocationDate), reason);
+    }
+
+    public void addCRLEntry(DERInteger userCertificate, Time revocationDate, int reason)
+    {
         DERConstructedSequence seq = new DERConstructedSequence();
         seq.addObject(userCertificate);
         seq.addObject(revocationDate);
+        
         if (reason != 0)
         {
-            ReasonFlags rf = new ReasonFlags(reason);
+            CRLReason rf = new CRLReason(reason);
+            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
+            DEROutputStream         dOut = new DEROutputStream(bOut);
+            try
+            {
+                dOut.writeObject(rf);
+            }
+            catch (IOException e)
+            {
+                throw new IllegalArgumentException("error encoding value: " + e);
+            }
+            byte[] value = bOut.toByteArray();
             DERConstructedSequence eseq = new DERConstructedSequence();
-            eseq.addObject(X509Extensions.ReasonCode);
-            eseq.addObject(rf);
+            DERConstructedSequence eseq1 = new DERConstructedSequence();
+            eseq1.addObject(X509Extensions.ReasonCode);
+            eseq1.addObject(new DEROctetString(value));
+            eseq.addObject(eseq1);
             X509Extensions ex = new X509Extensions(eseq);
             seq.addObject(ex);
         }
@@ -130,7 +161,7 @@ public class V2TBSCertListGenerator
 
         if (extensions != null)
         {
-            seq.addObject(new DERTaggedObject(0, extensions.getDERObject()));
+            seq.addObject(new DERTaggedObject(0, extensions));
         }
 
         return new TBSCertList(seq);