public class

KeyUsageExtension

extends Extension
implements CertAttrSet<T>
java.lang.Object
   ↳ sun.security.x509.Extension
     ↳ sun.security.x509.KeyUsageExtension

Class Overview

Represent the Key Usage Extension.

This extension, if present, defines the purpose (e.g., encipherment, signature, certificate signing) of the key contained in the certificate. The usage restriction might be employed when a multipurpose key is to be restricted (e.g., when an RSA key should be used only for signing or only for key encipherment).

Summary

Constants
String CRL_SIGN
String DATA_ENCIPHERMENT
String DECIPHER_ONLY
String DIGITAL_SIGNATURE
String ENCIPHER_ONLY
String IDENT Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.
String KEY_AGREEMENT
String KEY_CERTSIGN
String KEY_ENCIPHERMENT
String NAME Attribute names.
String NON_REPUDIATION
[Expand]
Inherited Fields
From class sun.security.x509.Extension
Public Constructors
KeyUsageExtension(byte[] bitString)
Create a KeyUsageExtension with the passed bit settings.
KeyUsageExtension(boolean[] bitString)
Create a KeyUsageExtension with the passed bit settings.
KeyUsageExtension(BitArray bitString)
Create a KeyUsageExtension with the passed bit settings.
KeyUsageExtension(Boolean critical, Object value)
Create the extension from the passed DER encoded value of the same.
KeyUsageExtension()
Create a default key usage.
Public Methods
void delete(String name)
Delete the attribute value.
void encode(OutputStream out)
Write the extension to the DerOutputStream.
Object get(String name)
Get the attribute value.
boolean[] getBits()
Enumeration<String> getElements()
Return an enumeration of names of attributes existing within this attribute.
String getName()
Return the name of this attribute.
void set(String name, Object obj)
Set the attribute value.
String toString()
Returns a printable representation of the KeyUsage.
[Expand]
Inherited Methods
From class sun.security.x509.Extension
From class java.lang.Object
From interface sun.security.x509.CertAttrSet

Constants

public static final String CRL_SIGN

Constant Value: "crl_sign"

public static final String DATA_ENCIPHERMENT

Constant Value: "data_encipherment"

public static final String DECIPHER_ONLY

Constant Value: "decipher_only"

public static final String DIGITAL_SIGNATURE

Constant Value: "digital_signature"

public static final String ENCIPHER_ONLY

Constant Value: "encipher_only"

public static final String IDENT

Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.

Constant Value: "x509.info.extensions.KeyUsage"

public static final String KEY_AGREEMENT

Constant Value: "key_agreement"

public static final String KEY_CERTSIGN

Constant Value: "key_certsign"

public static final String KEY_ENCIPHERMENT

Constant Value: "key_encipherment"

public static final String NAME

Attribute names.

Constant Value: "KeyUsage"

public static final String NON_REPUDIATION

Constant Value: "non_repudiation"

Public Constructors

public KeyUsageExtension (byte[] bitString)

Create a KeyUsageExtension with the passed bit settings. The criticality is set to true.

Parameters
bitString the bits to be set for the extension.
Throws
IOException

public KeyUsageExtension (boolean[] bitString)

Create a KeyUsageExtension with the passed bit settings. The criticality is set to true.

Parameters
bitString the bits to be set for the extension.
Throws
IOException

public KeyUsageExtension (BitArray bitString)

Create a KeyUsageExtension with the passed bit settings. The criticality is set to true.

Parameters
bitString the bits to be set for the extension.
Throws
IOException

public KeyUsageExtension (Boolean critical, Object value)

Create the extension from the passed DER encoded value of the same. The DER encoded value may be wrapped in an OCTET STRING.

Parameters
critical true if the extension is to be treated as critical.
value an array of DER encoded bytes of the actual value (possibly wrapped in an OCTET STRING).
Throws
ClassCastException if value is not an array of bytes
IOException on error.

public KeyUsageExtension ()

Create a default key usage.

Public Methods

public void delete (String name)

Delete the attribute value.

Parameters
name the name of the attribute to delete.
Throws
IOException

public void encode (OutputStream out)

Write the extension to the DerOutputStream.

Parameters
out the DerOutputStream to write the extension to.
Throws
IOException on encoding errors.

public Object get (String name)

Get the attribute value.

Parameters
name the name of the attribute to return.
Throws
IOException

public boolean[] getBits ()

public Enumeration<String> getElements ()

Return an enumeration of names of attributes existing within this attribute.

Returns
  • an enumeration of the attribute names.

public String getName ()

Return the name of this attribute.

Returns
  • the name of this CertAttrSet.

public void set (String name, Object obj)

Set the attribute value.

Parameters
name the name of the attribute (e.g. "x509.info.key")
obj the attribute object.
Throws
IOException

public String toString ()

Returns a printable representation of the KeyUsage.

Returns
  • a string representation of the object.