Class KeyUsageExtension
java.lang.Object
org.mozilla.jss.netscape.security.x509.Extension
org.mozilla.jss.netscape.security.x509.KeyUsageExtension
- All Implemented Interfaces:
Serializable
,CertAttrSet
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).
- Version:
- 1.9
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean[]
static final String
static final int
static final String
static final int
static final String
static final int
static final String
static final int
static final String
static final int
static final String
Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.static final String
static final int
static final String
static final int
static final String
static final int
static final String
Attribute names.static String[]
static final int
static final String
static final int
private static final long
Fields inherited from class org.mozilla.jss.netscape.security.x509.Extension
critical, extensionId, extensionValue
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a default key usage.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
(byte[] bitString) KeyUsageExtension
(Boolean critical, Object value) Create the extension from the passed DER encoded value of the same.KeyUsageExtension
(BitArray bitString) Create a KeyUsageExtension with the passed bit settings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
decode
(InputStream in) Decode the extension from the InputStream.void
Delete the attribute value.void
encode
(OutputStream out) Write the extension to the DerOutputStream.private void
Get the attribute value.Return an enumeration of names of attributes existing within this attribute.boolean[]
getBits()
getName()
Return the name of this attribute.private boolean
isSet
(int position) Check if bit is set.private void
set
(int position, boolean val) Set the bit at the specified position.void
Set the attribute value.toString()
Returns a printable representation of the KeyUsage.Methods inherited from class org.mozilla.jss.netscape.security.x509.Extension
clearValue, encode, getExtensionId, getExtensionValue, isCritical, setCritical, setExtensionId, setExtensionValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
IDENT
Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.- See Also:
-
NAME
Attribute names.- See Also:
-
DIGITAL_SIGNATURE
- See Also:
-
NON_REPUDIATION
- See Also:
-
KEY_ENCIPHERMENT
- See Also:
-
DATA_ENCIPHERMENT
- See Also:
-
KEY_AGREEMENT
- See Also:
-
KEY_CERTSIGN
- See Also:
-
CRL_SIGN
- See Also:
-
ENCIPHER_ONLY
- See Also:
-
DECIPHER_ONLY
- See Also:
-
DIGITAL_SIGNATURE_BIT
public static final int DIGITAL_SIGNATURE_BIT- See Also:
-
NON_REPUDIATION_BIT
public static final int NON_REPUDIATION_BIT- See Also:
-
KEY_ENCIPHERMENT_BIT
public static final int KEY_ENCIPHERMENT_BIT- See Also:
-
DATA_ENCIPHERMENT_BIT
public static final int DATA_ENCIPHERMENT_BIT- See Also:
-
KEY_AGREEMENT_BIT
public static final int KEY_AGREEMENT_BIT- See Also:
-
KEY_CERTSIGN_BIT
public static final int KEY_CERTSIGN_BIT- See Also:
-
CRL_SIGN_BIT
public static final int CRL_SIGN_BIT- See Also:
-
ENCIPHER_ONLY_BIT
public static final int ENCIPHER_ONLY_BIT- See Also:
-
DECIPHER_ONLY_BIT
public static final int DECIPHER_ONLY_BIT- See Also:
-
NBITS
public static final int NBITS- See Also:
-
names
-
bitString
private boolean[] bitString
-
-
Constructor Details
-
KeyUsageExtension
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
-
KeyUsageExtension
- Throws:
IOException
-
KeyUsageExtension
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
-
KeyUsageExtension
- Throws:
IOException
-
KeyUsageExtension
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
-
KeyUsageExtension
Create the extension from the passed DER encoded value of the same.- Parameters:
critical
- true if the extension is to be treated as critical.value
- Array of DER encoded bytes of the actual value.- Throws:
IOException
- on error.
-
KeyUsageExtension
public KeyUsageExtension()Create a default key usage.
-
-
Method Details
-
encodeThis
- Throws:
IOException
-
isSet
private boolean isSet(int position) Check if bit is set.- Parameters:
position
- the position in the bit string to check.
-
set
private void set(int position, boolean val) Set the bit at the specified position. -
set
Set the attribute value.- Specified by:
set
in interfaceCertAttrSet
- Parameters:
name
- the name of the attribute (e.g. "x509.info.key")obj
- the attribute object.- Throws:
IOException
- on other errors.
-
get
Get the attribute value.- Specified by:
get
in interfaceCertAttrSet
- Parameters:
name
- the name of the attribute to return.- Returns:
- attribute value
- Throws:
IOException
- on other errors.
-
delete
Delete the attribute value.- Specified by:
delete
in interfaceCertAttrSet
- Parameters:
name
- the name of the attribute to delete.- Throws:
IOException
- on other errors.
-
toString
Returns a printable representation of the KeyUsage.- Specified by:
toString
in interfaceCertAttrSet
- Overrides:
toString
in classExtension
- Returns:
- value of this certificate attribute in printable form.
-
decode
Decode the extension from the InputStream.- Specified by:
decode
in interfaceCertAttrSet
- Parameters:
in
- the InputStream to unmarshal the contents from.- Throws:
IOException
- on decoding or validity errors.
-
encode
Write the extension to the DerOutputStream.- Specified by:
encode
in interfaceCertAttrSet
- Parameters:
out
- the DerOutputStream to write the extension to.- Throws:
IOException
- on encoding errors.
-
getAttributeNames
Return an enumeration of names of attributes existing within this attribute.- Specified by:
getAttributeNames
in interfaceCertAttrSet
- Returns:
- an enumeration of the attribute names.
-
getBits
public boolean[] getBits() -
getName
Return the name of this attribute.- Specified by:
getName
in interfaceCertAttrSet
- Returns:
- the name of this CertAttrSet.
-