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 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 final class InhibitAnyPolicy extends ExtensionValue { 37 38 /** the value of the extension */ 39 private final int skipCerts; 40 41 /** 42 * Creates an object on the base of its encoded form. 43 */ 44 public InhibitAnyPolicy(byte[] encoding) throws IOException { 45 super(encoding); 46 this.skipCerts = new BigInteger((byte[]) 47 ASN1Integer.getInstance().decode(encoding)).intValue(); 48 } 49 50 /** 51 * Returns ASN.1 encoded form of the object. 52 */ 53 @Override public byte[] getEncoded() { 54 if (encoding == null) { 55 encoding = ASN1Integer.getInstance() 56 .encode(ASN1Integer.fromIntValue(skipCerts)); 57 } 58 return encoding; 59 } 60 61 @Override public void dumpValue(StringBuilder sb, String prefix) { 62 sb.append(prefix).append("Inhibit Any-Policy: ").append(skipCerts).append('\n'); 63 } 64 } 65