|
IAIK TSP version 2.32 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.tsp.TimeStampReq
public class TimeStampReq
This class implements the TSP ASN.1 type TimeStampReq
as it
is specified in RFC 3161.
TimeStampReq ::= SEQUENCE { version INTEGER { v1(1) }, messageImprint MessageImprint, --a hash algorithm OID and the hash value of the data to be --time stamped reqPolicy TSAPolicyID OPTIONAL, nonce INTEGER OPTIONAL, certReq BOOLEAN DEFAULT FALSE, extensions [0] IMPLICIT Extensions OPTIONAL }
This class handles the ASN.1 structure and the DER encoding and decoding of this structure.
The version
field (currently v1) describes the version of the TimeStamp
request.
The messageImprint
field SHALL contain the hash of the datum to be time
stamped. The hash is represented as an OCTET STRING. Its length MUST match
the length of the hash value for that algorithm (e.g. 20 bytes for SHA-1 or
16 bytes for MD5). The hash algorithm indicated in the hashAlgorithm field
MUST be a known hash algorithm (one-way and collision resistant).
The reqPolicy
field, if included, indicates the policy under which the
TimeStampToken
SHOULD be provided.
The nonce
, if included, allows to verify the timeliness of the response when
no local clock is available. The nonce is a large unique number which is generated by the client
(e.g. a 64 bit integer).
In such a case the same nonce value shall be included in the response,
otherwise the response shall be rejected.
If the certReq
field is present and set to true, the TSA's public key
certificate that is referenced by the ESSCertID attribute in the response
MUST be provided by the TSA in the certificates field from the SignedData
structure in that response. That field may also contain other certificates.
If the certReq
field is missing, or if the certReq field is present and set
to false then the certificates field from the SignedData
structure MUST not
be present in the response.
The extensions
field is a generic way to add additional information to the
request in the future. Extensions are defined in RFC 2459. If an extension,
whether it is marked critical or not critical, is used by a requester but is
not recognized by a time stamping server, the server SHALL not issue a token
and SHALL return a failure (unacceptedExtension).
Example code for creating a TimeStampReq
:
//Create a new TimeStampReq TimeStampReq request = new TimeStampReq(); //Calculate the hash of a given message byte[] hashed_message = null; try { hashed_message = MessageImprint.calculateHash("Data to be hashed", AlgorithmID.sha1); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return; } //Create a new imprint with the hash and the hash algorithm MessageImprint imprint = new MessageImprint(AlgorithmID.sha1, hashed_message); //set the imprint request.setMessageImprint(imprint); //request the TSA to include its certificate chain into the response request.setCertReq(true); //set the nonce if needful (optional) //The nonce is a large random number with a high probability that the client //generates it only once (e.g., a 64 bit integer). request.setNonce(new BigInteger("1234567890")); //set the policy under which the token should be created (optional) request.setTSAPolicyID(new ObjectID("0.8.15")); byte[] req = request.getEncoded(); //now the request is ready to be send
Field Summary | |
---|---|
static int |
PROTOCOL_VERSION
The current protocol version = 1 |
Constructor Summary | |
---|---|
TimeStampReq()
Constructs an empty TimeStampReq object. |
|
TimeStampReq(ASN1Object component)
This constructor tries to reconstruct a TimeStampReq object
from the given ASN.1 structure. |
|
TimeStampReq(byte[] timeStampReq)
This constructor generates a TimeStampReq object from an
encoded ASN.1 object. |
|
TimeStampReq(MessageImprint message_imprint)
To construct a new TimeStampReq object a
MessageImprint object must be provided. |
Method Summary | |
---|---|
boolean |
getCertReq()
Returns if a certificate is requested or not. |
byte[] |
getEncoded()
This method DER encodes the ASN.1 TimeStampReq object. |
X509Extensions |
getExtensions()
Returns the X509Extensions object. |
MessageImprint |
getMessageImprint()
Returns the MessageImprint object. |
java.math.BigInteger |
getNonce()
Returns the nonce number. |
ObjectID |
getTSAPolicyID()
Returns the PolicyInformation object. |
int |
getVersion()
Returns the TSP version. |
void |
setCertReq(boolean cert_req)
This method sets or resets a certificate request. |
void |
setExtensions(X509Extensions extensions)
This method sets a new X509Extensions object. |
void |
setMessageImprint(MessageImprint message_imprint)
This method sets a new MessageImprint object. |
void |
setNonce(java.math.BigInteger nonce)
This method sets a new nonce number. |
void |
setTSAPolicyID(ObjectID req_policy)
This method sets a new PolicyInformation object. |
ASN1Object |
toASN1Object()
Returns the ASN.1 structure of the TimeStampReq 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 |
Field Detail |
---|
public static final int PROTOCOL_VERSION
Constructor Detail |
---|
public TimeStampReq()
TimeStampReq
object.
public TimeStampReq(MessageImprint message_imprint) throws java.lang.NullPointerException
TimeStampReq
object a
MessageImprint
object must be provided.
message_imprint
- The hashed message and its algorithm identifier.
java.lang.NullPointerException
- Thrown if the given argument is null
.public TimeStampReq(ASN1Object component) throws CodingException
TimeStampReq
object
from the given ASN.1 structure.
component
- The ASN.1 structure.
CodingException
- Thrown if the given ASN.1 Object
is not a
TimeStampReq
.public TimeStampReq(byte[] timeStampReq) throws CodingException
TimeStampReq
object from an
encoded ASN.1 object.
timeStampReq
- The encoded ASN.1 object.
CodingException
- If the given ASN.1 Object
is not a
TimeStampReq
.Method Detail |
---|
public byte[] getEncoded()
TimeStampReq
object.
TimeStampReq
object.public ASN1Object toASN1Object()
TimeStampReq
object.
ASN1Object
of the TimeStampReq
object.public void setMessageImprint(MessageImprint message_imprint) throws java.lang.NullPointerException
MessageImprint
object.
message_imprint
- The MessageImprint
object.
java.lang.NullPointerException
- Thrown if the given argument is null
.public MessageImprint getMessageImprint()
MessageImprint
object.
MessageImprint
object.public void setTSAPolicyID(ObjectID req_policy) throws java.lang.NullPointerException
PolicyInformation
object.
req_policy
- The policy information as ObjectID
under which this
time stamp request is presented.
java.lang.NullPointerException
- Thrown if the given argument is null
.public ObjectID getTSAPolicyID()
PolicyInformation
object.
PolicyInformation
object.public void setNonce(java.math.BigInteger nonce) throws java.lang.NullPointerException
nonce
- The new number which is nearly unique.
java.lang.NullPointerException
- Thrown if the given argument is null
.public java.math.BigInteger getNonce()
public void setCertReq(boolean cert_req)
cert_req
- An boolean which indicates if an certificate is requested.public boolean getCertReq()
public void setExtensions(X509Extensions extensions) throws java.lang.NullPointerException
X509Extensions
object.
extensions
- The X509Extensions
object which specifies the
extensions for this request.
java.lang.NullPointerException
- Thrown if the given argument is null
.public X509Extensions getExtensions()
X509Extensions
object.
X509Extensions
object.public int getVersion()
public java.lang.String toString()
toString
in class java.lang.Object
TimeStampReq
object.
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |