iaik.smime.ess
Class ContentHints

java.lang.Object
  extended by iaik.asn1.structures.AttributeValue
      extended by iaik.smime.ess.ESSAttributeValue
          extended by iaik.smime.ess.ContentHints
All Implemented Interfaces:
ASN1Type

public class ContentHints
extends ESSAttributeValue

The S/MIMEv3 ESS ContentHints attribute.

The Enhanced Security Services for S/MIMEv3 (ESS) (RFC 2634) specifies the ContentHints attribute to may be included as an attribute in a SignerInfo to provide information describing the innermost signed content of a multi-layer message at the outermost signature layer.

 ContentHints ::= SEQUENCE {
   contentDescription UTF8String (SIZE (1..MAX)) OPTIONAL,
   contentType ContentType }

 id-aa-contentHint OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840)
     rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) id-aa(2) 4}
 
The contentDescription field may be used to provide information that the recipient may use to select protected messages for processing, such as a message subject. If this field is set, then the attribute is expected to appear on the signedData object enclosing an envelopedData object and not on the inner signedData object. The (SIZE (1..MAX)) construct constrains the sequence to have at least one entry. MAX indicates the upper bound is unspecified. Implementations are free to choose an upper bound that suits their environment.
Messages which contain a signedData object wrapped around an envelopedData object, thus masking the inner content type of the message, SHOULD include a contentHints attribute, except for the case of the data content type. Specific message content types may either force or preclude the inclusion of the contentHints attribute. For example, when a signedData/Receipt is encrypted within an envelopedData object, an outer signedData object MUST be created that encapsulates the envelopedData object and a contentHints attribute with contentType set to the id-ct-receipt object identifier MUST be included in the outer signedData SignerInfo signedAttributes.

When creating a ContentHints object the content type object identifier has to be supplied. Subsequently method setContentDescription may be called to provide a string describing the content:

 ObjectID contentType = ...;
 String contentDescription = ...;
 ContentHints contentHints = new ContentHints(contentType);
 contentHints.setContentDescription(contentDescription);
 


Field Summary
static ObjectID oid
          The attributeType object identifier of this ContentHints attribute.
 
Constructor Summary
ContentHints()
          Empty default constructor.
ContentHints(ASN1Object obj)
          Creates an ContentHints from its ASN.1 representation.
ContentHints(ObjectID contentType)
          Creates an ContentHints for the given content type.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 ContentHints object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this ContentHints to the specified object.
 ObjectID getAttributeType()
          Returns the OID identifying the ContentHints attribute type.
 java.lang.String getContentDescription()
          Returns the (first) content description, if included.
 java.lang.String[] getContentDescriptions()
          Returns the (first) content description, if included.
 ObjectID getContentType()
          Returns the content type.
 int hashCode()
          Returns a hashcode for this ContentHints.
 void setContentDescription(java.lang.String contentDescription)
          Sets the content description.
 void setContentDescriptions(java.lang.String[] contentDescriptions)
          Sets the content descriptions (if more than one content description is used).
static void setMaxNumOfContentDescriptions(int max)
          Sets the allowed number of content description fields.
 ASN1Object toASN1Object()
          Returns this ContentHints as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this ContentHints.
 
Methods inherited from class iaik.smime.ess.ESSAttributeValue
multipleAllowed
 
Methods inherited from class iaik.asn1.structures.AttributeValue
getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

oid

public static final ObjectID oid
The attributeType object identifier of this ContentHints attribute. The corresponding OID string is "1.2.840.113549.1.9.16.2.4".

Constructor Detail

ContentHints

public ContentHints()
Empty default constructor. Required for dynamic object creation. Shall NOT be used by an application.


ContentHints

public ContentHints(ObjectID contentType)
Creates an ContentHints for the given content type.

Parameters:
contentType - the content type

ContentHints

public ContentHints(ASN1Object obj)
             throws CodingException
Creates an ContentHints from its ASN.1 representation.

Parameters:
obj - the ContentHints as ASN1Object
Throws:
CodingException - if the encoding is invalid
Method Detail

setMaxNumOfContentDescriptions

public static void setMaxNumOfContentDescriptions(int max)
Sets the allowed number of content description fields.

Parameters:
max - the max number of content description fields (default: 1).

getContentType

public ObjectID getContentType()
Returns the content type.

Returns:
the type of the content

setContentDescription

public void setContentDescription(java.lang.String contentDescription)
Sets the content description.

The contentDescription field may be used to provide information that the recipient may use to select protected messages for processing, such as a message subject. If this field is set, then the ContentHints attribute is expected to appear on the signedData object enclosing an envelopedData object and not on the inner signedData object.

Parameters:
contentDescription - a string describing the content

setContentDescriptions

public void setContentDescriptions(java.lang.String[] contentDescriptions)
Sets the content descriptions (if more than one content description is used).

The contentDescription field may be used to provide information that the recipient may use to select protected messages for processing, such as a message subject. If this field is set, then the ContentHints attribute is expected to appear on the signedData object enclosing an envelopedData object and not on the inner signedData object.

Parameters:
contentDescriptions - the content description terms to be set
Throws:
java.lang.IllegalArgumentException - if the number of content description terms exceeds the maximum allowed number setMaxNumOfContentDescriptions of content description terms or any of the array elements is null

getContentDescription

public java.lang.String getContentDescription()
Returns the (first) content description, if included.

The contentDescription field may be used to provide information that the recipient may use to select protected messages for processing, such as a message subject. If this field is set, then the ContentHints attribute is expected to appear on the signedData object enclosing an envelopedData object and not on the inner signedData object.

Returns:
a string describing the content, or null if no ContentDescription is included

getContentDescriptions

public java.lang.String[] getContentDescriptions()
Returns the (first) content description, if included.

The contentDescription field may be used to provide information that the recipient may use to select protected messages for processing, such as a message subject. If this field is set, then the ContentHints attribute is expected to appear on the signedData object enclosing an envelopedData object and not on the inner signedData object.

Returns:
a string describing the content, or null if no ContentDescription is included

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes the given ASN.1 ContentHints object for parsing the internal structure.

Parameters:
obj - the ContentHints as ASN1Object
Throws:
CodingException - if the encoding is invalid

toASN1Object

public ASN1Object toASN1Object()
Returns this ContentHints as ASN1Object.

Returns:
this ContentHints as ASN1Object

getAttributeType

public ObjectID getAttributeType()
Returns the OID identifying the ContentHints attribute type.

Specified by:
getAttributeType in class AttributeValue
Returns:
the OID identifying the ContentHints attribute type.

equals

public boolean equals(java.lang.Object obj)
Compares this ContentHints to the specified object.

Specified by:
equals in class ESSAttributeValue
Parameters:
obj - the object to compare this ContentHints against.
Returns:
true, if the given object is equal to this ContentHints, false otherwise

hashCode

public int hashCode()
Returns a hashcode for this ContentHints.

Overrides:
hashCode in class ESSAttributeValue
Returns:
a hashcode calculated for this ContentHints

toString

public java.lang.String toString()
Returns a string representation of this ContentHints.

Specified by:
toString in class AttributeValue
Returns:
this ContentHints as string

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK-CMS 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC