01: package org.bouncycastle.tsp;
02:
03: import java.io.IOException;
04: import java.math.BigInteger;
05: import java.text.ParseException;
06: import java.util.Date;
07:
08: import org.bouncycastle.asn1.tsp.Accuracy;
09: import org.bouncycastle.asn1.tsp.TSTInfo;
10:
11: public class TimeStampTokenInfo {
12: TSTInfo tstInfo;
13: Date genTime;
14:
15: TimeStampTokenInfo(TSTInfo tstInfo) throws TSPException,
16: IOException {
17: this .tstInfo = tstInfo;
18:
19: try {
20: this .genTime = tstInfo.getGenTime().getDate();
21: } catch (ParseException e) {
22: throw new TSPException("unable to parse genTime field");
23: }
24: }
25:
26: public boolean isOrdered() {
27: return tstInfo.getOrdering().isTrue();
28: }
29:
30: public Accuracy getAccuracy() {
31: return tstInfo.getAccuracy();
32: }
33:
34: public Date getGenTime() {
35: return genTime;
36: }
37:
38: public GenTimeAccuracy getGenTimeAccuracy() {
39: if (this .getAccuracy() != null) {
40: return new GenTimeAccuracy(this .getAccuracy());
41: }
42:
43: return null;
44: }
45:
46: public String getPolicy() {
47: return tstInfo.getPolicy().getId();
48: }
49:
50: public BigInteger getSerialNumber() {
51: return tstInfo.getSerialNumber().getValue();
52: }
53:
54: /**
55: * @return the nonce value, null if there isn't one.
56: */
57: public BigInteger getNonce() {
58: if (tstInfo.getNonce() != null) {
59: return tstInfo.getNonce().getValue();
60: }
61:
62: return null;
63: }
64:
65: public String getMessageImprintAlgOID() {
66: return tstInfo.getMessageImprint().getHashAlgorithm()
67: .getObjectId().getId();
68: }
69:
70: public byte[] getMessageImprintDigest() {
71: return tstInfo.getMessageImprint().getHashedMessage();
72: }
73:
74: public byte[] getEncoded() throws IOException {
75: return tstInfo.getEncoded();
76: }
77: }
|