|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.smime.attributes.SMIMECapability
public class SMIMECapability
The S/MIMEv3 type SMIMECapability.
S/MIMEv3 (RFC 5751)
specifies the SMimeCapability
to be used by an
S/MIME for announcing that it is able to handle some particular
algorithm capabilities. For that purpose the S/MIME client
creates a SMIMECapability object where it references the
algorithm it is able to handle by its algorithm object identifier.
If necessary the SMIMECapability object additionally may
include parameters providing information required to differentiate
between two instances of the same algorithm (for instance key length
for RC2). Any SMIMECapability a client want to announce is collected
and included into a SMIMECapabilities
attribute in preference order.
SMIMECapability ::= SEQUENCE { capabilityID OBJECT IDENTIFIER, parameters ANY DEFINED BY capabilityID OPTIONAL } SMIMECapabilities ::= SEQUENCE OF SMIMECapabilityWhen
creating
a SMIMECapability object
the OID of the algorithm has to be specified for announcing to be capable
to handle the corresponding algorithm. Any parameters (e.g. key length
supported for some particular algorithm) to be additionally announced can
be included by calling method setParameters
.
Since the parameters may have any ASN.1 representation method setParameters
simple expects them as an ASN1Object.
So, for instance, parameters announcing that the client is capable to handle RC2
for a key length of 128 bits, would be an ASN.1 INTEGER:
SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_128Capability.setParameters(new INTEGER(128));If the client also is capable to handle RC2 for key lengths of 40 and 64 bits, create a SMIMECapability object for these two key lengths, too, and -- together with any further capabilities to be announced -- subsequently set it for the
SMIMECapabilities
attribute, e.g.:
// RC2 128 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_128Capability.setParameters(new INTEGER(128)); // RC2 64 SMIMECapability rc2_64Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_64Capability.setParameters(new INTEGER(64)); // RC2 40 SMIMECapability rc2_40Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_40Capability.setParameters(new INTEGER(40)); // any further capabilities ... // add the capabilities in preference order to an SMIMECapabilities attribute: SMIMECapability[] capabilities = { ..., rc2_128Capability, rc2_64Capability, rc2_40Capability, ...}; SMIMECapabilities smimeCapabilities = new SMIMECapabilities(capabilities);
SMIMECapabilities
Constructor Summary | |
---|---|
SMIMECapability()
Empty default constructor. |
|
SMIMECapability(ASN1Object obj)
Creates an SMIMECapability from an ASN1Object. |
|
SMIMECapability(ObjectID capabilityID)
Creates an SMIMECapability for the given capability (algorithm) id. |
Method Summary | |
---|---|
void |
decode(ASN1Object obj)
Decodes an SMIMECapability from an ASN1Object. |
boolean |
equals(java.lang.Object obj)
Compares this SMIMECapability to the specified object. |
ObjectID |
getCapabilityID()
Gets the capability ID of this SMIMECapability object. |
ASN1Object |
getParameters()
Gets the algorithm specific parameters (if included) announced by this SMIMECapability. |
int |
hashCode()
Returns a hashcode for this SMIMECapability. |
void |
setParameters(ASN1Object parameters)
Sets the algorithm specific parameters (if required) to be announced by this SMIMECapability. |
ASN1Object |
toASN1Object()
Returns this SMIMECapability as ASN1Object. |
java.lang.String |
toString()
Returns a string representation of this SMIMECapability. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SMIMECapability()
public SMIMECapability(ObjectID capabilityID)
Use method setParameters
for
setting any parameters to be included.
capabilityID
- the capabilty oid identifying the algorithm for
which to create a SMimeCapabililtypublic SMIMECapability(ASN1Object obj) throws CodingException
obj
- the SMIMECapability as ASN1Object
CodingException
- if an error occurs while parsing the ASN1ObjectMethod Detail |
---|
public ObjectID getCapabilityID()
public ASN1Object getParameters()
Since the parameters may have any ASN.1 representation this method simple returns the parameters as ASN1Object. So, for instance, parameters announcing that the client is capable to handle RC2 for a key length of 128 bits, would be encoded as an ASN.1 INTEGER:
INTEGER rc2KeyLength = (INTEGER)capability.getParameters(); int keyLength = ((BigInteger)rc2KeyLength.getValue()).intValue();
null
if no
parameters are includedpublic void setParameters(ASN1Object parameters)
Since the parameters may have any ASN.1 representation this method simple expects them as an ASN1Object. So, for instance, parameters announcing that the client is capable to handle RC2 for a key length of 128 bits, would be an ASN.1 INTEGER:
SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_128Capability.setParameters(new INTEGER(128));If the client also is capable to handle RC2 for key lengths of 40 and 64 bits, create a SMIMECapability object for these two key lengths, too, and -- together with any further capabilities to be announced -- subsequently set it for the
SMIMECapabilities
attribute, e.g.:
// RC2 128 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_128Capability.setParameters(new INTEGER(128)); // RC2 64 SMIMECapability rc2_64Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_64Capability.setParameters(new INTEGER(64)); // RC2 40 SMIMECapability rc2_40Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm()); rc2_40Capability.setParameters(new INTEGER(40)); // any further capabilities ... // add the capabilities in preference order to an SMIMECapabilities attribute: SMIMECapability[] capabilities = { ..., rc2_128Capability, rc2_64Capability, rc2_40Capability, ...}; SMIMECapabilities smimeCapabilities = new SMIMECapabilities(capabilities);
parameters
- the parameters to be announced with this SMIMECapabilitypublic ASN1Object toASN1Object() throws CodingException
toASN1Object
in interface ASN1Type
CodingException
- if the ASN1Object cannot be created because
no capability ID is setpublic void decode(ASN1Object obj) throws CodingException
decode
in interface ASN1Type
obj
- the SMIMECapability as ASN1Object
CodingException
- if an error occurs while parsing the ASN1Objectpublic boolean equals(java.lang.Object obj)
SMIMECapability
to the specified object.
equals
in class java.lang.Object
obj
- the object to compare this SMIMECapability
against.
true
, if the given object is equal to this
SMIMECapability
,
false
otherwisepublic int hashCode()
The hashcode is calculated from the capabilityID only.
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |