iaik.cms.attributes
Class SigningTime

java.lang.Object
  extended by iaik.asn1.structures.AttributeValue
      extended by iaik.cms.attributes.SigningTime
All Implemented Interfaces:
ASN1Type

public class SigningTime
extends AttributeValue

The CMS SigningTime attribute.

The Cryptographic Message Syntax (CMS) (RFC 5652) specifies the SigningTime attribute to may be included as an signed attribute in a SignerInfo for specifying the time at which the signer (purportedly) performed the signing process:

 SigningTime ::= Time

 Time ::= CHOICE {
   utcTime          UTCTime,
   generalizedTime  GeneralizedTime }
 
Dates between 1 January 1950 and 31 December 2049 (inclusive) must be encoded as UTCTime. Any dates with year values before 1950 or after 2049 must be encoded as GeneralizedTime.

Depending on the Date value supplied when creating a SigningTime attribute this class automatically decides whether UTCTime or GeneralizedTime has to be used when later encoding the SigningTime:

 Date time = ...;
 SigningTime signingTime = new SigningTime(time);
 

See Also:
SignerInfo

Field Summary
static ObjectID oid
          The attributeType object identifier of the CMS SigningTime attribute.
 
Constructor Summary
SigningTime()
          Creates a SigningTime for the current date.
SigningTime(ASN1Object obj)
          Creates an CMS SigningTime from its ASN.1 representation.
SigningTime(java.util.Date time)
          Creates a CMS SigningTime attribute for the time value.
SigningTime(java.util.Date time, ASN encodingType)
          Creates a CMS SigningTime attribute for the given Date using the specified encoding type.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 SigningTime object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this SigningTime to the specified object.
 java.util.Date get()
          Returns the signing time.
 ObjectID getAttributeType()
          Returns the OID identifying the SigningTime attribute type.
 int hashCode()
          Returns a hashcode for this object.
 boolean multipleAllowed()
          Returns false since only one AttributeValue is allowed in the SET OF AttributeValue of an SigningTime attribute.
 ASN1Object toASN1Object()
          Returns this SigningTime as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this SigningTime.
 
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 the CMS SigningTime attribute. The corresponding OID string is "1.2.840.113549.1.9.5".

Constructor Detail

SigningTime

public SigningTime()
Creates a SigningTime for the current date.


SigningTime

public SigningTime(java.util.Date time)
Creates a CMS SigningTime attribute for the time value.

Parameters:
time - the signing time value

SigningTime

public SigningTime(java.util.Date time,
                   ASN encodingType)
Creates a CMS SigningTime attribute for the given Date using the specified encoding type.

When using this constructor be aware that according the CMS/SMIME spec, Dates between 1 January 1950 and 31 December 2049 (inclusive) must be encoded as UTCTime. Any dates with year values before 1950 or after 2049 must be encoded as GeneralizedTime. (See RFC 5652)

Parameters:
time - the signing time
encodingType - the encoding type, either UTCTime or GeneralizedTime
Throws:
java.lang.IllegalArgumentException - if the supplied encoding type is not UTCTime or GeneralizedTime

SigningTime

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

Parameters:
obj - the CMS SigningTime as ASN1Object
Throws:
CodingException - if an error occurs when parsing the ASN1Object
Method Detail

get

public java.util.Date get()
Returns the signing time.

Returns:
the signing time

decode

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

Parameters:
obj - the SigningTime as ASN1Object
Throws:
CodingException - if an error occurs when parsing the ASN1Object

toASN1Object

public ASN1Object toASN1Object()
                        throws CodingException
Returns this SigningTime as ASN1Object.

Returns:
this SigningTime as ASN1Object
Throws:
CodingException - if no time value has been set

getAttributeType

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

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

equals

public boolean equals(java.lang.Object obj)
Compares this SigningTime to the specified object. The comparison is done based on the String representation.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare this SigningTime against.
Returns:
true, if the given object is equal to this SigningTime, false otherwise

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this object

multipleAllowed

public boolean multipleAllowed()
Returns false since only one AttributeValue is allowed in the SET OF AttributeValue of an SigningTime attribute.

Overrides:
multipleAllowed in class AttributeValue
Returns:
false since only one attribute value is allowed

toString

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

Specified by:
toString in class AttributeValue
Returns:
this SigningTime 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