IAIK TSP
version 2.32

iaik.tsp
Class Accuracy

java.lang.Object
  extended by iaik.tsp.Accuracy

public class Accuracy
extends java.lang.Object

This class implements the TSP ASN.1 type Accuracy as it is specified in RFC 3161.

 Accuracy ::= SEQUENCE {
     seconds    INTEGER    OPTIONAL,
     millis [0] INTEGER    (1..999) OPTIONAL,
     micros [1] INTEGER    (1..999) OPTIONAL
 }
 

This class handles the ASN.1 structure and the DER encoding and decoding of this structure.

Accuracy represents the time deviation around the UTC time contained in GeneralizedTime. By adding the accuracy value to the GeneralizedTime, an upper limit of the time at which the timestamp has been created by the TSA can be obtained. In the same way, by subtracting the accuracy from the GeneralizedTime, a lower limit of the time at which the timestamp has been created by the TSA can be obtained.

Accuracy can be decomposed in seconds, milliseconds (between 1-999) and microseconds (1-999), all expressed as integer.

If the Accuracy optional field is not present, then the accuracy may be available through other means, e.g. the PolicyInformation.


Constructor Summary
Accuracy()
          To construct a new Accuracy object.
Accuracy(ASN1Object component)
          This constructor tries to reconstruct an Accuracy object from a given ASN.1 structure.
 
Method Summary
protected  void checkRangeOfMicros(int micros)
          This method checks if the given parameter is in the range.
protected  void checkRangeOfMillis(int millis)
          This method checks if the given parameter is in the range.
protected  void checkRangeOfSeconds(int seconds)
          This method checks if the given parameter is in the range.
 byte[] getEncoded()
          This method DER encodes the ASN.1 Accuracy object.
 int getMicros()
          Returns the microseconds fraction of the accuracy.
 int getMillis()
          Returns the milliseconds of the accuracy.
 int getSeconds()
          Returns the seconds of the accuracy.
 void setMicros(int micros)
          This method sets the accuracy in microseconds.
 void setMillis(int millis)
          This method sets the accuracy in milliseconds.
 void setSeconds(int seconds)
          This method sets the accuracy in seconds.
 ASN1Object toASN1Object()
          Returns the ASN.1 structure of the Accuracy object.
 java.lang.String toString()
          This method returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Accuracy

public Accuracy()
To construct a new Accuracy object.


Accuracy

public Accuracy(ASN1Object component)
         throws CodingException
This constructor tries to reconstruct an Accuracy object from a given ASN.1 structure.

Parameters:
component - ASN.1 structure to reconstruct.
Throws:
CodingException - Thrown if the given ASN1Object is not a Accuracy ASN.1 object.
Method Detail

getEncoded

public byte[] getEncoded()
This method DER encodes the ASN.1 Accuracy object.

Returns:
DER encoded Accuracy object.

toASN1Object

public ASN1Object toASN1Object()
Returns the ASN.1 structure of the Accuracy object.

Returns:
ASN1Object of the Accuracy object.

setSeconds

public void setSeconds(int seconds)
                throws java.lang.IllegalArgumentException
This method sets the accuracy in seconds.

Parameters:
seconds - Accuracy in seconds.
Throws:
java.lang.IllegalArgumentException - If the seconds are invalid.

setMillis

public void setMillis(int millis)
               throws java.lang.IllegalArgumentException
This method sets the accuracy in milliseconds.

Parameters:
millis - Accuracy in milliseconds.
Throws:
java.lang.IllegalArgumentException - If the milliseconds are invalid.

setMicros

public void setMicros(int micros)
               throws java.lang.IllegalArgumentException
This method sets the accuracy in microseconds.

Parameters:
micros - Accuracy in microseconds.
Throws:
java.lang.IllegalArgumentException - If the microseconds are invalid.

getSeconds

public int getSeconds()
Returns the seconds of the accuracy.

Returns:
The seconds of the accuracy.

getMillis

public int getMillis()
Returns the milliseconds of the accuracy.

Returns:
The milliseconds of the accuracy.

getMicros

public int getMicros()
Returns the microseconds fraction of the accuracy.

Returns:
The microseconds fraction of the accuracy.

toString

public java.lang.String toString()
This method returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The Accuracy object in string representation.

checkRangeOfSeconds

protected void checkRangeOfSeconds(int seconds)
                            throws java.lang.IllegalArgumentException
This method checks if the given parameter is in the range.

Parameters:
seconds - Checks if the seconds are in range.
Throws:
java.lang.IllegalArgumentException - If the parameter is out of range.

checkRangeOfMillis

protected void checkRangeOfMillis(int millis)
                           throws java.lang.IllegalArgumentException
This method checks if the given parameter is in the range.

Parameters:
millis - Checks if the milliseconds are in range.
Throws:
java.lang.IllegalArgumentException - If the parameter is out of range.

checkRangeOfMicros

protected void checkRangeOfMicros(int micros)
                           throws java.lang.IllegalArgumentException
This method checks if the given parameter is in the range.

Parameters:
micros - Checks if the microseconds are in range.
Throws:
java.lang.IllegalArgumentException - If the parameter is out of range.

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

IAIK TSP, © 2002 IAIK, © 2003 - 2014 Stiftung SIC