Extension.java revision 2362
2362N/A * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Represent a X509 Extension Attribute. 0N/A * <p>Extensions are additional attributes which can be inserted in a X509 0N/A * v3 certificate. For example a "Driving License Certificate" could have 0N/A * the driving license number as a extension. 0N/A * <p>Extensions are represented as a sequence of the extension identifier 0N/A * (Object Identifier), a boolean flag stating whether the extension is to 0N/A * be treated as being critical and the extension value itself (this is again 0N/A * a DER encoding of the extension value). 0N/A * ASN.1 definition of Extension: 0N/A * Extension ::= SEQUENCE { 0N/A * ExtensionId OBJECT IDENTIFIER, 0N/A * critical BOOLEAN DEFAULT FALSE, 0N/A * extensionValue OCTET STRING 0N/A * All subclasses need to implement a constructor of the form 0N/A * <subclass> (Boolean, Object) 0N/A * where the Object is typically an array of DER encoded bytes. 0N/A * @author Amit Kapoor 0N/A * @author Hemma Prafullchandra 0N/A * Default constructor. Used only by sub-classes. 0N/A * Constructs an extension from a DER encoded array of bytes. 0N/A // Object identifier 0N/A // If the criticality flag was false, it will not have been encoded. 0N/A // Extension value (DER encoded) 0N/A * Constructs an Extension from individual components of ObjectIdentifier, 0N/A * criticality and the DER encoded OctetString. 0N/A * @param extensionId the ObjectIdentifier of the extension 0N/A * @param critical the boolean indicating if the extension is critical 0N/A * @param extensionValue the DER encoded octet string of the value. 0N/A // passed in a DER encoded octet string, strip off the tag 0N/A * Constructs an Extension from another extension. To be used for 0N/A * creating decoded subclasses. 0N/A * @param ext the extension to create from. 0N/A * Constructs an Extension from individual components of ObjectIdentifier, 0N/A * criticality and the raw encoded extension value. 0N/A * @param extensionId the ObjectIdentifier of the extension 0N/A * @param critical the boolean indicating if the extension is critical 0N/A * @param rawExtensionValue the raw DER-encoded extension value (this 0N/A * is not the encoded OctetString). 0N/A * Write the extension to the DerOutputStream. 0N/A * @param out the DerOutputStream to write the extension to. 0N/A * @exception IOException on encoding errors 0N/A * Returns true if extension is critical. 0N/A * Returns the ObjectIdentifier of the extension. 0N/A * Returns the extension value as an byte array for further processing. 0N/A * Note, this is the raw DER value of the extension, not the DER 0N/A * encoded octet string which is in the certificate. 0N/A * This method does not return a clone; it is the responsibility of the 0N/A * caller to clone the array if necessary. 0N/A * Returns the Extension in user readable form. 0N/A s +=
" Criticality=true\n";
0N/A s +=
" Criticality=false\n";
0N/A // Value to mix up the hash 0N/A * Returns a hashcode value for this Extension. 0N/A * @return the hashcode value. 0N/A * Compares this Extension for equality with the specified 0N/A * object. If the <code>other</code> object is an 0N/A * <code>instanceof</code> <code>Extension</code>, then 0N/A * its encoded form is retrieved and compared with the 0N/A * encoded form of this Extension. 0N/A * @param other the object to test for equality with this Extension. 0N/A * @return true iff the other object is of type Extension, and the 0N/A * criticality flag, object identifier and encoded extension value of 0N/A * the two Extensions match, false otherwise.