Example usage for org.bouncycastle.asn1.tsp TimeStampReq TimeStampReq

List of usage examples for org.bouncycastle.asn1.tsp TimeStampReq TimeStampReq

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.tsp TimeStampReq TimeStampReq.

Prototype

public TimeStampReq(MessageImprint messageImprint, ASN1ObjectIdentifier tsaPolicy, ASN1Integer nonce,
            ASN1Boolean certReq, Extensions extensions) 

Source Link

Usage

From source file:com.guardtime.asn1.TimestampRequest.java

License:Apache License

/**
 * Composes a new {@code TimeStampReq} structure containing the given
 * hash value and no optional fields.// w ww .  j a  v a2s.  c  o  m
 *
 * @param algOid
 *            identifier of the hash algorithm that was used to hash the
 *            data.
 * @param hashedMessage
 *            hash value of the data to be timestamped.
 * @return a new timestamp request.
 */
public static TimestampRequest compose(String algOid, byte[] hashedMessage) {
    if (algOid == null) {
        throw new IllegalArgumentException("invalid hash algorithm: null");
    } else if (hashedMessage == null) {
        throw new IllegalArgumentException("invalid hashed message: null");
    }

    AlgorithmIdentifier algId = new AlgorithmIdentifier(new ASN1ObjectIdentifier(algOid));
    MessageImprint mi = new MessageImprint(algId, hashedMessage);
    TimeStampReq req = new TimeStampReq(mi, null, null, null, null);
    return new TimestampRequest(req);
}