Abstract Base Class CMSContentInfo The CMSDataContentInfo Class

Oracle CMS 5-5

5.3.2.1 Abstract Base Class CMSContentInfo

CMSContentInfo is an abstract class representing a fundamental CMS object. Table 5–2 lists the subclasses of CMSContentInfo. Some of the useful methods of this abstract class are described in Table 5–3 .

5.3.2.1.1 Constructing a CMS Object

Perform the following steps to construct a CMS object: 1. Create the object of the specified content type. 2. Initialize the object. 3. Call the output.. method to write the object encoding. If you are reading in an existing CMSContentInfo, but you do not know the concrete type in advance, use inputInstance. To create a new object, use one of the constructors of the concrete subclass with which you are working. To read in one of a known concrete type, use the no-args constructor and then invoke the input method.

5.3.2.1.2 Reading a CMS Object

Perform the following steps to read an object: 1. Call CMSContentInfo.inputInstance.. to read in the object. 2. Call getContentType to determine its content type. 3. You can now invoke the content type-specific operations.

5.3.2.2 The CMSDataContentInfo Class

The class CMSDataContentInfo represents an object of type id-data as defined by the constant CMS.id_data, and is intended to refer to arbitrary octet strings whose interpretation is left up to the application. A useful method of this class is: byte[] getData which returns the data stored in the data object. Table 5–3 Useful Methods of CMSContentInfo Method Description contentTypeName oracle.security.crypto.asn1.ASN1ObjectID contentType Returns the content type of the object as a string. getContentType Returns the content type of the object as an object identifier OID. inputjava.io.InputStream is Initializes this object by reading a BER encoding from the specified input stream. inputInstancejava.io.InputStream is Creates a new CMSContentInfo object by reading a BER encoding from the specified input stream. isDegenerate Indicates if the object is degenerate. isDetached Indicates if the object is detached. outputjava.io.OutputStream os Writes the encoding of the object to the given output stream. 5-6 Oracle Fusion Middleware Reference for Oracle Security Developer Tools To create a CMS data object: 1. Create an instance of CMSDataContentInfo using the constructor that takes a byte array, documentBytes, that contains the information: CMSDataContentInfo exdata = new CMSDataContentInfobyte[] documentBytes 2. Write the data object to a file, for example data.p7m: exdata.outputnew FileOutputStreamdata.p7m; The steps you use when reading a CMS data object depend on whether you know the objects content type. 1. Open a connection to the file using FileInputStream. If you know that the object stored in the file data.p7m is of content type id-data: CMSDataContentInfo exdata = new CMSDataContentInfonew FileInputStreamdata.p7m; However, if you do not know the content type in advance, check the type prior to reading: CMSContentInfo cmsdata = CMSContentInfo.inputInstancenew FileInputStreamdata.p7m; if cmsdata instanceof CMSDataContentInfo { CMSDataContentInfo exdata = CMSDataContentInfo cmsdata; ..... } 2. To access the information stored in the CMS data object: byte[] docBytes = exdata.getData;

5.3.2.3 The ESSReceipt Class