resolve darcs stupidity
[org.ibex.core.git] / src / org / bouncycastle / asn1 / x509 / CertificateList.java
index 48703d1..b658a1a 100644 (file)
@@ -2,7 +2,6 @@
 package org.bouncycastle.asn1.x509;
 
 import org.bouncycastle.asn1.*;
-import org.bouncycastle.asn1.pkcs.*;
 
 /**
  * PKIX RFC-2459
@@ -17,85 +16,89 @@ import org.bouncycastle.asn1.pkcs.*;
  *      signatureValue       BIT STRING  }
  * </pre>
  */
-
 public class CertificateList
-       implements DEREncodable
+    implements DEREncodable
 {
-       DERConstructedSequence seq;
+    TBSCertList            tbsCertList;
+    AlgorithmIdentifier    sigAlgId;
+    DERBitString           sig;
+
+    public static CertificateList getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
 
-       TBSCertList                     tbsCertList;
-       AlgorithmIdentifier     sigAlgId;
-       DERBitString            sig;
+    public static CertificateList getInstance(
+        Object  obj)
+    {
+        if (obj instanceof CertificateList)
+        {
+            return (CertificateList)obj;
+        }
+        else if (obj instanceof ASN1Sequence)
+        {
+            return new CertificateList((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
 
     public CertificateList(
-        DERConstructedSequence seq)
+        ASN1Sequence seq)
     {
-               this.seq = seq;
-
-               if ( seq.getObjectAt(0) instanceof TBSCertList )
-               {
-                       tbsCertList = (TBSCertList)seq.getObjectAt(0);
-               }
-               else
-               {
-                       tbsCertList = new TBSCertList((DERConstructedSequence)seq.getObjectAt(0));
-               }
-
-               if ( seq.getObjectAt(1) instanceof AlgorithmIdentifier )
-               {
-                       sigAlgId = (AlgorithmIdentifier)seq.getObjectAt(1);
-               }
-               else
-               {
-                       sigAlgId = new AlgorithmIdentifier((DERConstructedSequence)seq.getObjectAt(1));
-               }
-
-               sig = (DERBitString)seq.getObjectAt(2);
-       }
-
-       public TBSCertList getTBSCertList()
-       {
-               return tbsCertList;
-       }
-
-       public TBSCertList.CRLEntry[] getRevokedCertificates()
-       {
-               return tbsCertList.getRevokedCertificates();
-       }
-
-       public AlgorithmIdentifier getSignatureAlgorithm()
-       {
-               return sigAlgId;
-       }
-
-       public DERBitString getSignature()
-       {
-               return sig;
-       }
-
-       public int getVersion()
-       {
-               return tbsCertList.getVersion();
-       }
-
-       public X509Name getIssuer()
-       {
-               return tbsCertList.getIssuer();
-       }
-
-       public DERUTCTime getThisUpdate()
-       {
-               return tbsCertList.getThisUpdate();
-       }
-
-       public DERUTCTime getNextUpdate()
-       {
-               return tbsCertList.getNextUpdate();
-       }
-
-       public DERObject getDERObject()
-       {
-               return seq;
-       }
-}
+        tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0));
+        sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
+        sig = (DERBitString)seq.getObjectAt(2);
+    }
+
+    public TBSCertList getTBSCertList()
+    {
+        return tbsCertList;
+    }
+
+    public TBSCertList.CRLEntry[] getRevokedCertificates()
+    {
+        return tbsCertList.getRevokedCertificates();
+    }
 
+    public AlgorithmIdentifier getSignatureAlgorithm()
+    {
+        return sigAlgId;
+    }
+
+    public DERBitString getSignature()
+    {
+        return sig;
+    }
+
+    public int getVersion()
+    {
+        return tbsCertList.getVersion();
+    }
+
+    public X509Name getIssuer()
+    {
+        return tbsCertList.getIssuer();
+    }
+
+    public Time getThisUpdate()
+    {
+        return tbsCertList.getThisUpdate();
+    }
+
+    public Time getNextUpdate()
+    {
+        return tbsCertList.getNextUpdate();
+    }
+
+    public DERObject getDERObject()
+    {
+        DERConstructedSequence seq = new DERConstructedSequence();
+        seq.addObject(tbsCertList);
+        seq.addObject(sigAlgId);
+        seq.addObject(sig);
+        return seq;
+    }
+}