public class SMIMECapabilities extends V3Extension
S/MIMEv3 (RFC 4262)
specifies the SMIMECapabilities
extension to may be included in a certificate
for announcing the cryptographic S/MIME capabilities
of the certificate subject. The SMIMECapabilities extension
has the same ASN.1 syntax as the SMIMECapabilities attribute
defines by RFC 3851:
SMIMECapability ::= SEQUENCE { capabilityID OBJECT IDENTIFIER, parameters ANY DEFINED BY capabilityID OPTIONAL } SMIMECapabilities ::= SEQUENCE OF SMIMECapabilityHowever, whereas the SMIMECapabilities attribute maybe included in an S/MIME mail, the SMIMECapabilities may be included in a certificate. Any algorithm the certificate subject (or her/his S/MIME agent) is able to handle is announced by an
SMIMECapability
object
identifying the algorithm by its OID. The optional parameters field
may provide information that may be required to differentiate
between two instances of the same algorithm (for instance key length
for RC2). Any SMimeCapability to be announced is collected
and included into an SMIMECapabilities extension in preference order.
SMIMECapability ::= SEQUENCE { capabilityID OBJECT IDENTIFIER, parameters ANY DEFINED BY capabilityID OPTIONAL } SMIMECapabilities ::= SEQUENCE OF SMIMECapabilityWhen
creating
an
SMIMECapabilities object the list of capabilities
has to be supplied. The following example shows how to create
an SMIMECapabilities extension containing capabilities announcing the
ability to handle the TripleDES algorithm, and the RC2 algorithm for
key lengths of 128, 64 and 40 bits, in this preference order:
// capabilites SMIMECapability[] capabilities = new SMIMECapability[5]; // 3DES capabilities[0] = new SMIMECapability(AlgorithmID.des_EDE3_CBC.getAlgorithm()); // RC2 128 capabilities[1] = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); capabilities[1].setParameters(new INTEGER(128)); // RC2 64 capabilities[2] = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); capabilities[2].setParameters(new INTEGER(64)); // DES capabilities[3] = new SMIMECapability(AlgorithmID.des_CBC.getAlgorithm()); // RC2 40 capabilities[4] = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); capabilities[4].setParameters(new INTEGER(40)); SMIMECapabilities smimeCapabilities = new SMIMECapabilities(capabilities); .. // add es extension to a certificate X509Certificate cert = ...; cert.addExtension(smimeCapabilities);
To parse an SMIMECapabilities extension from a certificate use method
with the SMIMECapabilities oid. Subsequently parse the SMIMECapabilities
extension for the included getExtension
capabilities
:
// the certificate X509Certificate cert = ...; ... // get SMIMECapabilities extension SMIMECapabilities smimeCapabilities = (SMIMECapabilities)cert.getExtension(SMIMECapabilities.oid); if (smimeCapabilities != null) { // get capabilities SMIMECapability capabilities[] = smimeCapabilities.getCapabilities(); if (capabilities != null) { for (int i = 0; i < capabilities.length; i++) { ... } } }
SMIMECapability
,
X509Certificate
Modifier and Type | Field and Description |
---|---|
static ObjectID |
oid
The object identifier of this
SMIMECapabilities extension. |
critical
Constructor and Description |
---|
SMIMECapabilities()
Empty default constructor.
|
SMIMECapabilities(SMIMECapability[] capabilities)
Creates an SMIMECapabilities extension for the supplied list of algorithm
capabilities to be announced.
|
Modifier and Type | Method and Description |
---|---|
SMIMECapability[] |
getCapabilities()
Returns the capabilites included.
|
SMIMECapability[] |
getCapabilities(ObjectID capabilityID)
Returns all capabilities with the same capability ID.
|
ObjectID |
getObjectID()
Returns the OID identifying the SMIMECapabilities extension.
|
int |
hashCode()
Returns a hashcode for this identity.
|
void |
init(ASN1Object obj)
Inits this
SMIMECapabilities object with an ASN1Object
representing the value of this extension. |
ASN1Object |
toASN1Object()
Returns this SMIMECapabilities as ASN1Object.
|
java.lang.String |
toString()
Returns a string representation of this SMIMECapabilities.
|
java.lang.String |
toString(boolean detailed)
Returns a string representation of this SMIMECapabilities.
|
getName, isCritical, setCritical
public static final ObjectID oid
SMIMECapabilities
extension.
The corresponding OID string is "1.2.840.113549.1.9.15".public SMIMECapabilities()
public SMIMECapabilities(SMIMECapability[] capabilities)
capabilities
- the algorithm capabilities to be announcedpublic SMIMECapability[] getCapabilities()
null
if no capabilities are includedpublic SMIMECapability[] getCapabilities(ObjectID capabilityID)
This method may be used for getting all included SMIMECapability
objects belonging to the same algorithm but possibly having different
algorithm parameters.
capabilityID
- the OID identifying the algorithm in mindnull
if
no capabilities with the requested ID are includedpublic void init(ASN1Object obj) throws X509ExtensionException
SMIMECapabilities
object with an ASN1Object
representing the value of this extension.
The given ASN1Object represents the SEQUENCE of SMIMECapability
elements included in the extension:
SMIMECapabilities ::= SEQUENCE OF SMIMECapabilityThis method is used by the
X509Extensions
class when parsing the ASN.1 representation
of a certificate for properly initializing an included
BasicConstraints extension. This method initializes the
extension only with its value, but not with its critical
specification. For that reason, this method shall not be
explicitly called by an application.init
in class V3Extension
obj
- the SMimeCapabilities value as ASN1ObjectX509ExtensionException
- if the extension could not be parsedpublic ASN1Object toASN1Object() throws X509ExtensionException
SMIMECapability
elements included in this extension:
SMIMECapabilities ::= SEQUENCE OF SMIMECapability
toASN1Object
in class V3Extension
X509ExtensionException
- if the extension could not be createdpublic ObjectID getObjectID()
getObjectID
in class V3Extension
public int hashCode()
hashCode
in class V3Extension
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean detailed)
detailed
- whether to print more detailed information