Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.cms;
  
  
Parser for RFC 5652: SignedData object.

 SignedData ::= SEQUENCE {
     version CMSVersion,
     digestAlgorithms DigestAlgorithmIdentifiers,
     encapContentInfo EncapsulatedContentInfo,
     certificates [0] IMPLICIT CertificateSet OPTIONAL,
     crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
     signerInfos SignerInfos
   }
 
 
 public class SignedDataParser
 {
     private ASN1SequenceParser _seq;
     private ASN1Integer         _version;
     private Object             _nextObject;
     private boolean            _certsCalled;
     private boolean            _crlsCalled;
 
     public static SignedDataParser getInstance(
         Object o)
         throws IOException
     {
         if (o instanceof ASN1Sequence)
         {
             return new SignedDataParser(((ASN1Sequence)o).parser());
         }
         if (o instanceof ASN1SequenceParser)
         {
             return new SignedDataParser((ASN1SequenceParser)o);
         }
 
         throw new IOException("unknown object encountered: " + o.getClass().getName());
     }
 
     private SignedDataParser(
         ASN1SequenceParser seq)
         throws IOException
     {
         this. = seq;
         this. = (ASN1Integer)seq.readObject();
     }
 
     public ASN1Integer getVersion()
     {
         return ;
     }
 
         throws IOException
     {
         Object o = .readObject();
 
         if (o instanceof ASN1Set)
         {
             return ((ASN1Set)o).parser();
         }
 
         return (ASN1SetParser)o;
     }
 
         throws IOException
     {
         return new ContentInfoParser((ASN1SequenceParser).readObject());
     }
 
     public ASN1SetParser getCertificates()
         throws IOException
     {
          = true;
          = .readObject();
 
         if ( instanceof ASN1TaggedObjectParser && ((ASN1TaggedObjectParser)).getTagNo() == 0)
         {
              = null;
 
             return certs;
         }
 
         return null;
     }
 
    public ASN1SetParser getCrls()
        throws IOException
    {
        if (!)
        {
            throw new IOException("getCerts() has not been called.");
        }
         = true;
        if ( == null)
        {
             = .readObject();
        }
        if ( instanceof ASN1TaggedObjectParser && ((ASN1TaggedObjectParser)).getTagNo() == 1)
        {
             = null;
            return crls;
        }
        return null;
    }
    public ASN1SetParser getSignerInfos()
        throws IOException
    {
        if (! || !)
        {
            throw new IOException("getCerts() and/or getCrls() has not been called.");
        }
        if ( == null)
        {
             = .readObject();
        }
        return (ASN1SetParser);
    }
New to GrepCode? Check out our FAQ X