Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.x509;
  
  
Generator for Version 2 TBSCertList structures.
  TBSCertList  ::=  SEQUENCE  {
       version                 Version OPTIONAL,
                                    -- if present, shall be v2
       signature               AlgorithmIdentifier,
       issuer                  Name,
       thisUpdate              Time,
       nextUpdate              Time OPTIONAL,
       revokedCertificates     SEQUENCE OF SEQUENCE  {
            userCertificate         CertificateSerialNumber,
            revocationDate          Time,
            crlEntryExtensions      Extensions OPTIONAL
                                          -- if present, shall be v2
                                 }  OPTIONAL,
       crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
                                          -- if present, shall be v2
                                 }
 
Note: This class may be subject to change
 
 public class V2TBSCertListGenerator
 {
     private ASN1Integer         version = new ASN1Integer(1);
     private AlgorithmIdentifier signature;
     private X500Name            issuer;
     private Time                thisUpdatenextUpdate=null;
     private Extensions          extensions = null;
     private ASN1EncodableVector crlentries = new ASN1EncodableVector();
 
     private final static ASN1Sequence[] reasons;
 
     static
     {
         = new ASN1Sequence[11];
 
         [7] = createReasonExtension(7); // 7 -> unknown
     }
 
     public V2TBSCertListGenerator()
     {
     }
 
 
     public void setSignature(
         AlgorithmIdentifier    signature)
     {
         this. = signature;
     }

    

Deprecated:
use X500Name method
 
     public void setIssuer(
         X509Name    issuer)
     {
         this. = X500Name.getInstance(issuer.toASN1Primitive());
     }
 
     public void setIssuer(X500Name issuer)
     {
         this. = issuer;
     }
 
     public void setThisUpdate(
         ASN1UTCTime thisUpdate)
     {
         this. = new Time(thisUpdate);
     }
 
     public void setNextUpdate(
         ASN1UTCTime nextUpdate)
     {
        this. = new Time(nextUpdate);
    }
    public void setThisUpdate(
        Time thisUpdate)
    {
        this. = thisUpdate;
    }
    public void setNextUpdate(
        Time nextUpdate)
    {
        this. = nextUpdate;
    }
    public void addCRLEntry(
        ASN1Sequence crlEntry)
    {
        .add(crlEntry);
    }
    public void addCRLEntry(ASN1Integer userCertificateASN1UTCTime revocationDateint reason)
    {
        addCRLEntry(userCertificatenew Time(revocationDate), reason);
    }
    public void addCRLEntry(ASN1Integer userCertificateTime revocationDateint reason)
    {
        addCRLEntry(userCertificaterevocationDatereasonnull);
    }
    public void addCRLEntry(ASN1Integer userCertificateTime revocationDateint reasonASN1GeneralizedTime invalidityDate)
    {
        if (reason != 0)
        {
            ASN1EncodableVector v = new ASN1EncodableVector();
            if (reason < .)
            {
                if (reason < 0)
                {
                    throw new IllegalArgumentException("invalid reason value: " + reason);
                }
                v.add([reason]);
            }
            else
            {
                v.add(createReasonExtension(reason));
            }
            if (invalidityDate != null)
            {
                v.add(createInvalidityDateExtension(invalidityDate));
            }
            internalAddCRLEntry(userCertificaterevocationDatenew DERSequence(v));
        }
        else if (invalidityDate != null)
        {
            ASN1EncodableVector v = new ASN1EncodableVector();
            v.add(createInvalidityDateExtension(invalidityDate));
            internalAddCRLEntry(userCertificaterevocationDatenew DERSequence(v));
        }
        else
        {
            addCRLEntry(userCertificaterevocationDatenull);
        }
    }
    private void internalAddCRLEntry(ASN1Integer userCertificateTime revocationDateASN1Sequence extensions)
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
        v.add(userCertificate);
        v.add(revocationDate);
        if (extensions != null)
        {
            v.add(extensions);
        }
        addCRLEntry(new DERSequence(v));
    }
    public void addCRLEntry(ASN1Integer userCertificateTime revocationDateExtensions extensions)
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
        v.add(userCertificate);
        v.add(revocationDate);
        
        if (extensions != null)
        {
            v.add(extensions);
        }
        
        addCRLEntry(new DERSequence(v));
    }
    public void setExtensions(
        X509Extensions    extensions)
    {
        setExtensions(Extensions.getInstance(extensions));
    }
    public void setExtensions(
        Extensions    extensions)
    {
        this. = extensions;
    }
    {
        if (( == null) || ( == null) || ( == null))
        {
            throw new IllegalStateException("Not all mandatory fields set in V2 TBSCertList generator.");
        }
        ASN1EncodableVector  v = new ASN1EncodableVector();
        v.add();
        v.add();
        v.add();
        v.add();
        if ( != null)
        {
            v.add();
        }
        // Add CRLEntries if they exist
        if (.size() != 0)
        {
            v.add(new DERSequence());
        }
        if ( != null)
        {
            v.add(new DERTaggedObject(0, ));
        }
        return new TBSCertList(new DERSequence(v));
    }
    private static ASN1Sequence createReasonExtension(int reasonCode)
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
        CRLReason crlReason = CRLReason.lookup(reasonCode);
        try
        {
            v.add(.);
            v.add(new DEROctetString(crlReason.getEncoded()));
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("error encoding reason: " + e);
        }
        return new DERSequence(v);
    }
    private static ASN1Sequence createInvalidityDateExtension(ASN1GeneralizedTime invalidityDate)
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
        try
        {
            v.add(.);
            v.add(new DEROctetString(invalidityDate.getEncoded()));
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("error encoding reason: " + e);
        }
        return new DERSequence(v);
    }
New to GrepCode? Check out our FAQ X