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