01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.crypto.asn1.x509;
17:
18: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
19: import org.apache.geronimo.crypto.asn1.ASN1EncodableVector;
20: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
21: import org.apache.geronimo.crypto.asn1.DERGeneralizedTime;
22: import org.apache.geronimo.crypto.asn1.DERObject;
23: import org.apache.geronimo.crypto.asn1.DERSequence;
24:
25: public class AttCertValidityPeriod extends ASN1Encodable {
26: DERGeneralizedTime notBeforeTime;
27: DERGeneralizedTime notAfterTime;
28:
29: public static AttCertValidityPeriod getInstance(Object obj) {
30: if (obj instanceof AttCertValidityPeriod) {
31: return (AttCertValidityPeriod) obj;
32: } else if (obj instanceof ASN1Sequence) {
33: return new AttCertValidityPeriod((ASN1Sequence) obj);
34: }
35:
36: throw new IllegalArgumentException("unknown object in factory");
37: }
38:
39: public AttCertValidityPeriod(ASN1Sequence seq) {
40: notBeforeTime = (DERGeneralizedTime) seq.getObjectAt(0);
41: notAfterTime = (DERGeneralizedTime) seq.getObjectAt(1);
42: }
43:
44: /**
45: * @param notBeforeTime
46: * @param notAfterTime
47: */
48: public AttCertValidityPeriod(DERGeneralizedTime notBeforeTime,
49: DERGeneralizedTime notAfterTime) {
50: this .notBeforeTime = notBeforeTime;
51: this .notAfterTime = notAfterTime;
52: }
53:
54: public DERGeneralizedTime getNotBeforeTime() {
55: return notBeforeTime;
56: }
57:
58: public DERGeneralizedTime getNotAfterTime() {
59: return notAfterTime;
60: }
61:
62: /**
63: * Produce an object suitable for an ASN1OutputStream.
64: * <pre>
65: * AttCertValidityPeriod ::= SEQUENCE {
66: * notBeforeTime GeneralizedTime,
67: * notAfterTime GeneralizedTime
68: * }
69: * </pre>
70: */
71: public DERObject toASN1Object() {
72: ASN1EncodableVector v = new ASN1EncodableVector();
73:
74: v.add(notBeforeTime);
75: v.add(notAfterTime);
76:
77: return new DERSequence(v);
78: }
79: }
|