1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 package org.apache.harmony.security.x509; 21 22 import java.io.IOException; 23 import java.math.BigInteger; 24 import org.apache.harmony.security.asn1.ASN1Integer; 25 import org.apache.harmony.security.asn1.ASN1Type; 26 27 /** 28 * CRL Entry's CRL Number Extension (OID = 2.5.29.20). 29 * <pre> 30 * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } 31 * 32 * CRLNumber ::= INTEGER (0..MAX) 33 * </pre> 34 * (as specified in RFC 3280 http://www.ietf.org/rfc/rfc3280.txt) 35 */ 36 public class CRLNumber extends ExtensionValue { 37 38 // crl number value 39 private final BigInteger number; 40 41 /** 42 * Constructs the object on the base of the invalidity date value. 43 */ 44 public CRLNumber(BigInteger number) { 45 this.number = number; 46 } 47 48 /** 49 * Constructs the object on the base of its encoded form. 50 */ 51 public CRLNumber(byte[] encoding) throws IOException { 52 super(encoding); 53 number = new BigInteger((byte[]) ASN1.decode(encoding)); 54 } 55 56 /** 57 * Returns the invalidity date. 58 */ 59 public BigInteger getNumber() { 60 return number; 61 } 62 63 /** 64 * Returns ASN.1 encoded form of this X.509 CRLNumber value. 65 * @return a byte array containing ASN.1 encoded form. 66 */ 67 public byte[] getEncoded() { 68 if (encoding == null) { 69 encoding = ASN1.encode(number.toByteArray()); 70 } 71 return encoding; 72 } 73 74 /** 75 * Places the string representation of extension value 76 * into the StringBuffer object. 77 */ 78 public void dumpValue(StringBuffer buffer, String prefix) { 79 buffer.append(prefix).append("CRL Number: [ ").append(number).append( 80 " ]\n"); 81 } 82 83 /** 84 * ASN.1 Encoder/Decoder. 85 */ 86 public static final ASN1Type ASN1 = ASN1Integer.getInstance(); 87 } 88