public class KeyUsageExtension extends Extension implements CertAttrSet<java.lang.String>
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).
Extension,
CertAttrSet| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CRL_SIGN |
static java.lang.String |
DATA_ENCIPHERMENT |
static java.lang.String |
DECIPHER_ONLY |
static java.lang.String |
DIGITAL_SIGNATURE |
static java.lang.String |
ENCIPHER_ONLY |
static java.lang.String |
IDENT
Identifier for this attribute, to be used with the
get, set, delete methods of Certificate, x509 type.
|
static java.lang.String |
KEY_AGREEMENT |
static java.lang.String |
KEY_CERTSIGN |
static java.lang.String |
KEY_ENCIPHERMENT |
static java.lang.String |
NAME
Attribute names.
|
static java.lang.String |
NON_REPUDIATION |
critical, extensionId, extensionValue| Constructor and Description |
|---|
KeyUsageExtension()
Create a default key usage.
|
KeyUsageExtension(BitArray bitString)
Create a KeyUsageExtension with the passed bit settings.
|
KeyUsageExtension(boolean[] bitString)
Create a KeyUsageExtension with the passed bit settings.
|
KeyUsageExtension(java.lang.Boolean critical,
java.lang.Object value)
Create the extension from the passed DER encoded value of the same.
|
KeyUsageExtension(byte[] bitString)
Create a KeyUsageExtension with the passed bit settings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete(java.lang.String name)
Delete the attribute value.
|
void |
encode(java.io.OutputStream out)
Write the extension to the DerOutputStream.
|
java.lang.Object |
get(java.lang.String name)
Get the attribute value.
|
boolean[] |
getBits() |
java.util.Enumeration<java.lang.String> |
getElements()
Return an enumeration of names of attributes existing within this
attribute.
|
java.lang.String |
getName()
Return the name of this attribute.
|
void |
set(java.lang.String name,
java.lang.Object obj)
Set the attribute value.
|
java.lang.String |
toString()
Returns a printable representation of the KeyUsage.
|
encode, equals, getExtensionId, getExtensionValue, hashCode, isCriticalpublic static final java.lang.String IDENT
public static final java.lang.String NAME
public static final java.lang.String DIGITAL_SIGNATURE
public static final java.lang.String NON_REPUDIATION
public static final java.lang.String KEY_ENCIPHERMENT
public static final java.lang.String DATA_ENCIPHERMENT
public static final java.lang.String KEY_AGREEMENT
public static final java.lang.String KEY_CERTSIGN
public static final java.lang.String CRL_SIGN
public static final java.lang.String ENCIPHER_ONLY
public static final java.lang.String DECIPHER_ONLY
public KeyUsageExtension(byte[] bitString)
throws java.io.IOException
bitString - the bits to be set for the extension.java.io.IOExceptionpublic KeyUsageExtension(boolean[] bitString)
throws java.io.IOException
bitString - the bits to be set for the extension.java.io.IOExceptionpublic KeyUsageExtension(BitArray bitString) throws java.io.IOException
bitString - the bits to be set for the extension.java.io.IOExceptionpublic KeyUsageExtension(java.lang.Boolean critical,
java.lang.Object value)
throws java.io.IOException
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).java.lang.ClassCastException - if value is not an array of bytesjava.io.IOException - on error.public KeyUsageExtension()
public void set(java.lang.String name,
java.lang.Object obj)
throws java.io.IOException
set in interface CertAttrSet<java.lang.String>name - the name of the attribute (e.g. "x509.info.key")obj - the attribute object.java.io.IOException - on other errors.public java.lang.Object get(java.lang.String name)
throws java.io.IOException
get in interface CertAttrSet<java.lang.String>name - the name of the attribute to return.java.io.IOException - on other errors.public void delete(java.lang.String name)
throws java.io.IOException
delete in interface CertAttrSet<java.lang.String>name - the name of the attribute to delete.java.io.IOException - on other errors.public java.lang.String toString()
toString in interface CertAttrSet<java.lang.String>toString in class Extensionpublic void encode(java.io.OutputStream out)
throws java.io.IOException
encode in interface CertAttrSet<java.lang.String>out - the DerOutputStream to write the extension to.java.io.IOException - on encoding errors.public java.util.Enumeration<java.lang.String> getElements()
getElements in interface CertAttrSet<java.lang.String>public boolean[] getBits()
public java.lang.String getName()
getName in interface CertAttrSet<java.lang.String>Copyright © 2020. All Rights Reserved.