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 final class CRLNumber extends ExtensionValue { 37 /** crl number value */ 38 private final BigInteger number; 39 40 /** 41 * Constructs the object on the base of its encoded form. 42 */ 43 public CRLNumber(byte[] encoding) throws IOException { 44 super(encoding); 45 number = new BigInteger((byte[]) ASN1.decode(encoding)); 46 } 47 48 /** 49 * Returns the invalidity date. 50 */ 51 public BigInteger getNumber() { 52 return number; 53 } 54 55 /** 56 * Returns ASN.1 encoded form of this X.509 CRLNumber value. 57 */ 58 @Override public byte[] getEncoded() { 59 if (encoding == null) { 60 encoding = ASN1.encode(number.toByteArray()); 61 } 62 return encoding; 63 } 64 65 @Override public void dumpValue(StringBuilder sb, String prefix) { 66 sb.append(prefix).append("CRL Number: [ ").append(number).append(" ]\n"); 67 } 68 69 /** 70 * ASN.1 Encoder/Decoder. 71 */ 72 public static final ASN1Type ASN1 = ASN1Integer.getInstance(); 73 } 74