1 package org.bouncycastle.asn1.x509; 2 3 import org.bouncycastle.asn1.ASN1EncodableVector; 4 import org.bouncycastle.asn1.ASN1GeneralizedTime; 5 import org.bouncycastle.asn1.ASN1Object; 6 import org.bouncycastle.asn1.ASN1Primitive; 7 import org.bouncycastle.asn1.ASN1Sequence; 8 import org.bouncycastle.asn1.DERSequence; 9 10 public class AttCertValidityPeriod 11 extends ASN1Object 12 { 13 ASN1GeneralizedTime notBeforeTime; 14 ASN1GeneralizedTime notAfterTime; 15 getInstance( Object obj)16 public static AttCertValidityPeriod getInstance( 17 Object obj) 18 { 19 if (obj instanceof AttCertValidityPeriod) 20 { 21 return (AttCertValidityPeriod)obj; 22 } 23 else if (obj != null) 24 { 25 return new AttCertValidityPeriod(ASN1Sequence.getInstance(obj)); 26 } 27 28 return null; 29 } 30 AttCertValidityPeriod( ASN1Sequence seq)31 private AttCertValidityPeriod( 32 ASN1Sequence seq) 33 { 34 if (seq.size() != 2) 35 { 36 throw new IllegalArgumentException("Bad sequence size: " 37 + seq.size()); 38 } 39 40 notBeforeTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(0)); 41 notAfterTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(1)); 42 } 43 44 /** 45 * @param notBeforeTime 46 * @param notAfterTime 47 */ AttCertValidityPeriod( ASN1GeneralizedTime notBeforeTime, ASN1GeneralizedTime notAfterTime)48 public AttCertValidityPeriod( 49 ASN1GeneralizedTime notBeforeTime, 50 ASN1GeneralizedTime notAfterTime) 51 { 52 this.notBeforeTime = notBeforeTime; 53 this.notAfterTime = notAfterTime; 54 } 55 getNotBeforeTime()56 public ASN1GeneralizedTime getNotBeforeTime() 57 { 58 return notBeforeTime; 59 } 60 getNotAfterTime()61 public ASN1GeneralizedTime getNotAfterTime() 62 { 63 return notAfterTime; 64 } 65 66 /** 67 * Produce an object suitable for an ASN1OutputStream. 68 * <pre> 69 * AttCertValidityPeriod ::= SEQUENCE { 70 * notBeforeTime GeneralizedTime, 71 * notAfterTime GeneralizedTime 72 * } 73 * </pre> 74 */ toASN1Primitive()75 public ASN1Primitive toASN1Primitive() 76 { 77 ASN1EncodableVector v = new ASN1EncodableVector(); 78 79 v.add(notBeforeTime); 80 v.add(notAfterTime); 81 82 return new DERSequence(v); 83 } 84 } 85