Stay organized with collections
Save and categorize content based on your preferences.
SNIMatcher
abstract class SNIMatcher
Instances of this class represent a matcher that performs match operations on an SNIServerName
instance.
Servers can use Server Name Indication (SNI) information to decide if specific SSLSocket
or SSLEngine
instances should accept a connection. For example, when multiple "virtual" or "name-based" servers are hosted on a single underlying network address, the server application can use SNI information to determine whether this server is the exact server that the client wants to access. Instances of this class can be used by a server to verify the acceptable server names of a particular type, such as host names.
SNIMatcher
objects are immutable. Subclasses should not provide methods that can change the state of an instance once it has been created.
Summary
Protected constructors |
Creates an SNIMatcher using the specified server name type.
|
Public methods |
Int |
Returns the server name type of this SNIMatcher object.
|
abstract Boolean |
Attempts to match the given SNIServerName .
|
Protected constructors
SNIMatcher
protected SNIMatcher(type: Int)
Creates an SNIMatcher
using the specified server name type.
Parameters |
type |
Int: the type of the server name that this matcher performs on |
Exceptions |
java.lang.IllegalArgumentException |
if type is not in the range of 0 to 255, inclusive. |
Public methods
getType
fun getType(): Int
Returns the server name type of this SNIMatcher
object.
Return |
Int |
the server name type of this SNIMatcher object. |
matches
abstract fun matches(serverName: SNIServerName!): Boolean
Attempts to match the given SNIServerName
.
Return |
Boolean |
true if, and only if, the matcher matches the given serverName |
Exceptions |
java.lang.NullPointerException |
if serverName is null |
java.lang.IllegalArgumentException |
if serverName is not of the given server name type of this matcher |
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,["# SNIMatcher\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSNIMatcher\n==========\n\n```\nabstract class SNIMatcher\n```\n\n|---|-------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [javax.net.ssl.SNIMatcher](#) |\n\nInstances of this class represent a matcher that performs match operations on an [SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName) instance.\n\nServers can use Server Name Indication (SNI) information to decide if specific [SSLSocket](/reference/kotlin/javax/net/ssl/SSLSocket) or [SSLEngine](/reference/kotlin/javax/net/ssl/SSLEngine) instances should accept a connection. For example, when multiple \"virtual\" or \"name-based\" servers are hosted on a single underlying network address, the server application can use SNI information to determine whether this server is the exact server that the client wants to access. Instances of this class can be used by a server to verify the acceptable server names of a particular type, such as host names.\n\n`SNIMatcher` objects are immutable. Subclasses should not provide methods that can change the state of an instance once it has been created.\n\nSummary\n-------\n\n| Protected constructors ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [SNIMatcher](#SNIMatcher(kotlin.Int))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Creates an `SNIMatcher` using the specified server name type. |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getType](#getType())`()` Returns the server name type of this `SNIMatcher` object. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [matches](#matches(javax.net.ssl.SNIServerName))`(`serverName:` `[SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName)!`)` Attempts to match the given [SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName). |\n\nProtected constructors\n----------------------\n\n### SNIMatcher\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nprotected SNIMatcher(type: Int)\n```\n\nCreates an `SNIMatcher` using the specified server name type.\n\n| Parameters ||\n|--------|---------------------------------------------------------------------------------------------------------------------------------------|\n| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the type of the server name that this matcher performs on |\n\n| Exceptions ||\n|--------------------------------------|-------------------------------------------------------|\n| `java.lang.IllegalArgumentException` | if `type` is not in the range of 0 to 255, inclusive. |\n\nPublic methods\n--------------\n\n### getType\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getType(): Int\n```\n\nReturns the server name type of this `SNIMatcher` object.\n\n| Return ||\n|----------------------------------------------------------------------------|---------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the server name type of this `SNIMatcher` object. |\n\n**See Also**\n\n- [javax.net.ssl.SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName) \n\n### matches\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun matches(serverName: SNIServerName!): Boolean\n```\n\nAttempts to match the given [SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName).\n\n| Parameters ||\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `serverName` | [SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName)!: the [SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName) instance on which this matcher performs match operations |\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if, and only if, the matcher matches the given `serverName` |\n\n| Exceptions ||\n|--------------------------------------|----------------------------------------------------------------------|\n| `java.lang.NullPointerException` | if `serverName` is `null` |\n| `java.lang.IllegalArgumentException` | if `serverName` is not of the given server name type of this matcher |\n\n**See Also**\n\n- [javax.net.ssl.SNIServerName](/reference/kotlin/javax/net/ssl/SNIServerName)"]]