public class ExtendedKeyUsage extends V3Extension
ExtendedKeyUsage
Extension.
The ExtendedKeyUsage
extension is a standard X509v3 extension, which
may or may not be marked as being critical.
Each extension is associated with a specific certificateExtension
object identifier, derived from:
certificateExtension OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} id-ce OBJECT IDENTIFIER ::= certificateExtension
The object identifier for the ExtendedKeyUsage
extension
is defined as:
id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 }
which corresponds to the OID string "2.5.29.37".
The X.509 Certificate and CRL profile presented in RFC 3280 specifies the extended key usage extension for defining purposes for which the subject's public key may be used. These purposes may be specified in addition to those of the KeyUsage extension, or in place of those.
The ASN.1 definition of the ExtendedKeyUsage
extension is specified
as follows:
ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId KeyPurposeId ::= OBJECT IDENTIFIER
Key purposes may be defined by any organization with a need. Object identifiers used to identify key purposes shall be assigned in accordance with IANA or ITU-T Rec. X.660 | ISO/IEC/ITU 9834-1.
More information can be found in RFC 3280, section 4.2.1.13 "Extended Key Usage".
The following extended key usage purposes are defined by RFC 3280:
For adding a ExtendedKeyUsage
extension object to a X509Certificate, use the
addExtension
method of the iaik.x509.X509Certificate
class, e.g.:
X509Certificate cert = new X509Certificate(); ... ExtendedKeyUsage extKeyUsage = new ExtendedKeyUsage(); //add purposes extKeyUsage.addKeyPurposeID(ExtendedKeyUsage.codeSigning); extKeyUsage.addKeyPurposeID(ExtendedKeyUsage.timeStamping); extKeyUsage.setCritical(true); cert.addExtension(keyUsage);
ObjectID
,
X509Certificate
,
X509Extensions
,
V3Extension
Modifier and Type | Field and Description |
---|---|
static ObjectID |
anyExtendedKeyUsage
The "Any extended key usage" ExtendedKeyUsage purpose id.
|
static ObjectID |
clientAuth
The "TLS Web client authentication" ExtendedKeyUsage purpose id.
|
static ObjectID |
codeSigning
The "Code Signing" ExtendedKeyUsage purpose id.
|
static ObjectID |
emailProtection
The "E-mail protection" ExtendedKeyUsage purpose id.
|
static ObjectID |
iKEIntermediate
The "iKEIntermediate" ExtendedKeyUsage purpose id.
|
static ObjectID |
ipsecEndSystem
The "IP security end system" ExtendedKeyUsage purpose id.
|
static ObjectID |
ipsecTunnel
The "IP security tunnel termination" ExtendedKeyUsage purpose id.
|
static ObjectID |
ipsecUser
The "IP security user" ExtendedKeyUsage purpose id.
|
static ObjectID |
microsoftSGC
The "Microsoft Server Gated Cryptography" ExtendedKeyUsage purpose id.
|
static ObjectID |
netscapeSGC
The "Netscape Server Gated Cryptography" ExtendedKeyUsage purpose id.
|
static ObjectID |
ocspSigning
The OCSP signing ExtendedKeyUsage purpose id.
|
static ObjectID |
oid
The object identifier of this ExtendedKeyUsage extension.
|
static ObjectID |
serverAuth
The "TLS Web server authentication" ExtendedKeyUsage purpose id.
|
static ObjectID |
timeStamping
The "Timestamping" ExtendedKeyUsage purpose id.
|
static ObjectID |
tslSigning
The TSL signing ExtendedKeyUsage purpose id.
|
critical
Constructor and Description |
---|
ExtendedKeyUsage()
Creates a new ExtendedKeyUsage extension.
|
ExtendedKeyUsage(ObjectID keyPurposeID)
Create an ExtendedKeyUsage with a given key purpose.
|
ExtendedKeyUsage(ObjectID[] keyPurposes)
Create an ExtendedKeyUsage with an array of key purposes.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyPurposeID(ObjectID keyPurposeID)
Adds a KeyPurposeID to this extension.
|
boolean |
contains(ObjectID keyPurposeID)
Checks if the given key purpose id is included.
|
ObjectID[] |
getKeyPurposeIDs()
Returns all KeyPurposeIDs included in this extension.
|
ObjectID |
getObjectID()
Returns the object ID of this
ExtendedKeyUsage extension. |
int |
hashCode()
Returns a hashcode for this identity.
|
void |
init(ASN1Object obj)
Inits this
ExtendedKeyUsage implementation with an ASN1Object
representing the value of this extension. |
void |
removeAllKeyPurposeIDs()
Removes all KeyPurposeIDs from this extension.
|
boolean |
removeKeyPurposeID(ObjectID keyPurposeID)
Removes a KeyPurposeID from this extension.
|
ASN1Object |
toASN1Object()
Returns an ASN1Object representing the value of this
ExtendedKeyUsage
extension object. |
java.lang.String |
toString()
Returns a string that represents the contents of
this
ExtendedKeyUsage extension. |
getName, isCritical, setCritical
public static final ObjectID oid
public static final ObjectID anyExtendedKeyUsage
public static final ObjectID serverAuth
public static final ObjectID clientAuth
public static final ObjectID codeSigning
public static final ObjectID emailProtection
public static final ObjectID ipsecEndSystem
public static final ObjectID ipsecTunnel
public static final ObjectID ipsecUser
public static final ObjectID timeStamping
public static final ObjectID ocspSigning
public static final ObjectID iKEIntermediate
public static final ObjectID microsoftSGC
public static final ObjectID netscapeSGC
public static final ObjectID tslSigning
* -- OID for TSL signing KeyPurposeID for ExtKeyUsageSyntax id-tsl OBJECT IDENTIFIER { itu-t(0) identified-organization(4) etsi(0) tsl-specification (2231) } id-tsl-kp OBJECT IDENTIFIER ::= { id-tsl kp(3) } id-tsl-kp-tslSigning OBJECT IDENTIFIER ::= { id-tsl-kp tsl-signing(0) }OID string: "0.4.0.2231.3.0".
public ExtendedKeyUsage()
addKeyUsagePurposeID
method for adding some purpose, e.g.:
ExtendedKeyUsage extKeyUsage = new ExtendedKeyUsage(); extKeyUsage.addKeyPurposeID(ExtendedKeyUsage.codeSigning); extKeyUsage.addKeyPurposeID(ExtendedKeyUsage.timeStamping);
public ExtendedKeyUsage(ObjectID keyPurposeID)
public ExtendedKeyUsage(ObjectID[] keyPurposes)
public void addKeyPurposeID(ObjectID keyPurposeID)
keyPurposeID
- the KeyPurposeID to addpublic boolean removeKeyPurposeID(ObjectID keyPurposeID)
keyPurposeID
- the KeyPurposeID to removepublic void removeAllKeyPurposeIDs()
public ObjectID[] getKeyPurposeIDs()
public boolean contains(ObjectID keyPurposeID)
keyPurposeID
- the key purpose id to be checkedtrue
if the given key purpose id is included
false
if it is not includedpublic ASN1Object toASN1Object() throws X509ExtensionException
ExtendedKeyUsage
extension object.
The returned ASN1Object is an ASN.1 Sequence representing the several purpose ids:
ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId KeyPurposeId ::= OBJECT IDENTIFIER
toASN1Object
in class V3Extension
ExtendedKeyUsage
as ASN1ObjectX509ExtensionException
- if the extension could not be createdpublic void init(ASN1Object obj) throws X509ExtensionException
ExtendedKeyUsage
implementation with an ASN1Object
representing the value of this extension.
The given ASN1Object is the one created by toASN1Object()
.
This method is used by the X509Extensions
class when parsing the ASN.1 representation
of a certificate for properly initializing an included
ExtendedKeyUsage 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 ExtendedKeyUsage as ASN1ObjectX509ExtensionException
- if the extension could not be parsedpublic int hashCode()
hashCode
in class V3Extension
public ObjectID getObjectID()
ExtendedKeyUsage
extension.getObjectID
in class V3Extension
public java.lang.String toString()
ExtendedKeyUsage
extension.toString
in class java.lang.Object