01: package org.bouncycastle.bcpg.sig;
02:
03: import org.bouncycastle.bcpg.SignatureSubpacket;
04: import org.bouncycastle.bcpg.SignatureSubpacketTags;
05:
06: /**
07: * packet giving signature expiration time.
08: */
09: public class SignatureExpirationTime extends SignatureSubpacket {
10: protected static byte[] timeToBytes(long t) {
11: byte[] data = new byte[4];
12:
13: data[0] = (byte) (t >> 24);
14: data[1] = (byte) (t >> 16);
15: data[2] = (byte) (t >> 8);
16: data[3] = (byte) t;
17:
18: return data;
19: }
20:
21: public SignatureExpirationTime(boolean critical, byte[] data) {
22: super (SignatureSubpacketTags.EXPIRE_TIME, critical, data);
23: }
24:
25: public SignatureExpirationTime(boolean critical, long seconds) {
26: super (SignatureSubpacketTags.EXPIRE_TIME, critical,
27: timeToBytes(seconds));
28: }
29:
30: /**
31: * return time in seconds before signature expires after creation time.
32: */
33: public long getTime() {
34: long time = ((long) (data[0] & 0xff) << 24)
35: | ((data[1] & 0xff) << 16) | ((data[2] & 0xff) << 8)
36: | (data[3] & 0xff);
37:
38: return time;
39: }
40: }
|