Stay organized with collections
Save and categorize content based on your preferences.
Extension
public
interface
Extension
java.security.cert.Extension
|
This interface represents an X.509 extension.
Extensions provide a means of associating additional attributes with users
or public keys and for managing a certification hierarchy. The extension
format also allows communities to define private extensions to carry
information unique to those communities.
Each extension contains an object identifier, a criticality setting
indicating whether it is a critical or a non-critical extension, and
and an ASN.1 DER-encoded value. Its ASN.1 definition is:
Extension ::= SEQUENCE {
extnId OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extnValue OCTET STRING
-- contains a DER encoding of a value
-- of the type registered for use with
-- the extnId object identifier value
}
This interface is designed to provide access to a single extension,
unlike X509Extension
which is more suitable
for accessing a set of extensions.
Summary
Public methods |
abstract
void
|
encode(OutputStream out)
Generates the extension's DER encoding and writes it to the output
stream.
|
abstract
String
|
getId()
Gets the extensions's object identifier.
|
abstract
byte[]
|
getValue()
Gets the extensions's DER-encoded value.
|
abstract
boolean
|
isCritical()
Gets the extension's criticality setting.
|
Public methods
encode
public abstract void encode (OutputStream out)
Generates the extension's DER encoding and writes it to the output
stream.
Parameters |
out |
OutputStream : the output stream |
getId
public abstract String getId ()
Gets the extensions's object identifier.
Returns |
String |
the object identifier as a String |
getValue
public abstract byte[] getValue ()
Gets the extensions's DER-encoded value. Note, this is the bytes
that are encoded as an OCTET STRING. It does not include the OCTET
STRING tag and length.
Returns |
byte[] |
a copy of the extension's value, or null if no
extension value is present. |
isCritical
public abstract boolean isCritical ()
Gets the extension's criticality setting.
Returns |
boolean |
true if this is a critical extension. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Extension\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nExtension\n=========\n\n\n`\npublic\n\n\ninterface\nExtension\n`\n\n\n`\n\n\n`\n\n|------------------------------|\n| java.security.cert.Extension |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis interface represents an X.509 extension.\n\n\nExtensions provide a means of associating additional attributes with users\nor public keys and for managing a certification hierarchy. The extension\nformat also allows communities to define private extensions to carry\ninformation unique to those communities.\n\n\nEach extension contains an object identifier, a criticality setting\nindicating whether it is a critical or a non-critical extension, and\nand an ASN.1 DER-encoded value. Its ASN.1 definition is:\n\n```\n\n Extension ::= SEQUENCE {\n extnId OBJECT IDENTIFIER,\n critical BOOLEAN DEFAULT FALSE,\n extnValue OCTET STRING\n -- contains a DER encoding of a value\n -- of the type registered for use with\n -- the extnId object identifier value\n }\n\n \n```\n\n\nThis interface is designed to provide access to a single extension,\nunlike [X509Extension](/reference/java/security/cert/X509Extension) which is more suitable\nfor accessing a set of extensions.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[encode](/reference/java/security/cert/Extension#encode(java.io.OutputStream))`(`[OutputStream](/reference/java/io/OutputStream)` out) ` Generates the extension's DER encoding and writes it to the output stream. |\n| ` abstract `[String](/reference/java/lang/String) | ` `[getId](/reference/java/security/cert/Extension#getId())`() ` Gets the extensions's object identifier. |\n| ` abstract byte[]` | ` `[getValue](/reference/java/security/cert/Extension#getValue())`() ` Gets the extensions's DER-encoded value. |\n| ` abstract boolean` | ` `[isCritical](/reference/java/security/cert/Extension#isCritical())`() ` Gets the extension's criticality setting. |\n\nPublic methods\n--------------\n\n### encode\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void encode (OutputStream out)\n```\n\nGenerates the extension's DER encoding and writes it to the output\nstream.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------|------------------------------------------|\n| `out` | `OutputStream`: the output stream \u003cbr /\u003e |\n\n| Throws ||\n|-------------------------------------------------------------------|------------------------------|\n| [IOException](/reference/java/io/IOException) | on encoding or output error. |\n| [NullPointerException](/reference/java/lang/NullPointerException) | if `out` is `null`. |\n\n### getId\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract String getId ()\n```\n\nGets the extensions's object identifier.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|------------------------------------------|\n| [String](/reference/java/lang/String) | the object identifier as a String \u003cbr /\u003e |\n\n### getValue\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract byte[] getValue ()\n```\n\nGets the extensions's DER-encoded value. Note, this is the bytes\nthat are encoded as an OCTET STRING. It does not include the OCTET\nSTRING tag and length.\n\n\u003cbr /\u003e\n\n| Returns ||\n|----------|-------------------------------------------------------------------------------------|\n| `byte[]` | a copy of the extension's value, or `null` if no extension value is present. \u003cbr /\u003e |\n\n### isCritical\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean isCritical ()\n```\n\nGets the extension's criticality setting.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|----------------------------------------------|\n| `boolean` | true if this is a critical extension. \u003cbr /\u003e |"]]