com.ibm.security12.sun.security.pkcs
Class PKCS9Attribute

java.lang.Object
  |
  +--com.ibm.security12.sun.security.pkcs.PKCS9Attribute

public class PKCS9Attribute
extends Object
implements DerEncoder

Class supporting any PKCS9 attributes. Supports DER decoding and access to attribute values, but not DER encoding or setting of values.

Type/Class Table

The following table shows the correspondence between PKCS9 attribute types and value component classes.

Object Identifier Attribute Name Type Value Class
1.2.840.113549.1.9.1 EmailAddress Multi-valued String[]
1.2.840.113549.1.9.2 UnstructuredName Multi-valued String[]
1.2.840.113549.1.9.3 ContentType Single-valued ObjectIdentifier
1.2.840.113549.1.9.4 MessageDigest Single-valued byte[]
1.2.840.113549.1.9.5 SigningTime Single-valued Date
1.2.840.113549.1.9.6 Countersignature Multi-valued SignerInfo[]
1.2.840.113549.1.9.7 ChallengePassword Single-valued String
1.2.840.113549.1.9.8 UnstructuredAddress Single-valued String
1.2.840.113549.1.9.9 ExtendedCertificateAttributes Multi-valued (not supported)
1.2.840.113549.1.9.10 IssuerAndSerialNumber Single-valued (not supported)
1.2.840.113549.1.9.{11,12} RSA DSI proprietary Single-valued (not supported)
1.2.840.113549.1.9.13 S/MIME unused assignment Single-valued (not supported)
1.2.840.113549.1.9.14 ExtensionRequest Single-valued CertificateExtensions
1.2.840.113549.1.9.15 SMIMECapability Single-valued (not supported)

Version:
1.4 98/09/11
Author:
Douglas Hoover

Field Summary
static ObjectIdentifier CHALLENGE_PASSWORD_OID
           
static String CHALLENGE_PASSWORD_STR
           
static ObjectIdentifier CONTENT_TYPE_OID
           
static String CONTENT_TYPE_STR
           
static ObjectIdentifier COUNTERSIGNATURE_OID
           
static String COUNTERSIGNATURE_STR
           
static ObjectIdentifier EMAIL_ADDRESS_OID
           
static String EMAIL_ADDRESS_STR
           
static ObjectIdentifier EXTENDED_CERTIFICATE_ATTRIBUTES_OID
           
static String EXTENDED_CERTIFICATE_ATTRIBUTES_STR
           
static ObjectIdentifier EXTENSION_REQUEST_OID
           
static String EXTENSION_REQUEST_STR
           
static ObjectIdentifier ISSUER_SERIALNUMBER_OID
           
static String ISSUER_SERIALNUMBER_STR
           
static ObjectIdentifier MESSAGE_DIGEST_OID
           
static String MESSAGE_DIGEST_STR
           
static ObjectIdentifier SIGNING_TIME_OID
           
static String SIGNING_TIME_STR
           
static ObjectIdentifier SMIME_CAPABILITY_OID
           
static String SMIME_CAPABILITY_STR
           
static ObjectIdentifier UNSTRUCTURED_ADDRESS_OID
           
static String UNSTRUCTURED_ADDRESS_STR
           
static ObjectIdentifier UNSTRUCTURED_NAME_OID
           
static String UNSTRUCTURED_NAME_STR
           
 
Constructor Summary
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.
PKCS9Attribute(String name, Object value)
          Construct an attribute object from the attribute's name and value.
 
Method Summary
 void derEncode(OutputStream out)
          Write the DER encoding of this attribute to an output stream.
 String getName()
          Return the name of this attribute.
static String getName(ObjectIdentifier oid)
          Return the attribute name for a given OID or null if we don't recognize the oid.
 ObjectIdentifier getOID()
          Return the OID of this attribute.
static ObjectIdentifier getOID(String name)
          Return the OID for a given attribute name or null if we don't recognize the name.
 Object getValue()
          Get the value of this attribute.
 boolean isSingleValued()
          Show whether this attribute is single-valued.
 String toString()
          Returns a string representation of this attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMAIL_ADDRESS_OID

public static final ObjectIdentifier EMAIL_ADDRESS_OID

UNSTRUCTURED_NAME_OID

public static final ObjectIdentifier UNSTRUCTURED_NAME_OID

CONTENT_TYPE_OID

public static final ObjectIdentifier CONTENT_TYPE_OID

MESSAGE_DIGEST_OID

public static final ObjectIdentifier MESSAGE_DIGEST_OID

SIGNING_TIME_OID

public static final ObjectIdentifier SIGNING_TIME_OID

COUNTERSIGNATURE_OID

public static final ObjectIdentifier COUNTERSIGNATURE_OID

CHALLENGE_PASSWORD_OID

public static final ObjectIdentifier CHALLENGE_PASSWORD_OID

UNSTRUCTURED_ADDRESS_OID

public static final ObjectIdentifier UNSTRUCTURED_ADDRESS_OID

EXTENDED_CERTIFICATE_ATTRIBUTES_OID

public static final ObjectIdentifier EXTENDED_CERTIFICATE_ATTRIBUTES_OID

ISSUER_SERIALNUMBER_OID

public static final ObjectIdentifier ISSUER_SERIALNUMBER_OID

EXTENSION_REQUEST_OID

public static final ObjectIdentifier EXTENSION_REQUEST_OID

SMIME_CAPABILITY_OID

public static final ObjectIdentifier SMIME_CAPABILITY_OID

EMAIL_ADDRESS_STR

public static final String EMAIL_ADDRESS_STR

UNSTRUCTURED_NAME_STR

public static final String UNSTRUCTURED_NAME_STR

CONTENT_TYPE_STR

public static final String CONTENT_TYPE_STR

MESSAGE_DIGEST_STR

public static final String MESSAGE_DIGEST_STR

SIGNING_TIME_STR

public static final String SIGNING_TIME_STR

COUNTERSIGNATURE_STR

public static final String COUNTERSIGNATURE_STR

CHALLENGE_PASSWORD_STR

public static final String CHALLENGE_PASSWORD_STR

UNSTRUCTURED_ADDRESS_STR

public static final String UNSTRUCTURED_ADDRESS_STR

EXTENDED_CERTIFICATE_ATTRIBUTES_STR

public static final String EXTENDED_CERTIFICATE_ATTRIBUTES_STR

ISSUER_SERIALNUMBER_STR

public static final String ISSUER_SERIALNUMBER_STR

EXTENSION_REQUEST_STR

public static final String EXTENSION_REQUEST_STR

SMIME_CAPABILITY_STR

public static final String SMIME_CAPABILITY_STR
Constructor Detail

PKCS9Attribute

public PKCS9Attribute(ObjectIdentifier oid,
                      Object value)
               throws IllegalArgumentException
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 multi-valued, provide an array containing all the values. Arrays of length zero are accepted, though probably useless.

The table gives the class that value must have for a given attribute.


PKCS9Attribute

public PKCS9Attribute(String name,
                      Object value)
               throws IllegalArgumentException
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 multi-valued, provide an array containing all the values. Arrays of length zero are accepted, though probably useless.

The table gives the class that value must have for a given attribute. Reasonable variants of these attributes are accepted; in particular, case does not matter.

Throws:
IllegalArgumentException - if the name is not recognized of the value has the wrong type.

PKCS9Attribute

public PKCS9Attribute(DerValue derVal)
               throws IOException
Construct a PKCS9Attribute from its encoding on an input stream.
Parameters:
val - the DerValue representing the DER encoding of the attribute.
Throws:
IOException - on parsing error.
Method Detail

derEncode

public void derEncode(OutputStream out)
               throws IOException
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 as T61Strings.

Specified by:
derEncode in interface DerEncoder

getValue

public Object getValue()
Get the value of this attribute. If the attribute is single-valued, return just the one value. If the attribute is multi-valued, return an array containing all the values. It is possible for this array to be of length 0.

The table gives the class of the value returned, depending on the type of this attribute.


isSingleValued

public boolean isSingleValued()
Show whether this attribute is single-valued.

getOID

public ObjectIdentifier getOID()
Return the OID of this attribute.

getName

public String getName()
Return the name of this attribute.

getOID

public static ObjectIdentifier getOID(String name)
Return the OID for a given attribute name or null if we don't recognize the name.

getName

public static String getName(ObjectIdentifier oid)
Return the attribute name for a given OID or null if we don't recognize the oid.

toString

public String toString()
Returns a string representation of this attribute.
Overrides:
toString in class Object