okhttp3.internal.Util.verifyAsIpAddress()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(265)

本文整理了Java中okhttp3.internal.Util.verifyAsIpAddress()方法的一些代码示例,展示了Util.verifyAsIpAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.verifyAsIpAddress()方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:verifyAsIpAddress

Util.verifyAsIpAddress介绍

[英]Returns true if host is not a host name and might be an IP address.
[中]如果主机不是主机名并且可能是IP地址,则返回true。

代码示例

代码示例来源:origin: square/okhttp

private static boolean domainMatch(String urlHost, String domain) {
 if (urlHost.equals(domain)) {
  return true; // As in 'example.com' matching 'example.com'.
 }
 if (urlHost.endsWith(domain)
   && urlHost.charAt(urlHost.length() - domain.length() - 1) == '.'
   && !verifyAsIpAddress(urlHost)) {
  return true; // As in 'example.com' matching 'www.example.com'.
 }
 return false;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

private static boolean domainMatch(String urlHost, String domain) {
 if (urlHost.equals(domain)) {
  return true; // As in 'example.com' matching 'example.com'.
 }
 if (urlHost.endsWith(domain)
   && urlHost.charAt(urlHost.length() - domain.length() - 1) == '.'
   && !verifyAsIpAddress(urlHost)) {
  return true; // As in 'example.com' matching 'www.example.com'.
 }
 return false;
}

代码示例来源:origin: square/okhttp

public boolean verify(String host, X509Certificate certificate) {
 return verifyAsIpAddress(host)
   ? verifyIpAddress(host, certificate)
   : verifyHostname(host, certificate);
}

代码示例来源:origin: square/okhttp

/**
 * Returns the domain name of this URL's {@link #host()} that is one level beneath the public
 * suffix by consulting the <a href="https://publicsuffix.org">public suffix list</a>. Returns
 * null if this URL's {@link #host()} is an IP address or is considered a public suffix by the
 * public suffix list.
 *
 * <p>In general this method <strong>should not</strong> be used to test whether a domain is valid
 * or routable. Instead, DNS is the recommended source for that information.
 *
 * <p><table summary="">
 *   <tr><th>URL</th><th>{@code topPrivateDomain()}</th></tr>
 *   <tr><td>{@code http://google.com}</td><td>{@code "google.com"}</td></tr>
 *   <tr><td>{@code http://adwords.google.co.uk}</td><td>{@code "google.co.uk"}</td></tr>
 *   <tr><td>{@code http://square}</td><td>null</td></tr>
 *   <tr><td>{@code http://co.uk}</td><td>null</td></tr>
 *   <tr><td>{@code http://localhost}</td><td>null</td></tr>
 *   <tr><td>{@code http://127.0.0.1}</td><td>null</td></tr>
 * </table>
 */
public @Nullable String topPrivateDomain() {
 if (verifyAsIpAddress(host)) return null;
 return PublicSuffixDatabase.get().getEffectiveTldPlusOne(host);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

public boolean verify(String host, X509Certificate certificate) {
 return verifyAsIpAddress(host)
   ? verifyIpAddress(host, certificate)
   : verifyHostname(host, certificate);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
 * Returns the domain name of this URL's {@link #host()} that is one level beneath the public
 * suffix by consulting the <a href="https://publicsuffix.org">public suffix list</a>. Returns
 * null if this URL's {@link #host()} is an IP address or is considered a public suffix by the
 * public suffix list.
 *
 * <p>In general this method <strong>should not</strong> be used to test whether a domain is valid
 * or routable. Instead, DNS is the recommended source for that information.
 *
 * <p><table summary="">
 *   <tr><th>URL</th><th>{@code topPrivateDomain()}</th></tr>
 *   <tr><td>{@code http://google.com}</td><td>{@code "google.com"}</td></tr>
 *   <tr><td>{@code http://adwords.google.co.uk}</td><td>{@code "google.co.uk"}</td></tr>
 *   <tr><td>{@code http://square}</td><td>null</td></tr>
 *   <tr><td>{@code http://co.uk}</td><td>null</td></tr>
 *   <tr><td>{@code http://localhost}</td><td>null</td></tr>
 *   <tr><td>{@code http://127.0.0.1}</td><td>null</td></tr>
 * </table>
 */
public @Nullable String topPrivateDomain() {
 if (verifyAsIpAddress(host)) return null;
 return PublicSuffixDatabase.get().getEffectiveTldPlusOne(host);
}

代码示例来源:origin: square/okhttp

for (int i = 0, size = altNames.size(); i < size; i++) {
 String altName = altNames.get(i);
 int tag = verifyAsIpAddress(altName)
   ? GeneralName.iPAddress
   : GeneralName.dNSName;

代码示例来源:origin: apache/servicemix-bundles

private static boolean domainMatch(String urlHost, String domain) {
 if (urlHost.equals(domain)) {
  return true; // As in 'example.com' matching 'example.com'.
 }
 if (urlHost.endsWith(domain)
   && urlHost.charAt(urlHost.length() - domain.length() - 1) == '.'
   && !verifyAsIpAddress(urlHost)) {
  return true; // As in 'example.com' matching 'www.example.com'.
 }
 return false;
}

代码示例来源:origin: com.github.ljun20160606/okhttp

private static boolean domainMatch(String urlHost, String domain) {
 if (urlHost.equals(domain)) {
  return true; // As in 'example.com' matching 'example.com'.
 }
 if (urlHost.endsWith(domain)
   && urlHost.charAt(urlHost.length() - domain.length() - 1) == '.'
   && !verifyAsIpAddress(urlHost)) {
  return true; // As in 'example.com' matching 'www.example.com'.
 }
 return false;
}

代码示例来源:origin: duzechao/OKHttpUtils

private static boolean domainMatch(HttpUrl url, String domain) {
 String urlHost = url.host();
 if (urlHost.equals(domain)) {
  return true; // As in 'example.com' matching 'example.com'.
 }
 if (urlHost.endsWith(domain)
   && urlHost.charAt(urlHost.length() - domain.length() - 1) == '.'
   && !verifyAsIpAddress(urlHost)) {
  return true; // As in 'example.com' matching 'www.example.com'.
 }
 return false;
}

代码示例来源:origin: com.palantir.conjure.java.runtime/okhttp-clients

public boolean verify(String host, X509Certificate certificate) {
  return verifyAsIpAddress(host)
      ? verifyIpAddress(host, certificate)
      : verifyHostname(host, certificate);
}

代码示例来源:origin: duzechao/OKHttpUtils

public boolean verify(String host, X509Certificate certificate) {
 return verifyAsIpAddress(host)
   ? verifyIpAddress(host, certificate)
   : verifyHostName(host, certificate);
}

代码示例来源:origin: com.github.ljun20160606/okhttp

public boolean verify(String host, X509Certificate certificate) {
 return verifyAsIpAddress(host)
   ? verifyIpAddress(host, certificate)
   : verifyHostname(host, certificate);
}

代码示例来源:origin: apache/servicemix-bundles

public boolean verify(String host, X509Certificate certificate) {
 return verifyAsIpAddress(host)
   ? verifyIpAddress(host, certificate)
   : verifyHostname(host, certificate);
}

代码示例来源:origin: palantir/conjure-java-runtime

public boolean verify(String host, X509Certificate certificate) {
  return verifyAsIpAddress(host)
      ? verifyIpAddress(host, certificate)
      : verifyHostname(host, certificate);
}

代码示例来源:origin: com.github.ljun20160606/okhttp

/**
 * Returns the domain name of this URL's {@link #host()} that is one level beneath the public
 * suffix by consulting the <a href="https://publicsuffix.org">public suffix list</a>. Returns
 * null if this URL's {@link #host()} is an IP address or is considered a public suffix by the
 * public suffix list.
 *
 * <p>In general this method <strong>should not</strong> be used to test whether a domain is valid
 * or routable. Instead, DNS is the recommended source for that information.
 *
 * <p><table summary="">
 *   <tr><th>URL</th><th>{@code topPrivateDomain()}</th></tr>
 *   <tr><td>{@code http://google.com}</td><td>{@code "google.com"}</td></tr>
 *   <tr><td>{@code http://adwords.google.co.uk}</td><td>{@code "google.co.uk"}</td></tr>
 *   <tr><td>{@code http://square}</td><td>null</td></tr>
 *   <tr><td>{@code http://co.uk}</td><td>null</td></tr>
 *   <tr><td>{@code http://localhost}</td><td>null</td></tr>
 *   <tr><td>{@code http://127.0.0.1}</td><td>null</td></tr>
 * </table>
 */
public @Nullable String topPrivateDomain() {
 if (verifyAsIpAddress(host)) return null;
 return PublicSuffixDatabase.get().getEffectiveTldPlusOne(host);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Returns the domain name of this URL's {@link #host()} that is one level beneath the public
 * suffix by consulting the <a href="https://publicsuffix.org">public suffix list</a>. Returns
 * null if this URL's {@link #host()} is an IP address or is considered a public suffix by the
 * public suffix list.
 *
 * <p>In general this method <strong>should not</strong> be used to test whether a domain is valid
 * or routable. Instead, DNS is the recommended source for that information.
 *
 * <p><table summary="">
 *   <tr><th>URL</th><th>{@code topPrivateDomain()}</th></tr>
 *   <tr><td>{@code http://google.com}</td><td>{@code "google.com"}</td></tr>
 *   <tr><td>{@code http://adwords.google.co.uk}</td><td>{@code "google.co.uk"}</td></tr>
 *   <tr><td>{@code http://square}</td><td>null</td></tr>
 *   <tr><td>{@code http://co.uk}</td><td>null</td></tr>
 *   <tr><td>{@code http://localhost}</td><td>null</td></tr>
 *   <tr><td>{@code http://127.0.0.1}</td><td>null</td></tr>
 * </table>
 */
public @Nullable String topPrivateDomain() {
 if (verifyAsIpAddress(host)) return null;
 return PublicSuffixDatabase.get().getEffectiveTldPlusOne(host);
}

代码示例来源:origin: com.github.ljun20160606/mockwebserver

for (int i = 0, size = altNames.size(); i < size; i++) {
 String altName = altNames.get(i);
 int tag = verifyAsIpAddress(altName)
   ? GeneralName.iPAddress
   : GeneralName.dNSName;

代码示例来源:origin: com.squareup.okhttp3/okhttp-tls

for (int i = 0, size = altNames.size(); i < size; i++) {
 String altName = altNames.get(i);
 int tag = verifyAsIpAddress(altName)
   ? GeneralName.iPAddress
   : GeneralName.dNSName;

代码示例来源:origin: xjdr/xio

for (int i = 0, size = altNames.size(); i < size; i++) {
 String altName = altNames.get(i);
 int tag = verifyAsIpAddress(altName) ? GeneralName.iPAddress : GeneralName.dNSName;
 encodableAltNames[i] = new GeneralName(tag, altName);

相关文章