Class PKCS9Attribute
java.lang.Object
org.mozilla.jss.netscape.security.pkcs.PKCS9Attribute
- All Implemented Interfaces:
DerEncoder
Class supporting any PKCS9 attribute except
ExtendedCertificateAttribute. Supports DER decoding and access to
attribute values, but not DER encoding or setting of values.
- Version:
- 1.2 97/12/10
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringprivate intThe OID of this attribute isPKCS9_OIDS[index].static final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringprivate static final Hashtable<String,ObjectIdentifier> Hashtable mapping names and variant names of supported attributes to their OIDs.private static final Hashtable<ObjectIdentifier,String> Hashtable mapping attribute OIDs defined in PKCS9 to the corresponding attribute value type.static final ObjectIdentifierstatic final Stringprivate static final String(package private) static final ObjectIdentifier[]Array of attribute OIDs defined in PKCS9, by number.private static final Stringprivate static final Byte[][]Acceptable ASN.1 tags for DER encodings of values of PKCS9 attributes, by index inPKCS9_OIDS.static final ObjectIdentifierstatic final Stringprivate static final Stringstatic final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringprivate static final boolean[]Array indicating which PKCS9 attributes are single-valued, by index inPKCS9_OIDS.static final ObjectIdentifierstatic final Stringstatic final ObjectIdentifierstatic final Stringprivate ObjectValue set of this attribute.private static final Class<?>[]Class types required for values for a given PKCS9 attribute type. -
Constructor Summary
ConstructorsConstructorDescriptionPKCS9Attribute(String name, Object value) Construct an attribute object from the attribute's name and value.PKCS9Attribute(DerValue derVal) Construct a PKCS9Attribute from its encoding on an input stream.PKCS9Attribute(ObjectIdentifier oid, Object value) Construct an attribute object from the attribute's OID and value. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidDecode a PKCS9 attribute.voidderEncode(OutputStream out) Write the DER encoding of this attribute to an output stream.getName()Return the name of this attribute.static StringgetName(ObjectIdentifier oid) Return the attribute name for a given OID or null if we don't recognize the oid.getOID()Return the OID of this attribute.static ObjectIdentifierReturn the OID for a given attribute name or null if we don't recognize the name.getValue()Get the value of this attribute.(package private) static intBeginning the search atstart, find the first indexisuch thata[i] = obj.private voidinit(ObjectIdentifier oid, Object value) booleanShow whether this attribute is single-valued.private voidThrow an exception when there are multiple values for a single-valued attribute.private voidthrowTagException(Byte tag) Throw an exception when the tag on a value encoding is wrong for the attribute whose value it is.toString()Returns a string representation of this attribute.
-
Field Details
-
RSADSI_str
- See Also:
-
PKCS_str
- See Also:
-
PKCS9_str
- See Also:
-
PKCS9_OIDS
Array of attribute OIDs defined in PKCS9, by number. -
EMAIL_ADDRESS_OID
-
UNSTRUCTURED_NAME_OID
-
CONTENT_TYPE_OID
-
MESSAGE_DIGEST_OID
-
SIGNING_TIME_OID
-
COUNTERSIGNATURE_OID
-
CHALLENGE_PASSWORD_OID
-
UNSTRUCTURED_ADDRESS_OID
-
EXTENDED_CERTIFICATE_ATTRIBUTES_OID
-
ISSUER_AND_SERIALNUMBER_OID
-
PASSWORD_CHECK_OID
-
PUBLIC_KEY_OID
-
SIGNING_DESCRIPTION_OID
-
EXTENSION_REQUEST_OID
-
EMAIL_ADDRESS_STR
- See Also:
-
UNSTRUCTURED_NAME_STR
- See Also:
-
CONTENT_TYPE_STR
- See Also:
-
MESSAGE_DIGEST_STR
- See Also:
-
SIGNING_TIME_STR
- See Also:
-
COUNTERSIGNATURE_STR
- See Also:
-
CHALLENGE_PASSWORD_STR
- See Also:
-
UNSTRUCTURED_ADDRESS_STR
- See Also:
-
EXTENDED_CERTIFICATE_ATTRIBUTES_STR
- See Also:
-
ISSUER_AND_SERIALNUMBER_STR
- See Also:
-
PASSWORD_CHECK_STR
- See Also:
-
PUBLIC_KEY_STR
- See Also:
-
SIGNING_DESCRIPTION_STR
- See Also:
-
EXTENSION_REQUEST_STR
- See Also:
-
NAME_OID_TABLE
Hashtable mapping names and variant names of supported attributes to their OIDs. This table contains all name forms that occur in PKCS9, in lower case. -
OID_NAME_TABLE
Hashtable mapping attribute OIDs defined in PKCS9 to the corresponding attribute value type. -
PKCS9_VALUE_TAGS
Acceptable ASN.1 tags for DER encodings of values of PKCS9 attributes, by index inPKCS9_OIDS. Sets of acceptable tags are represented as arrays. -
VALUE_CLASSES
Class types required for values for a given PKCS9 attribute type.The following table shows the correspondence between attribute types and value component classes.
OID Attribute Type Name Kind Value Class 1.2.840.113549.1.9.1 EmailAddress Multiple-valued String[]1.2.840.113549.1.9.2 UnstructuredName Multiple-valued String1.2.840.113549.1.9.3 ContentType Single-valued ObjectIdentifier1.2.840.113549.1.9.4 MessageDigest Single-valued byte[]1.2.840.113549.1.9.5 SigningTime Single-valued Date1.2.840.113549.1.9.6 Countersignature Multiple-valued SignerInfo1.2.840.113549.1.9.7 ChallengePassword Single-valued String1.2.840.113549.1.9.8 UnstructuredAddress Single-valued String1.2.840.113549.1.9.9 ExtendedCertificateAttributes Multiple-valued (not supported) 1.2.840.113549.1.9.10 IssuerAndSerialNumber Single-valued (not supported) 1.2.840.113549.1.9.11 PasswordCheck Single-valued (not supported) 1.2.840.113549.1.9.12 PublicKey Single-valued (not supported) 1.2.840.113549.1.9.13 SigningDescription Single-valued (not supported) 1.2.840.113549.1.9.14 ExtensionRequest Single-valued Sequence -
SINGLE_VALUED
private static final boolean[] SINGLE_VALUEDArray indicating which PKCS9 attributes are single-valued, by index inPKCS9_OIDS. -
index
private int indexThe OID of this attribute isPKCS9_OIDS[index]. -
value
Value set of this attribute. Its class is given byVALUE_CLASSES[index].
-
-
Constructor Details
-
PKCS9Attribute
Construct an attribute object from the attribute's OID and value. If the attribute is single-valued, provide only one value. If the attribute is multiple-valued, provide an array containing all the values. Arrays of length zero are accepted, though probably useless.The following table gives the class that
valuemust have for a given attribute.value OID Attribute Type Name Kind Value Class 1.2.840.113549.1.9.1 EmailAddress Multiple-valued String[]1.2.840.113549.1.9.2 UnstructuredName Multiple-valued String[]1.2.840.113549.1.9.3 ContentType Single-valued ObjectIdentifier1.2.840.113549.1.9.4 MessageDigest Single-valued byte[]1.2.840.113549.1.9.5 SigningTime Single-valued Date1.2.840.113549.1.9.6 Countersignature Multiple-valued SignerInfo[]1.2.840.113549.1.9.7 ChallengePassword Single-valued String1.2.840.113549.1.9.8 UnstructuredAddress Single-valued String[]1.2.840.113549.1.9.9 ExtendedCertificateAttributes Multiple-valued (not supported) 1.2.840.113549.1.9.10 IssuerAndSerialNumber Single-valued (not supported) 1.2.840.113549.1.9.11 PasswordCheck Single-valued (not supported) 1.2.840.113549.1.9.12 PublicKey Single-valued (not supported) 1.2.840.113549.1.9.13 SigningDescription Single-valued (not supported) 1.2.840.113549.1.9.14 ExtensionRequest Single-valued Sequence- Throws:
IllegalArgumentException
-
PKCS9Attribute
Construct an attribute object from the attribute's name and value. If the attribute is single-valued, provide only one value. If the attribute is multiple-valued, provide an array containing all the values. Arrays of length zero are accepted, though probably useless.The following table gives the class that
valuemust have for a given attribute. Reasonable variants of these attributes are accepted; in particular, case does not matter.value OID Attribute Type Name Kind Value Class 1.2.840.113549.1.9.1 EmailAddress Multiple-valued String[]1.2.840.113549.1.9.2 UnstructuredName Multiple-valued String[]1.2.840.113549.1.9.3 ContentType Single-valued ObjectIdentifier1.2.840.113549.1.9.4 MessageDigest Single-valued byte[]1.2.840.113549.1.9.5 SigningTime Single-valued Date1.2.840.113549.1.9.6 Countersignature Multiple-valued SignerInfo[]1.2.840.113549.1.9.7 ChallengePassword Single-valued String1.2.840.113549.1.9.8 UnstructuredAddress Single-valued String[]1.2.840.113549.1.9.9 ExtendedCertificateAttributes Multiple-valued (not supported) 1.2.840.113549.1.9.10 IssuerAndSerialNumber Single-valued (not supported) 1.2.840.113549.1.9.11 PasswordCheck Single-valued (not supported) 1.2.840.113549.1.9.12 PublicKey Single-valued (not supported) 1.2.840.113549.1.9.13 SigningDescription Single-valued (not supported) 1.2.840.113549.1.9.14 ExtensionRequest Single-valued Sequence- Throws:
IllegalArgumentException- if thenameis not recognized of thevaluehas the wrong type.
-
PKCS9Attribute
Construct a PKCS9Attribute from its encoding on an input stream.- Throws:
IOException- on parsing error.
-
-
Method Details
-
init
- Throws:
IllegalArgumentException
-
decode
Decode a PKCS9 attribute.- Parameters:
val- the DerValue representing the DER encoding of the attribute.- Throws:
IOException
-
derEncode
Write the DER encoding of this attribute to an output stream.N.B.: This method always encodes values of ChallengePassword and UnstructuredAddress attributes as ASN.1
PrintableStrings, without checking whether they should be encoded asT61Strings.- Specified by:
derEncodein interfaceDerEncoder- Parameters:
out- the stream on which the DER encoding is written.- Throws:
IOException- If an error occurred.
-
getValue
Get the value of this attribute. If the attribute is single-valued, return just the one value. If the attribute is multiple-valued, return an array containing all the values. It is possible for this array to be of length 0.The following table gives the class of the value returned, depending on the type of this attribute.
value OID Attribute Type Name Kind Value Class 1.2.840.113549.1.9.1 EmailAddress Multiple-valued String[]1.2.840.113549.1.9.2 UnstructuredName Multiple-valued String[]1.2.840.113549.1.9.3 ContentType Single-valued ObjectIdentifier1.2.840.113549.1.9.4 MessageDigest Single-valued byte[]1.2.840.113549.1.9.5 SigningTime Single-valued Date1.2.840.113549.1.9.6 Countersignature Multiple-valued SignerInfo[]1.2.840.113549.1.9.7 ChallengePassword Single-valued String1.2.840.113549.1.9.8 UnstructuredAddress Single-valued String[]1.2.840.113549.1.9.9 ExtendedCertificateAttributes Multiple-valued (not supported) 1.2.840.113549.1.9.10 IssuerAndSerialNumber Single-valued (not supported) 1.2.840.113549.1.9.11 PasswordCheck Single-valued (not supported) 1.2.840.113549.1.9.12 PublicKey Single-valued (not supported) 1.2.840.113549.1.9.13 SigningDescription Single-valued (not supported) 1.2.840.113549.1.9.14 ExtensionRequest Single-valued Sequence -
isSingleValued
public boolean isSingleValued()Show whether this attribute is single-valued. -
getOID
Return the OID of this attribute. -
getName
Return the name of this attribute. -
getOID
Return the OID for a given attribute name or null if we don't recognize the name. -
getName
Return the attribute name for a given OID or null if we don't recognize the oid. -
toString
Returns a string representation of this attribute. -
indexOf
Beginning the search atstart, find the first indexisuch thata[i] = obj.- Returns:
- the index, if found, and -1 otherwise.
-
throwSingleValuedException
Throw an exception when there are multiple values for a single-valued attribute.- Throws:
IOException
-
throwTagException
Throw an exception when the tag on a value encoding is wrong for the attribute whose value it is.- Throws:
IOException
-