2619N/A * Copyright (c) 1997, 2010, 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 * Class supporting any PKCS9 attributes. 0N/A * The following table shows the correspondence between 0N/A * PKCS9 attribute types and value component classes. 5872N/A * For types not listed here, its name is the OID 5872N/A * in string form, its value is a (single-valued) 5872N/A * byte array that is the SET's encoding. 0N/A * <TABLE BORDER CELLPADDING=8 ALIGN=CENTER> 0N/A * <TH>Object Identifier</TH> 0N/A * <TH>Attribute Name</TH> 0N/A * <TH>Value Class</TH> 0N/A * <TD>1.2.840.113549.1.9.1</TD> 0N/A * <TD>EmailAddress</TD> 0N/A * <TD>Multi-valued</TD> 0N/A * <TD><code>String[]</code></TD> 0N/A * <TD>1.2.840.113549.1.9.2</TD> 0N/A * <TD>UnstructuredName</TD> 0N/A * <TD>Multi-valued</TD> 0N/A * <TD><code>String[]</code></TD> 0N/A * <TD>1.2.840.113549.1.9.3</TD> 0N/A * <TD>ContentType</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD><code>ObjectIdentifier</code></TD> 0N/A * <TD>1.2.840.113549.1.9.4</TD> 0N/A * <TD>MessageDigest</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD><code>byte[]</code></TD> 0N/A * <TD>1.2.840.113549.1.9.5</TD> 0N/A * <TD>SigningTime</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD><code>Date</code></TD> 0N/A * <TD>1.2.840.113549.1.9.6</TD> 0N/A * <TD>Countersignature</TD> 0N/A * <TD>Multi-valued</TD> 0N/A * <TD><code>SignerInfo[]</code></TD> 0N/A * <TD>1.2.840.113549.1.9.7</TD> 0N/A * <TD>ChallengePassword</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD><code>String</code></TD> 0N/A * <TD>1.2.840.113549.1.9.8</TD> 0N/A * <TD>UnstructuredAddress</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD><code>String</code></TD> 0N/A * <TD>1.2.840.113549.1.9.9</TD> 0N/A * <TD>ExtendedCertificateAttributes</TD> 0N/A * <TD>Multi-valued</TD> 0N/A * <TD>(not supported)</TD> 0N/A * <TD>1.2.840.113549.1.9.10</TD> 0N/A * <TD>IssuerAndSerialNumber</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD>(not supported)</TD> 0N/A * <TD>1.2.840.113549.1.9.{11,12}</TD> 0N/A * <TD>RSA DSI proprietary</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD>(not supported)</TD> 0N/A * <TD>1.2.840.113549.1.9.13</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD>(not supported)</TD> 0N/A * <TD>1.2.840.113549.1.9.14</TD> 0N/A * <TD>ExtensionRequest</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD>CertificateExtensions</TD> 0N/A * <TD>1.2.840.113549.1.9.15</TD> 0N/A * <TD>SMIMECapability</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD>(not supported)</TD> 0N/A * <TD>1.2.840.113549.1.9.16.2.12</TD> 0N/A * <TD>SigningCertificate</TD> 0N/A * <TD>Single-valued</TD> 0N/A * <TD>SigningCertificateInfo</TD> 0N/A * <TD>1.2.840.113549.1.9.16.2.14</TD> 0N/A * <TD>SignatureTimestampToken</TD> 0N/A * <TD>Single-valued</TD> 0N/A * @author Douglas Hoover 0N/A /* Are we debugging ? */ 0N/A * Array of attribute OIDs defined in PKCS9, by number. 0N/A static {
// static initializer for PKCS9_OIDS 0N/A // Initialize SigningCertificate and SignatureTimestampToken 0N/A // separately (because their values are out of sequence) 0N/A // first element [0] not used 0N/A // [11], [12] are RSA DSI proprietary 0N/A // [13] ==> signingDescription, S/MIME, not used anymore 0N/A "ExtendedCertificateAttributes";
0N/A // [11], [12] are RSA DSI proprietary 0N/A // [13] ==> signingDescription, S/MIME, not used anymore 0N/A "SignatureTimestampToken";
0N/A * Hashtable mapping names and variant names of supported 0N/A * attributes to their OIDs. This table contains all name forms 0N/A * that occur in PKCS9, in lower case. 0N/A static {
// static initializer for PCKS9_NAMES 0N/A * Hashtable mapping attribute OIDs defined in PKCS9 to the 0N/A * corresponding attribute value type. 0N/A * Acceptable ASN.1 tags for DER encodings of values of PKCS9 0N/A * attributes, by index in <code>PKCS9_OIDS</code>. 0N/A * Sets of acceptable tags are represented as arrays. 0N/A * Array indicating which PKCS9 attributes are single-valued, 0N/A * by index in <code>PKCS9_OIDS</code>. 0N/A false,
// EMailAddress 0N/A false,
// UnstructuredName 0N/A true,
// ContentType 0N/A true,
// MessageDigest 0N/A true,
// SigningTime 0N/A false,
// Countersignature 0N/A true,
// ChallengePassword 0N/A false,
// UnstructuredAddress 0N/A false,
// ExtendedCertificateAttributes 0N/A true,
// IssuerAndSerialNumber - not supported yet 0N/A true,
// ExtensionRequest 0N/A true,
// SMIMECapability - not supported yet 0N/A true,
// SigningCertificate 0N/A true // SignatureTimestampToken 5872N/A * The OID of this attribute. 5872N/A * The index of the OID of this attribute in <code>PKCS9_OIDS</code>, 0N/A * Value set of this attribute. Its class is given by 5872N/A * <code>VALUE_CLASSES[index]</code>. The SET itself 0N/A * Construct an attribute object from the attribute's OID and 0N/A * value. If the attribute is single-valued, provide only one 0N/A * value. If the attribute is multi-valued, provide an array 0N/A * containing all the values. 0N/A * Arrays of length zero are accepted, though probably useless. 0N/A * <a href=#classTable>table</a> gives the class that <code>value</code> 0N/A * must have for a given attribute. 5872N/A * @exception IllegalArgumentException 5872N/A * if the <code>value</code> has the wrong type. 0N/A * Construct an attribute object from the attribute's name and 0N/A * value. If the attribute is single-valued, provide only one 0N/A * value. If the attribute is multi-valued, provide an array 0N/A * containing all the values. 0N/A * Arrays of length zero are accepted, though probably useless. 0N/A * <a href=#classTable>table</a> gives the class that <code>value</code> 0N/A * must have for a given attribute. Reasonable variants of these 0N/A * attributes are accepted; in particular, case does not matter. 0N/A * @exception IllegalArgumentException 5872N/A * if the <code>name</code> is not recognized or the 0N/A * <code>value</code> has the wrong type. 0N/A "Unrecognized attribute name " +
name +
0N/A " constructing PKCS9Attribute.");
0N/A "Wrong value class " +
0N/A " constructing PKCS9Attribute; was " +
0N/A * Construct a PKCS9Attribute from its encoding on an input 0N/A * @param val the DerValue representing the DER encoding of the attribute. 0N/A * @exception IOException on parsing error. 0N/A // check single valued have only one value 0N/A // check for illegal element tags 0N/A case 1:
// email address 0N/A case 2:
// unstructured name 0N/A case 8:
// unstructured address 0N/A case 3:
// content type 0N/A case 4:
// message digest 0N/A case 5:
// signing time 0N/A case 6:
// countersignature 0N/A case 7:
// challenge password 0N/A case 9:
// extended-certificate attribute -- not supported 0N/A "attribute not supported.");
0N/A // break unnecessary 0N/A case 10:
// issuerAndserialNumber attribute -- not supported 0N/A "attribute not supported.");
0N/A // break unnecessary 0N/A case 11:
// RSA DSI proprietary 0N/A case 12:
// RSA DSI proprietary 0N/A "11 and 12, not supported.");
0N/A // break unnecessary 0N/A // break unnecessary 0N/A case 14:
// ExtensionRequest 0N/A case 15:
// SMIME-capability attribute -- not supported 0N/A "attribute not supported.");
0N/A // break unnecessary 0N/A case 16:
// SigningCertificate attribute 0N/A case 17:
// SignatureTimestampToken attribute 0N/A default:
// can't happen 0N/A * Write the DER encoding of this attribute to an output stream. 0N/A * <P> N.B.: This method always encodes values of 0N/A * ChallengePassword and UnstructuredAddress attributes as ASN.1 0N/A * <code>PrintableString</code>s, without checking whether they 0N/A * should be encoded as <code>T61String</code>s. 0N/A case 1:
// email address 0N/A case 2:
// unstructured name 0N/A case 3:
// content type 0N/A case 4:
// message digest 0N/A case 5:
// signing time 0N/A case 6:
// countersignature 0N/A case 7:
// challenge password 0N/A case 8:
// unstructured address 0N/A case 9:
// extended-certificate attribute -- not supported 0N/A "attribute not supported.");
0N/A // break unnecessary 0N/A case 10:
// issuerAndserialNumber attribute -- not supported 0N/A "attribute not supported.");
0N/A // break unnecessary 0N/A case 11:
// RSA DSI proprietary 0N/A case 12:
// RSA DSI proprietary 0N/A "11 and 12, not supported.");
0N/A // break unnecessary 0N/A // break unnecessary 0N/A case 14:
// ExtensionRequest 0N/A case 15:
// SMIMECapability 0N/A // break unnecessary 0N/A case 16:
// SigningCertificate 0N/A "PKCS9 SigningCertificate attribute not supported.");
0N/A // break unnecessary 0N/A case 17:
// SignatureTimestampToken 0N/A default:
// can't happen 5872N/A * Returns if the attribute is known. Unknown attributes can be created 5872N/A * from DER encoding with unknown OIDs. 0N/A * Get the value of this attribute. If the attribute is 0N/A * single-valued, return just the one value. If the attribute is 0N/A * multi-valued, return an array containing all the values. 0N/A * It is possible for this array to be of length 0. 0N/A * <a href=#classTable>table</a> gives the class of the value returned, 0N/A * depending on the type of this attribute. 0N/A * Show whether this attribute is single-valued. 0N/A * Return the OID of this attribute. 0N/A * Return the name of this attribute. 0N/A * Return the OID for a given attribute name or null if we don't recognize 0N/A * Return the attribute name for a given OID or null if we don't recognize 0N/A * Returns a string representation of this attribute. 0N/A if (
value instanceof byte[]) {
// special case for octet string 0N/A }
else {
// multi-valued 0N/A * Beginning the search at <code>start</code>, find the first 0N/A * index <code>i</code> such that <code>a[i] = obj</code>. 0N/A * @return the index, if found, and -1 otherwise. 0N/A * Throw an exception when there are multiple values for 0N/A * a single-valued attribute. 0N/A " has multiple values.");
0N/A * Throw an exception when the tag on a value encoding is 5872N/A * wrong for the attribute whose value it is. This method 5872N/A * will only be called for known tags.