Class ContentInfo

java.lang.Object
org.mozilla.jss.pkcs7.ContentInfo
All Implemented Interfaces:
ASN1Value

public class ContentInfo extends Object implements ASN1Value
A PKCS #7 ContentInfo structure.
  • Field Details

  • Constructor Details

    • ContentInfo

      public ContentInfo(OBJECT_IDENTIFIER contentType, ASN1Value content)
      Creates a ContentInfo with the given type and content.
      Parameters:
      contentType - The contentType of the ContentInfo.
      content - The content of the ContentInfo. May be null to signify that the optional content field is not present.
    • ContentInfo

      public ContentInfo(byte[] data)
      Creates a ContentInfo of type data.
    • ContentInfo

      public ContentInfo(SignedData sd)
      Creates a ContentInfo of type signedData.
    • ContentInfo

      public ContentInfo(EnvelopedData ed)
      Creates a ContentInfo of type envelopedData.
    • ContentInfo

      public ContentInfo(SignedAndEnvelopedData sed)
      Creates a ContentInfo of type signedAndEnvelopedData.
    • ContentInfo

      public ContentInfo(DigestedData dd)
      Creates a ContentInfo of type digestedData.
    • ContentInfo

      public ContentInfo(EncryptedData ed)
      Creates a ContentInfo of type encryptedData.
  • Method Details

    • getContentType

      public OBJECT_IDENTIFIER getContentType()
      Returns the contentType field, which determines what kind of content is contained in this ContentInfo. It will usually be one of the six predefined types, but may also be a user-defined type.
    • hasContent

      public boolean hasContent()
      Returns true if the content field is present.
    • getInterpretedContent

      public ASN1Value getInterpretedContent() throws InvalidBERException
      Returns the content, interpreted based on its type. If there is no content, null is returned.

      If the contentType is one of the six standard types, the returned object will be of that type. For example, if the ContentInfo has contentType signedData, a SignedData object will be returned. If the contentType is data, an OCTET_STRING will be returned.

      If the contentType is not one of the six standard types, the returned object will be an ANY.

      Throws:
      InvalidBERException
    • getContent

      public ANY getContent()
      Returns the content encoded as an ANY. If there is no content, null is returned.
    • encode

      public void encode(OutputStream ostream) throws IOException
      Description copied from interface: ASN1Value
      Write this value's DER encoding to an output stream using its own base tag.
      Specified by:
      encode in interface ASN1Value
      Parameters:
      ostream - Output stream.
      Throws:
      IOException - If an error occurred.
    • encode

      public void encode(Tag implicitTag, OutputStream ostream) throws IOException
      Description copied from interface: ASN1Value
      Write this value's DER encoding to an output stream using an implicit tag.
      Specified by:
      encode in interface ASN1Value
      Parameters:
      implicitTag - Implicit tag.
      ostream - Output stream.
      Throws:
      IOException - If an error occurred.
    • getTag

      public Tag getTag()
      Description copied from interface: ASN1Value
      Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
      Specified by:
      getTag in interface ASN1Value
      Returns:
      Base tag.
    • getTemplate

      public static ContentInfo.Template getTemplate()
      Returns a singleton instance of a decoding template for ContentInfo.