01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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:
25: import org.apache.harmony.security.asn1.ASN1Integer;
26: import org.apache.harmony.security.asn1.ASN1Type;
27:
28: /**
29: * CRL Entry's CRL Number Extension (OID = 2.5.29.20).
30: * <pre>
31: * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
32: *
33: * CRLNumber ::= INTEGER (0..MAX)
34: * </pre>
35: * (as specified in RFC 3280 http://www.ietf.org/rfc/rfc3280.txt)
36: */
37: public class CRLNumber extends ExtensionValue {
38:
39: // crl number value
40: private final BigInteger number;
41:
42: /**
43: * Constructs the object on the base of the invalidity date value.
44: */
45: public CRLNumber(BigInteger number) {
46: this .number = number;
47: }
48:
49: /**
50: * Constructs the object on the base of its encoded form.
51: */
52: public CRLNumber(byte[] encoding) throws IOException {
53: super (encoding);
54: number = new BigInteger((byte[]) ASN1.decode(encoding));
55: }
56:
57: /**
58: * Returns the invalidity date.
59: */
60: public BigInteger getNumber() {
61: return number;
62: }
63:
64: /**
65: * Returns ASN.1 encoded form of this X.509 CRLNumber value.
66: * @return a byte array containing ASN.1 encoded form.
67: */
68: public byte[] getEncoded() {
69: if (encoding == null) {
70: encoding = ASN1.encode(number.toByteArray());
71: }
72: return encoding;
73: }
74:
75: /**
76: * Places the string representation of extension value
77: * into the StringBuffer object.
78: */
79: public void dumpValue(StringBuffer buffer, String prefix) {
80: buffer.append(prefix)
81: .append("CRL Number: [ ").append(number).append( //$NON-NLS-1$
82: " ]\n"); //$NON-NLS-1$
83: }
84:
85: /**
86: * ASN.1 Encoder/Decoder.
87: */
88: public static final ASN1Type ASN1 = ASN1Integer.getInstance();
89: }
|