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