public final class SNIHostName extends SNIServerName
host_name的服务器名称。
如第3节“服务器名称指示”( TLS Extensions (RFC 6066))中所述 ,“HostName”包含服务器的完全限定的DNS主机名,如客户端所了解。 主机名的编码服务器名称值使用ASCII编码表示为字节串,而不带有后跟点。 这使得国际化域名(IDN)的支持下,经过中规定的使用A标签(国际化域名的应用程序(IDNA)的有效字符串的ASCII兼容编码(ACE)的形式) RFC 5890 。
请注意, SNIHostName对象是不可变的。
SNIServerName , StandardConstants.SNI_HOST_NAME
| Constructor and Description |
|---|
SNIHostName(byte[] encoded)
使用指定的编码值创建一个
SNIHostName 。
|
SNIHostName(String hostname)
使用指定的主机名创建一个
SNIHostName 。
|
| Modifier and Type | Method and Description |
|---|---|
static SNIMatcher |
createSNIMatcher(String regex)
为 SNIHostName创建一个SNIMatcher对象。
|
boolean |
equals(Object other)
将此服务器名称与指定对象进行比较。
|
String |
getAsciiName()
返回此
SNIHostName对象的
StandardCharsets.US_ASCII兼容主机名。
|
int |
hashCode()
返回此
SNIHostName的哈希码值。
|
String |
toString()
返回对象的字符串表示形式,包括此
SNIHostName对象中的DNS主机名。
|
getEncoded, getTypepublic SNIHostName(String hostname)
SNIHostName 。
需要注意的是每RFC 6066 ,主机名的编码服务器名称值是StandardCharsets.US_ASCII兼容。 在这种方法中, hostname可以是一个用户友好的国际化域名(IDN)。 IDN.toASCII(String, int)被用于强制ASCII字符中的主机名(见限制RFC 3490 , RFC 1122 , RFC 1123 )和翻译hostname成ASCII兼容性编码(ACE),为:
IDN.toASCII(hostname, IDN.USE_STD3_ASCII_RULES);
如果hostname参数是非法的:
hostname是空的, hostname以尾随点结尾, hostname不符合RFC 3490规范的有效国际化域名(IDN)。 hostname - 此服务器名称的主机名
NullPointerException - 如果
hostname是
null
IllegalArgumentException - 如果
hostname是非法的
public SNIHostName(byte[] encoded)
SNIHostName 。
该方法通常用于解析所请求的SNI扩展中的编码名称值。
根据RFC 6066 ,主机名的编码名称值为StandardCharsets.US_ASCII- compliant。 然而,在先前版本的SNI扩展( RFC 4366 )中,编码的主机名使用UTF-8编码表示为字节串。 为了版本容限,此方法允许encoded参数的字符集可以是StandardCharsets.UTF_8 ,以及StandardCharsets.US_ASCII 。 IDN.toASCII(String)用于将encoded参数转换为ASCII兼容编码(ACE)主机名。
强烈建议此构造函数仅用于解析所请求的SNI扩展中的编码名称值。 否则,遵守RFC 6066 ,请始终使用StandardCharsets.US_ASCII兼容的字符集,并强制执行主机名上ASCII字符的限制(见RFC 3490 , RFC 1122 , RFC 1123 )为encoded的说法,或者使用SNIHostName(String)代替。
如果encoded参数是非法的:
encoded是空的, encoded以尾随点结束, encoded未编码StandardCharsets.US_ASCII或StandardCharsets.UTF_8兼容字符集, encoded不符合RFC 3490规范的有效国际化域名(IDN)。 请注意, encoded字节数组被克隆以防止后续修改。
encoded - 此服务器名称的编码主机名
NullPointerException - 如果
encoded是
null
IllegalArgumentException - 如果
encoded是非法的
public String getAsciiName()
SNIHostName对象的StandardCharsets.US_ASCII兼容主机名。
请注意,根据RFC 6066 ,返回的主机名可能是包含A标签的国际化域名。 见RFC 5890有关详细A-标签规范的更多信息。
SNIHostName对象的
StandardCharsets.US_ASCII兼容主机名
public boolean equals(Object other)
根据RFC 6066 ,DNS主机名不区分大小写。 两个服务器主机名相等,如果且仅当它们具有相同的名称类型,并且主机名在与个别无关的比较中相等。
equals在
SNIServerName
other - 要与之进行比较的其他服务器名称对象。
other被认为等于这个实例,则为true
Object.hashCode() , HashMap
public int hashCode()
SNIHostName的哈希码值。
使用此SNIHostName的不区分大小写的主机名生成哈希码值。
hashCode在
SNIServerName
SNIHostName的哈希码值。
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)
public String toString()
SNIHostName对象中的DNS主机名。
表示的具体细节未经说明,可能有变更,但以下可能被视为典型:
"type=host_name (0), value= <hostname>"
“<hostname>”是主机名的ASCII表示,可能包含A标签。
例如,伪主机名的返回值可能如下所示:
"type=host_name (0), value=www.example.com"
要么
"type=host_name (0), value=xn--fsqu00a.xn--0zwm56d"
请注意,表示的确切细节未经说明,可能会有变动。
toString在
SNIServerName
public static SNIMatcher createSNIMatcher(String regex)
SNIHostName创建一个SNIMatcher对象。
这种方法可以由服务器使用来验证可接受的SNIHostName 。 例如,
SNIMatcher matcher =
SNIHostName.createSNIMatcher("www\\.example\\.com");
将接受主机名“www.example.com”。
SNIMatcher matcher =
SNIHostName.createSNIMatcher("www\\.example\\.(com|org)");
将接受主机名“www.example.com”和“www.example.org”。
regex -
regular expression pattern表示要匹配的主机名
SNIMatcher对象为
SNIHostName s
NullPointerException - 如果
regex是
null
PatternSyntaxException - if the regular expression's syntax is invalid
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.