Skip navigation links

Oracle Fusion Middleware CMS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10667-04


oracle.security.crypto.cms
Class CMSAuthenticatedDataOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by oracle.security.crypto.cms.CMSOutputStream
              extended by oracle.security.crypto.cms.CMSAuthenticatedDataOutputStream

All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class CMSAuthenticatedDataOutputStream
extends CMSOutputStream

A CMSAuthenticatedDataOutputStream writes its output in the form of a CMS authenticated-data structure, generating the message authentication code in the process.

Specifically, the effect of using this class is as if the following process took place:

except that the actual process is done in one pass, eliminating the necessity to accumulate all of the input data before writing any output.

In the case where a <ocde>CMSConnector is provided instead of a CMSOutputStream, only the exposed content i.e. the Content field of the ContentInfo structure minus the explicit [0] tag is written to the underlying output stream.

Please be aware that the HMAC key is stored in a RecipientInfo structure. If you decide to use the Key Encryption (CMSKEKRecipientInfo) key management mechanism, the HMAC key used must be a TripleDES or RC2 key.

IMPORTANT: This class generates large CMS authenticated-data Objects more efficiently (Java VM memory usage) than the CMSAuthenticatedDataContentInfo class.

See Also:
CMSOutputStream, CMSAuthenticatedDataContentInfo, CMSAuthenticatedDataOutputConnector

Field Summary

 

Fields inherited from class java.io.FilterOutputStream
out

 

Constructor Summary
CMSAuthenticatedDataOutputStream(CMSOutputConnector conn, OriginatorInfo origInfo, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.core.AlgorithmIdentifier digestAlgID, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, oracle.security.crypto.cert.AttributeSet authenticatedAttribs, oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs, javax.crypto.SecretKey hmacKey, oracle.security.crypto.core.AlgorithmIdentifier hmacKeyAlgID, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.
CMSAuthenticatedDataOutputStream(CMSOutputConnector conn, OriginatorInfo origInfo, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.core.AlgorithmIdentifier digestAlgID, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, oracle.security.crypto.cert.AttributeSet authenticatedAttribs, oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs, javax.crypto.SecretKey hmacKey, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.
CMSAuthenticatedDataOutputStream(CMSOutputConnector conn, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, javax.crypto.SecretKey hmacKey, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.
CMSAuthenticatedDataOutputStream(java.io.OutputStream out, OriginatorInfo origInfo, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.core.AlgorithmIdentifier digestAlgID, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, oracle.security.crypto.cert.AttributeSet authenticatedAttribs, oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs, javax.crypto.SecretKey hmacKey, oracle.security.crypto.core.AlgorithmIdentifier hmacKeyAlgID, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.
CMSAuthenticatedDataOutputStream(java.io.OutputStream out, OriginatorInfo origInfo, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.core.AlgorithmIdentifier digestAlgID, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, oracle.security.crypto.cert.AttributeSet authenticatedAttribs, oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs, javax.crypto.SecretKey hmacKey, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.
CMSAuthenticatedDataOutputStream(java.io.OutputStream out, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, javax.crypto.SecretKey hmacKey, oracle.security.crypto.core.AlgorithmIdentifier hmacKeyAlgID, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.
CMSAuthenticatedDataOutputStream(java.io.OutputStream out, java.util.Vector recipients, oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm, oracle.security.crypto.asn1.ASN1ObjectID encapContentType, javax.crypto.SecretKey hmacKey, boolean detachEncapContent)
          Creates a CMSAuthenticatedDataOutputStream.

 

Method Summary
 void close()
           
 oracle.security.crypto.asn1.ASN1ObjectID getExposedContentType()
          Returns the content type of the data that is output to the underlying output stream.
 void terminate()
          Finish writing the authenticated-data structure.
 void write(byte[] b, int off, int len)
           
 void write(int ch)
           

 

Methods inherited from class java.io.FilterOutputStream
flush, write

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(java.io.OutputStream out,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        javax.crypto.SecretKey hmacKey,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream.

Note the changes in the Method signature

Previously public CMSAuthenticatedDataOutputStream(OutputStream , Vector , AlgorithmIdentifier ,ASN1ObjectID , SymmetricKey ,boolean )

Nowpublic CMSAuthenticatedDataOutputStream(OutputStream , Vector , AlgorithmIdentifier ,ASN1ObjectID , SecretKey ,boolean )

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
out - The underlying output stream.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
encapContentType - The content type of data being authenticated.
hmacKey - The HMAC key.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
java.security.NoSuchAlgorithmException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(java.io.OutputStream out,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        javax.crypto.SecretKey hmacKey,
                                        oracle.security.crypto.core.AlgorithmIdentifier hmacKeyAlgID,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream. p>Note the changes in the Method signature

Previously public CMSAuthenticatedDataOutputStream(OutputStream , Vector , AlgorithmIdentifier, ASN1ObjectID , SymmetricKey ,AlgorithmIdentifier,boolean )

Nowpublic CMSAuthenticatedDataOutputStream(OutputStream , Vector , AlgorithmIdentifier, ASN1ObjectID , SecretKey ,AlgorithmIdentifier,boolean )

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
out - The underlying output stream.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
encapContentType - The content type of data being authenticated.
hmacKey - The HMAC key.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
java.security.NoSuchAlgorithmException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(java.io.OutputStream out,
                                        OriginatorInfo origInfo,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.core.AlgorithmIdentifier digestAlgID,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        oracle.security.crypto.cert.AttributeSet authenticatedAttribs,
                                        oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs,
                                        javax.crypto.SecretKey hmacKey,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream.

Note the changes in the Method signature

Previously public CMSAuthenticatedDataOutputStream(OutputStream , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier , ASN1ObjectID ,AttributeSet , AttributeSet , SymmetricKey,boolean)

Nowpublic CMSAuthenticatedDataOutputStream(OutputStream , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier , ASN1ObjectID ,AttributeSet , AttributeSet , SecretKey,boolean)

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
out - The underlying output stream.
origInfo - The Originator Info.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
digestAlgID - The digest algorithm.
encapContentType - The content type of data being authenticated.
authenticatedAttribs - The set of Authenticated Attributes.
unauthenticatedAttribs - The set of Unauthenticated Attributes.
hmacKey - The HMAC key.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
java.security.NoSuchAlgorithmException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(java.io.OutputStream out,
                                        OriginatorInfo origInfo,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.core.AlgorithmIdentifier digestAlgID,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        oracle.security.crypto.cert.AttributeSet authenticatedAttribs,
                                        oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs,
                                        javax.crypto.SecretKey hmacKey,
                                        oracle.security.crypto.core.AlgorithmIdentifier hmacKeyAlgID,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream.

Note the changes in the Method signature

Previously public CMSAuthenticatedDataOutputStream(OutputStream , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier , ASN1ObjectID ,AttributeSet , AttributeSet , SymmetricKey ,AlgorithmIdentifier ,boolean )

Now public CMSAuthenticatedDataOutputStream(OutputStream , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier , ASN1ObjectID ,AttributeSet , AttributeSet , SecretKey ,AlgorithmIdentifier ,boolean )

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
out - The underlying output stream.
origInfo - The Originator Info.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
digestAlgID - The digest algorithm.
encapContentType - The content type of data being authenticated.
authenticatedAttribs - The set of Authenticated Attributes.
unauthenticatedAttribs - The set of Unauthenticated Attributes.
hmacKey - The HMAC key.
hmacKeyAlgID - The HMAC key algorithm.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
java.security.NoSuchAlgorithmException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(CMSOutputConnector conn,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        javax.crypto.SecretKey hmacKey,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream.

Note the changes in the Method signature

Previously public CMSAuthenticatedDataOutputStream(CMSOutputConnector , Vector , AlgorithmIdentifier , ASN1ObjectID , SymmetricKey ,boolean )

Now public CMSAuthenticatedDataOutputStream(CMSOutputConnector , Vector , AlgorithmIdentifier , ASN1ObjectID , SecretKey ,boolean )

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
out - The underlying output stream.
origInfo - The Originator Info.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
encapContentType - The content type of data being authenticated.
authenticatedAttribs - The set of Authenticated Attributes.
unauthenticatedAttribs - The set of Unauthenticated Attributes.
hmacKey - The HMAC key.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
java.security.NoSuchAlgorithmException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(CMSOutputConnector conn,
                                        OriginatorInfo origInfo,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.core.AlgorithmIdentifier digestAlgID,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        oracle.security.crypto.cert.AttributeSet authenticatedAttribs,
                                        oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs,
                                        javax.crypto.SecretKey hmacKey,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream.

Note the changes in the Method signature

Previously public CMSAuthenticatedDataOutputStream(CMSOutputConnector , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier, ASN1ObjectID , AttributeSet , AttributeSet , SymmetricKey , boolean )

Nowpublic CMSAuthenticatedDataOutputStream(CMSOutputConnector , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier, ASN1ObjectID , AttributeSet , AttributeSet , SecretKey , boolean )

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
conn - The underlying output connector.
origInfo - The Originator Info.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
digestAlgID - The digest algorithm.
encapContentType - The content type of data being authenticated.
authenticatedAttribs - The set of Authenticated Attributes.
unauthenticatedAttribs - The set of Unauthenticated Attributes.
hmacKey - The HMAC key.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
java.security.NoSuchAlgorithmException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.

CMSAuthenticatedDataOutputStream

public CMSAuthenticatedDataOutputStream(CMSOutputConnector conn,
                                        OriginatorInfo origInfo,
                                        java.util.Vector recipients,
                                        oracle.security.crypto.core.AlgorithmIdentifier macAlgorithm,
                                        oracle.security.crypto.core.AlgorithmIdentifier digestAlgID,
                                        oracle.security.crypto.asn1.ASN1ObjectID encapContentType,
                                        oracle.security.crypto.cert.AttributeSet authenticatedAttribs,
                                        oracle.security.crypto.cert.AttributeSet unauthenticatedAttribs,
                                        javax.crypto.SecretKey hmacKey,
                                        oracle.security.crypto.core.AlgorithmIdentifier hmacKeyAlgID,
                                        boolean detachEncapContent)
                                 throws oracle.security.crypto.util.InvalidInputException,
                                        java.security.NoSuchAlgorithmException
Creates a CMSAuthenticatedDataOutputStream.

Note the changes in the Method signature public CMSAuthenticatedDataOutputStream(CMSOutputConnector , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier, ASN1ObjectID , AttributeSet , AttributeSets, SymmetricKey , AlgorithmIdentifier ,boolean )

Nowpublic CMSAuthenticatedDataOutputStream(CMSOutputConnector , OriginatorInfo , Vector , AlgorithmIdentifier , AlgorithmIdentifier, ASN1ObjectID , AttributeSet , AttributeSet , SecretKey , boolean )

Note the changes in the exceptions thrown

Exceptions not thrown - AlgorithmIdentifierException

Exceptions included - NoSuchAlgorithmException

Parameters:
conn - The underlying output connector.
origInfo - The Originator Info.
recipients - The recipients (each element must be an instance of CMSRecipientInfoSpec).
macAlgorithm - The HMAC Algorithm.
digestAlgID - The digest algorithm.
encapContentType - The content type of data being authenticated.
authenticatedAttribs - The set of Authenticated Attributes.
unauthenticatedAttribs - The set of Unauthenticated Attributes.
hmacKey - The HMAC key.
hmacKeyAlgID - The HMAC key algorithm.
detachEncapContent - If true the authenticated content is not written to the underlying output stream; false otherwise.
Throws:
NoSuchAlgorithmIdentifierException - Algorithm is not supported.
oracle.security.crypto.util.InvalidInputException - Input appears to be invalid.
java.security.NoSuchAlgorithmException

Method Detail

terminate

public void terminate()
               throws java.io.IOException
Finish writing the authenticated-data structure.

This method must be called only after all the authenticated data has been written.

Specified by:
terminate in class CMSOutputStream
Throws:
java.io.IOException - An I/O error ocuurs.

write

public void write(int ch)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException

getExposedContentType

public oracle.security.crypto.asn1.ASN1ObjectID getExposedContentType()
Returns the content type of the data that is output to the underlying output stream.
Specified by:
getExposedContentType in class CMSOutputStream
Returns:
The content type identifier.

Skip navigation links

Oracle Fusion Middleware CMS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10667-04


Copyright © 2005, 2011 , Oracle. All rights reserved.