Home | History | Annotate | Download | only in x509
      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.harmony.security.x509;
     19 
     20 import java.io.IOException;
     21 import java.util.Date;
     22 import org.apache.harmony.security.asn1.ASN1GeneralizedTime;
     23 import org.apache.harmony.security.asn1.ASN1Type;
     24 
     25 /**
     26  * CRL Entry's Invalidity Date Extension (OID = 2.5.29.24).
     27  * <pre>
     28  *   id-ce-invalidityDate OBJECT IDENTIFIER ::= { id-ce 24 }
     29  *
     30  *   invalidityDate ::=  GeneralizedTime
     31  * </pre>
     32  * (as specified in RFC 3280 http://www.ietf.org/rfc/rfc3280.txt)
     33  */
     34 public final class InvalidityDate extends ExtensionValue {
     35     /** invalidity date value */
     36     private final Date date;
     37 
     38     /**
     39      * Constructs the object on the base of its encoded form.
     40      */
     41     public InvalidityDate(byte[] encoding) throws IOException {
     42         super(encoding);
     43         date = (Date) ASN1.decode(encoding);
     44     }
     45 
     46     /**
     47      * Returns the invalidity date.
     48      */
     49     public Date getDate() {
     50         return date;
     51     }
     52 
     53     /**
     54      * Returns ASN.1 encoded form of this X.509 InvalidityDate value.
     55      */
     56     @Override public byte[] getEncoded() {
     57         if (encoding == null) {
     58             encoding = ASN1.encode(date);
     59         }
     60         return encoding;
     61     }
     62 
     63     @Override public void dumpValue(StringBuilder sb, String prefix) {
     64         sb.append(prefix).append("Invalidity Date: [ ").append(date).append(" ]\n");
     65     }
     66 
     67     /**
     68      * ASN.1 Encoder/Decoder.
     69      */
     70     public static final ASN1Type ASN1 = ASN1GeneralizedTime.getInstance();
     71 }
     72