public class KeyUsageExtension extends Extension implements CertAttrSet
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
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
CRL_SIGN |
static int |
CRL_SIGN_BIT |
static java.lang.String |
DATA_ENCIPHERMENT |
static int |
DATA_ENCIPHERMENT_BIT |
static java.lang.String |
DECIPHER_ONLY |
static int |
DECIPHER_ONLY_BIT |
static java.lang.String |
DIGITAL_SIGNATURE |
static int |
DIGITAL_SIGNATURE_BIT |
static java.lang.String |
ENCIPHER_ONLY |
static int |
ENCIPHER_ONLY_BIT |
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 int |
KEY_AGREEMENT_BIT |
static java.lang.String |
KEY_CERTSIGN |
static int |
KEY_CERTSIGN_BIT |
static java.lang.String |
KEY_ENCIPHERMENT |
static int |
KEY_ENCIPHERMENT_BIT |
static java.lang.String |
NAME
Attribute names.
|
static java.lang.String[] |
names |
static int |
NBITS |
static java.lang.String |
NON_REPUDIATION |
static int |
NON_REPUDIATION_BIT |
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) |
KeyUsageExtension(boolean critical,
boolean[] bitString)
Create a KeyUsageExtension with the passed bit settings.
|
KeyUsageExtension(boolean critical,
byte[] 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) |
Modifier and Type | Method and Description |
---|---|
void |
decode(java.io.InputStream in)
Decode the extension from the InputStream.
|
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.
|
java.util.Enumeration<java.lang.String> |
getAttributeNames()
Return an enumeration of names of attributes existing within this
attribute.
|
boolean[] |
getBits() |
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.
|
clearValue, encode, getExtensionId, getExtensionValue, isCritical, setCritical, setExtensionId, setExtensionValue
public 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 static final int DIGITAL_SIGNATURE_BIT
public static final int NON_REPUDIATION_BIT
public static final int KEY_ENCIPHERMENT_BIT
public static final int DATA_ENCIPHERMENT_BIT
public static final int KEY_AGREEMENT_BIT
public static final int KEY_CERTSIGN_BIT
public static final int CRL_SIGN_BIT
public static final int ENCIPHER_ONLY_BIT
public static final int DECIPHER_ONLY_BIT
public static final int NBITS
public static java.lang.String[] names
public KeyUsageExtension(boolean critical, byte[] bitString) throws java.io.IOException
bitString
- the bits to be set for the extension.java.io.IOException
public KeyUsageExtension(byte[] bitString) throws java.io.IOException
java.io.IOException
public KeyUsageExtension(boolean critical, boolean[] bitString) throws java.io.IOException
bitString
- the bits to be set for the extension.java.io.IOException
public KeyUsageExtension(boolean[] bitString) throws java.io.IOException
java.io.IOException
public KeyUsageExtension(BitArray bitString) throws java.io.IOException
bitString
- the bits to be set for the extension.java.io.IOException
public 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
- Array of DER encoded bytes of the actual value.java.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
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
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
name
- the name of the attribute to delete.java.io.IOException
- on other errors.public java.lang.String toString()
toString
in interface CertAttrSet
toString
in class Extension
public void decode(java.io.InputStream in) throws java.io.IOException
decode
in interface CertAttrSet
in
- the InputStream to unmarshal the contents from.java.io.IOException
- on decoding or validity errors.public void encode(java.io.OutputStream out) throws java.io.IOException
encode
in interface CertAttrSet
out
- the DerOutputStream to write the extension to.java.io.IOException
- on encoding errors.public java.util.Enumeration<java.lang.String> getAttributeNames()
getAttributeNames
in interface CertAttrSet
public boolean[] getBits()
public java.lang.String getName()
getName
in interface CertAttrSet