public final class SNIHostName
extends SNIServerName
| java.lang.Object | ||
| javax.net.ssl.SNIServerName | ||
| javax.net.ssl.SNIHostName | ||
此类的实例表示服务器名称指示(SNI)扩展中的类型为 host_name的服务器名称。
如第3节“服务器名称指示”( TLS Extensions (RFC 6066))中所述 ,“HostName”包含服务器的完全限定DNS主机名,正如客户所理解的。 主机名的编码服务器名称值使用ASCII编码表示为一个字节字符串,不带尾点。 这允许通过使用RFC 5890中定义的A标签(适用于应用的国际化域名(IDNA)的有效字符串的ASCII兼容编码(ACE)格式)来支持国际化域名(IDN)。
请注意, SNIHostName对象是不可变的。
也可以看看:
Public constructors |
|
|---|---|
SNIHostName(String hostname) 使用指定的主机名创建 |
|
SNIHostName(byte[] encoded) 使用指定的编码值创建 |
|
公共方法(Public methods) |
|
|---|---|
static SNIMatcher |
createSNIMatcher(String regex) 为 |
boolean |
equals(Object other) 将此服务器名称与指定的对象进行比较。 |
String |
getAsciiName() 返回此 |
int |
hashCode() 返回此 |
String |
toString() 返回对象的字符串表示形式,包括此 |
继承方法(Inherited methods) |
|
|---|---|
javax.net.ssl.SNIServerName
|
|
java.lang.Object
|
|
SNIHostName (String hostname)
使用指定的主机名创建一个 SNIHostName 。
请注意,根据RFC 6066 ,主机名的编码服务器名称值为US_ASCII 。 在这种方法中, hostname可以是一个用户友好的国际化域名(IDN)。 toASCII(String, int)被用于强制ASCII字符中的主机名(见限制RFC 3490 , RFC 1122 , RFC 1123 )并翻译hostname成ASCII兼容性编码(ACE),为:
IDN.toASCII(hostname, IDN.USE_STD3_ASCII_RULES);
hostname参数是非法的,如果它:
hostname is empty,hostname ends with a trailing dot,hostname is not a valid Internationalized Domain Name (IDN) compliant with the RFC 3490 specification.| 参数(Parameters) | |
|---|---|
hostname |
String: the hostname of this server name |
| 抛出异常(Throws) | |
|---|---|
NullPointerException |
if hostname is null |
IllegalArgumentException |
if hostname is illegal |
SNIHostName (byte[] encoded)
使用指定的编码值创建一个 SNIHostName 。
此方法通常用于解析所请求的SNI扩展中的编码名称值。
根据RFC 6066 ,主机名的编码名称值为US_ASCII 。 但是,在以前版本的SNI扩展( RFC 4366 )中,编码的主机名表示为使用UTF-8编码的字节字符串。 出于版本容差的目的,此方法允许encoded参数的字符集可以是UTF_8以及US_ASCII 。 toASCII(String)用于将encoded参数转换为ASCII Compatible Encoding(ACE)主机名。
强烈建议此构造函数仅用于解析所请求的SNI扩展中的编码名称值。 否则,遵守RFC 6066 ,请始终使用US_ASCII兼容的字符集,并强制执行主机名上ASCII字符的限制(见RFC 3490 , RFC 1122 , RFC 1123 )为encoded的说法,或者使用SNIHostName(String)代替。
如果它: encoded参数是非法的:
encoded is empty,encoded ends with a trailing dot,encoded is not encoded in US_ASCII or UTF_8-compliant charset,encoded is not a valid Internationalized Domain Name (IDN) compliant with the RFC 3490 specification.请注意,克隆了 encoded字节数组以防止后续修改。
| 参数(Parameters) | |
|---|---|
encoded |
byte: the encoded hostname of this server name |
| 抛出异常(Throws) | |
|---|---|
NullPointerException |
if encoded is null |
IllegalArgumentException |
if encoded is illegal |
SNIMatcher createSNIMatcher (String regex)
为 SNIHostName创建一个 SNIMatcher对象。
服务器可以使用此方法来验证可接受的SNIHostName 。 例如,
SNIMatcher matcher =
SNIHostName.createSNIMatcher("www\\.example\\.com");
will accept the hostname "www.example.com".
SNIMatcher matcher =
SNIHostName.createSNIMatcher("www\\.example\\.(com|org)");
will accept hostnames "www.example.com" and "www.example.org".
| 参数(Parameters) | |
|---|---|
regex |
String: the regular expression pattern representing the hostname(s) to match |
| 返回(Returns) | |
|---|---|
SNIMatcher |
a SNIMatcher object for SNIHostNames |
| 抛出异常(Throws) | |
|---|---|
NullPointerException |
if regex is null |
PatternSyntaxException |
if the regular expression's syntax is invalid |
boolean equals (Object other)
将此服务器名称与指定的对象进行比较。
根据RFC 6066 ,DNS主机名不区分大小写。 如果且仅当它们具有相同的名称类型时,两个服务器主机名相同,并且在与案例无关的比较中主机名相同。
| 参数(Parameters) | |
|---|---|
other |
Object: the other server name object to compare with. |
| 返回(Returns) | |
|---|---|
boolean |
true if, and only if, the other is considered equal to this instance |
String getAsciiName ()
返回此 SNIHostName对象的 US_ASCII的主机名。
请注意,根据RFC 6066 ,返回的主机名可能是包含A标签的国际化域名。 有关详细的A标签规范的更多信息,请参阅RFC 5890 。
| 返回(Returns) | |
|---|---|
String |
the US_ASCII-compliant hostname of this SNIHostName object |
int hashCode ()
返回此 SNIHostName的哈希码值。
哈希码值是使用此 SNIHostName的不区分大小写的主机名 SNIHostName 。
| 返回(Returns) | |
|---|---|
int |
a hash code value for this SNIHostName. |
String toString ()
返回对象的字符串表示形式,包括此 SNIHostName对象中的DNS主机名。
该表示的确切细节未指定,可能会有变化,但以下内容可能被视为典型情况:
"type=host_name (0), value=<hostname>"The "<hostname>" is an ASCII representation of the hostname, which may contains A-labels. For example, a returned value of an pseudo hostname may look like:
"type=host_name (0), value=www.example.com"or
"type=host_name (0), value=xn--fsqu00a.xn--0zwm56d"
请注意,该表示的确切细节未指定,可能会有变动。
| 返回(Returns) | |
|---|---|
String |
a string representation of the object. |