APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.x509

public Class KeyUsageExtension

extends Extension
Class Inheritance
Imports
java.io.IOException, sun.security.util.*

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).

Authors
Amit Kapoor, Hemma Prafullchandra
See Also
Extension

Field Summary

Modifier and TypeField and Description
private boolean[]
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
Inherited from sun.security.x509.Extension:
criticalextensionIdextensionValue

Constructor Summary

AccessConstructor and Description
public
KeyUsageExtension(byte[]
the bits to be set for the extension.
bitString
)

Create a KeyUsageExtension with the passed bit settings.

public
KeyUsageExtension(boolean[]
the bits to be set for the extension.
bitString
)

Create a KeyUsageExtension with the passed bit settings.

public
KeyUsageExtension(BitArray
the bits to be set for the extension.
bitString
)

Create a KeyUsageExtension with the passed bit settings.

public
KeyUsageExtension(Boolean
true if the extension is to be treated as critical.
critical
,
Object
an array of DER encoded bytes of the actual value (possibly wrapped in an OCTET STRING).
value
)

Create the extension from the passed DER encoded value of the same.

public
KeyUsageExtension()

Create a default key usage.

Method Summary

Modifier and TypeMethod and Description
public void
encode(DerOutputStream
the DerOutputStream to write the extension to.
out
)

Overrides sun.security.x509.Extension.encode.

Implements sun.security.util.DerEncoder.encode.

Write the extension to the DerOutputStream.

private void
public boolean
get(String name)

Get the attribute value.

public boolean[]
public String
getName()

Overrides sun.security.x509.Extension.getName.

Return the name of this extension.

private boolean
isSet(int
the position in the bit string to check.
position
)

Check if bit is set.

private void
set(int position, boolean val)

Set the bit at the specified position.

public void
set(String name, boolean val)

Set the attribute value.

public String
toString()

Overrides sun.security.x509.Extension.toString.

Returns a printable representation of the KeyUsage.

Inherited from sun.security.x509.Extension:
encodeequalsgetExtensionIdgetExtensionValuegetIdgetValuehashCodeisCriticalnewExtension

Field Detail

bitStringback to summary
private boolean[] bitString
CRL_SIGNback to summary
public static final String CRL_SIGN
DATA_ENCIPHERMENTback to summary
public static final String DATA_ENCIPHERMENT
DECIPHER_ONLYback to summary
public static final String DECIPHER_ONLY
DIGITAL_SIGNATUREback to summary
public static final String DIGITAL_SIGNATURE
ENCIPHER_ONLYback to summary
public static final String ENCIPHER_ONLY
KEY_AGREEMENTback to summary
public static final String KEY_AGREEMENT
KEY_CERTSIGNback to summary
public static final String KEY_CERTSIGN
KEY_ENCIPHERMENTback to summary
public static final String KEY_ENCIPHERMENT
NAMEback to summary
public static final String NAME
NON_REPUDIATIONback to summary
public static final String NON_REPUDIATION

Constructor Detail

KeyUsageExtensionback to summary
public KeyUsageExtension(byte[] bitString)

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

Parameters
bitString:byte[]

the bits to be set for the extension.

KeyUsageExtensionback to summary
public KeyUsageExtension(boolean[] bitString)

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

Parameters
bitString:boolean[]

the bits to be set for the extension.

KeyUsageExtensionback to summary
public KeyUsageExtension(BitArray bitString)

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

Parameters
bitString:BitArray

the bits to be set for the extension.

KeyUsageExtensionback to summary
public KeyUsageExtension(Boolean critical, Object value) throws IOException

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:Boolean

true if the extension is to be treated as critical.

value:Object

an array of DER encoded bytes of the actual value (possibly wrapped in an OCTET STRING).

Exceptions
IOException:
on error.
ClassCastException:
if value is not an array of bytes
KeyUsageExtensionback to summary
public KeyUsageExtension()

Create a default key usage.

Method Detail

encodeback to summary
public void encode(DerOutputStream out)

Overrides sun.security.x509.Extension.encode.

Implements sun.security.util.DerEncoder.encode.

Write the extension to the DerOutputStream.

Parameters
out:DerOutputStream

the DerOutputStream to write the extension to.

Annotations
@Override
encodeThisback to summary
private void encodeThis()
getback to summary
public boolean get(String name) throws IOException

Get the attribute value.

getBitsback to summary
public boolean[] getBits()
getNameback to summary
public String getName()

Overrides sun.security.x509.Extension.getName.

Return the name of this extension.

Annotations
@Override
isSetback to summary
private boolean isSet(int position)

Check if bit is set.

Parameters
position:int

the position in the bit string to check.

setback to summary
private void set(int position, boolean val)

Set the bit at the specified position.

setback to summary
public void set(String name, boolean val) throws IOException

Set the attribute value.

toStringback to summary
public String toString()

Overrides sun.security.x509.Extension.toString.

Returns a printable representation of the KeyUsage.