001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.geronimo.util.asn1.x509;
019
020 import org.apache.geronimo.util.asn1.ASN1Encodable;
021 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
022 import org.apache.geronimo.util.asn1.ASN1Sequence;
023 import org.apache.geronimo.util.asn1.DERGeneralizedTime;
024 import org.apache.geronimo.util.asn1.DERObject;
025 import org.apache.geronimo.util.asn1.DERSequence;
026
027 public class AttCertValidityPeriod
028 extends ASN1Encodable
029 {
030 DERGeneralizedTime notBeforeTime;
031 DERGeneralizedTime notAfterTime;
032
033 public static AttCertValidityPeriod getInstance(
034 Object obj)
035 {
036 if (obj instanceof AttCertValidityPeriod)
037 {
038 return (AttCertValidityPeriod)obj;
039 }
040 else if (obj instanceof ASN1Sequence)
041 {
042 return new AttCertValidityPeriod((ASN1Sequence)obj);
043 }
044
045 throw new IllegalArgumentException("unknown object in factory");
046 }
047
048 public AttCertValidityPeriod(
049 ASN1Sequence seq)
050 {
051 notBeforeTime = (DERGeneralizedTime)seq.getObjectAt(0);
052 notAfterTime = (DERGeneralizedTime)seq.getObjectAt(1);
053 }
054
055 /**
056 * @param notBeforeTime
057 * @param notAfterTime
058 */
059 public AttCertValidityPeriod(
060 DERGeneralizedTime notBeforeTime,
061 DERGeneralizedTime notAfterTime)
062 {
063 this.notBeforeTime = notBeforeTime;
064 this.notAfterTime = notAfterTime;
065 }
066
067 public DERGeneralizedTime getNotBeforeTime()
068 {
069 return notBeforeTime;
070 }
071
072 public DERGeneralizedTime getNotAfterTime()
073 {
074 return notAfterTime;
075 }
076
077 /**
078 * Produce an object suitable for an ASN1OutputStream.
079 * <pre>
080 * AttCertValidityPeriod ::= SEQUENCE {
081 * notBeforeTime GeneralizedTime,
082 * notAfterTime GeneralizedTime
083 * }
084 * </pre>
085 */
086 public DERObject toASN1Object()
087 {
088 ASN1EncodableVector v = new ASN1EncodableVector();
089
090 v.add(notBeforeTime);
091 v.add(notAfterTime);
092
093 return new DERSequence(v);
094 }
095 }