codec.pkcs7
Class ContentInfo

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--codec.asn1.ASN1AbstractCollection
                          |
                          +--codec.asn1.ASN1Sequence
                                |
                                +--codec.pkcs7.ContentInfo
All Implemented Interfaces:
ASN1Collection, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable

public class ContentInfo
extends ASN1Sequence

This class represents a ContentInfo as defined in PKCS#7. The ASN.1 definition of this structure is

 ContentInfo ::= SEQUENCE {
   contentType ContentType,
   content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
 }
 ContentType ::= OBJECT IDENTIFIER
 

contentType indicates the type of content. PKCS#7 specifies six content types, of which five are supported: data, signedData, envelopedData, signedAndEnvelopedData, and encryptedData. All of these content types have registered OIDs.

The ContentInfo is also the general syntax of a complete PKCS#7 structure.

Version:
"$Id: ContentInfo.java,v 1.4 2000/12/07 13:21:52 vroth Exp $"
Author:
Volker Roth
See Also:
Serialized Form

Field Summary
protected  ASN1TaggedType content_
          The actual content of this structure.
protected  ASN1ObjectIdentifier contentType_
          The OID defining the contents of this structure.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ContentInfo()
          This method creates an instance which is initialized for parsing.
ContentInfo(ASN1ObjectIdentifier o)
          This constructor sets the content type to the given OID but leaves the actual content empty.
ContentInfo(ASN1RegisteredType o)
          This method calls setContent with the given ASN.1 type, which builds the tree of ASN.1 objects used for decoding this structure.
ContentInfo(OIDRegistry registry)
          Creates an instance ready for decoding.
 
Method Summary
 void decode(Decoder decoder)
          Decodes this instance.
 ASN1Type getContent()
          This method returns the actual content of this structure.
 ASN1ObjectIdentifier getContentType()
          Returns the contentType of this structure.
 void setContent(ASN1ObjectIdentifier oid)
          Sets the content type to the given OID and clears the actual content.
 void setContent(ASN1ObjectIdentifier oid, ASN1Type type)
          This method sets the OID and content of this structure.
 void setContent(ASN1RegisteredType type)
          This method sets the content of this structure.
 
Methods inherited from class codec.asn1.ASN1Sequence
getTag
 
Methods inherited from class codec.asn1.ASN1AbstractCollection
checkConstraints, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

contentType_

protected ASN1ObjectIdentifier contentType_
The OID defining the contents of this structure.

content_

protected ASN1TaggedType content_
The actual content of this structure.
Constructor Detail

ContentInfo

public ContentInfo()
This method creates an instance which is initialized for parsing. The PKCSRegistry is used for resolving OIDs to PKCS7 structures.

ContentInfo

public ContentInfo(OIDRegistry registry)
Creates an instance ready for decoding. The given OIDRegistry is used to resolve content types. By default the PKCSRegistry is used.
Parameters:
registry - The Object Identifier registry that is used to resolve content types, or null if a default registry shall be used.

ContentInfo

public ContentInfo(ASN1ObjectIdentifier o)
This constructor sets the content type to the given OID but leaves the actual content empty. This is a constructor required for instance by the SignedData type in the case of signing detached signatures. Such signatures require the content type to be Data, but the actual data must be empty (no identifier, length and contents octets).

This method calls {link #setContent(codec.asn1,ASN1ObjectIdentifier) setContent(oid)}.

Parameters:
o - The OID denoting the content type, most probably the Data content OID.

ContentInfo

public ContentInfo(ASN1RegisteredType o)
This method calls setContent with the given ASN.1 type, which builds the tree of ASN.1 objects used for decoding this structure.
Parameters:
o - The PKCS#7 content type to embed in this structure.
Method Detail

getContentType

public ASN1ObjectIdentifier getContentType()
Returns the contentType of this structure. This value is defined only if the structure has been decoded successfully, or the content has been set previously.
Returns:
The OID describing the contentType of this structure.

getContent

public ASN1Type getContent()
This method returns the actual content of this structure.
Returns:
The content or null if no content is available.

setContent

public void setContent(ASN1ObjectIdentifier oid)
Sets the content type to the given OID and clears the actual content. The OID is copied by reference. Modifying it afterwards causes side effects.
Parameters:
oid - The OID that identifies the (empty) content type.

setContent

public void setContent(ASN1RegisteredType type)
This method sets the content of this structure. This method calls setContent(ASN1ObjectIdentifier, ASN1Type) with the OID returned by ASN1RegisteredType.getOID().
Parameters:
type - The content that shall be set.

setContent

public void setContent(ASN1ObjectIdentifier oid,
                       ASN1Type type)
This method sets the OID and content of this structure. The OID is cloned and the type is stored by reference. Subsequent modification of the type has side effects.
Parameters:
oid - The OID that identifies the content type.
type - The content.

decode

public void decode(Decoder decoder)
            throws ASN1Exception,
                   IOException
Decodes this instance. This method extracts the actual content type from the ASN1OpenType.
Overrides:
decode in class ASN1AbstractCollection
Parameters:
decoder - The Decoder to use.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.