KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > x509 > AttCertValidityPeriod


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17
18 package org.apache.geronimo.util.asn1.x509;
19
20 import org.apache.geronimo.util.asn1.ASN1Encodable;
21 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
22 import org.apache.geronimo.util.asn1.ASN1Sequence;
23 import org.apache.geronimo.util.asn1.DERGeneralizedTime;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERSequence;
26
27 public class AttCertValidityPeriod
28     extends ASN1Encodable
29 {
30     DERGeneralizedTime notBeforeTime;
31     DERGeneralizedTime notAfterTime;
32
33     public static AttCertValidityPeriod getInstance(
34             Object JavaDoc obj)
35     {
36         if (obj instanceof AttCertValidityPeriod)
37         {
38             return (AttCertValidityPeriod)obj;
39         }
40         else if (obj instanceof ASN1Sequence)
41         {
42             return new AttCertValidityPeriod((ASN1Sequence)obj);
43         }
44
45         throw new IllegalArgumentException JavaDoc("unknown object in factory");
46     }
47
48     public AttCertValidityPeriod(
49         ASN1Sequence seq)
50     {
51         notBeforeTime = (DERGeneralizedTime)seq.getObjectAt(0);
52         notAfterTime = (DERGeneralizedTime)seq.getObjectAt(1);
53     }
54
55     /**
56      * @param notBeforeTime
57      * @param notAfterTime
58      */

59     public AttCertValidityPeriod(
60         DERGeneralizedTime notBeforeTime,
61         DERGeneralizedTime notAfterTime)
62     {
63         this.notBeforeTime = notBeforeTime;
64         this.notAfterTime = notAfterTime;
65     }
66
67     public DERGeneralizedTime getNotBeforeTime()
68     {
69         return notBeforeTime;
70     }
71
72     public DERGeneralizedTime getNotAfterTime()
73     {
74         return notAfterTime;
75     }
76
77     /**
78      * Produce an object suitable for an ASN1OutputStream.
79      * <pre>
80      * AttCertValidityPeriod ::= SEQUENCE {
81      * notBeforeTime GeneralizedTime,
82      * notAfterTime GeneralizedTime
83      * }
84      * </pre>
85      */

86     public DERObject toASN1Object()
87     {
88         ASN1EncodableVector v = new ASN1EncodableVector();
89
90         v.add(notBeforeTime);
91         v.add(notAfterTime);
92
93         return new DERSequence(v);
94     }
95 }
96
Popular Tags