Stay organized with collections
Save and categorize content based on your preferences.
Extension
interface 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 java.security.cert.X509Extension
which is more suitable for accessing a set of extensions.
Summary
Public methods |
abstract Unit |
Generates the extension's DER encoding and writes it to the output stream.
|
abstract String! |
Gets the extensions's object identifier.
|
abstract ByteArray! |
Gets the extensions's DER-encoded value.
|
abstract Boolean |
Gets the extension's criticality setting.
|
Public methods
encode
abstract fun encode(out: OutputStream!): Unit
Generates the extension's DER encoding and writes it to the output stream.
Exceptions |
java.io.IOException |
on encoding or output error. |
java.lang.NullPointerException |
if out is null . |
getId
abstract fun getId(): String!
Gets the extensions's object identifier.
Return |
String! |
the object identifier as a String |
getValue
abstract fun getValue(): ByteArray!
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.
Return |
ByteArray! |
a copy of the extension's value, or null if no extension value is present. |
isCritical
abstract fun isCritical(): Boolean
Gets the extension's criticality setting.
Return |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Extension\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nExtension\n=========\n\n```\ninterface Extension\n```\n\n|-----------------------------------|\n| [java.security.cert.Extension](#) |\n\nThis interface represents an X.509 extension.\n\nExtensions 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.\n\nEach 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: \n\n```kotlin\nExtension ::= 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\nThis interface is designed to provide access to a single extension, unlike [java.security.cert.X509Extension](/reference/kotlin/java/security/cert/X509Extension) which is more suitable for accessing a set of extensions.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [encode](#encode(java.io.OutputStream))`(`out:` `[OutputStream](../../io/OutputStream.html#)!`)` Generates the extension's DER encoding and writes it to the output stream. |\n| abstract [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getId](#getId())`()` Gets the extensions's object identifier. |\n| abstract [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)! | [getValue](#getValue())`()` Gets the extensions's DER-encoded value. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isCritical](#isCritical())`()` Gets the extension's criticality setting. |\n\nPublic methods\n--------------\n\n### encode\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun encode(out: OutputStream!): Unit\n```\n\nGenerates the extension's DER encoding and writes it to the output stream.\n\n| Parameters ||\n|-------|-----------------------------------------------------------------|\n| `out` | [OutputStream](../../io/OutputStream.html#)!: the output stream |\n\n| Exceptions ||\n|----------------------------------|------------------------------|\n| `java.io.IOException` | on encoding or output error. |\n| `java.lang.NullPointerException` | if `out` is `null`. |\n\n### getId\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun getId(): String!\n```\n\nGets the extensions's object identifier.\n\n| Return ||\n|-----------------------------------------------------------------------------------|-----------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | the object identifier as a String |\n\n### getValue\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun getValue(): ByteArray!\n```\n\nGets 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.\n\n| Return ||\n|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|\n| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)! | a copy of the extension's value, or `null` if no extension value is present. |\n\n### isCritical\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun isCritical(): Boolean\n```\n\nGets the extension's criticality setting.\n\n| Return ||\n|------------------------------------------------------------------------------------|---------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if this is a critical extension. |"]]