{@link Beta} <br>
Returns a verifier that trusts all host names.

<p>Be careful! Disabling host name verification is dangerous and should only be done in testing
environments.
338406
@Beta
  public static HostnameVerifier trustAllHostnameVerifier() {
    return new HostnameVerifier() {

      public boolean verify(String arg0, SSLSession arg1) {
        return true;
      }
    };
  }
1368495
private static String stripHostname(final String originalHostname) {

		// Check if the hostname domains the domain separator character
		final int index = originalHostname.indexOf(DOMAIN_SEPARATOR);
		if (index == -1) {
			return originalHostname;
		}

		// Make sure we are not stripping an IPv4 address
		final Matcher matcher = IPV4_PATTERN.matcher(originalHostname);
		if (matcher.matches()) {
			return originalHostname;
		}

		if (index == 0) {
			throw new IllegalStateException("Hostname " + originalHostname + " starts with a " + DOMAIN_SEPARATOR);
		}

		return originalHostname.substring(0, index);
	}
727489
public static X509HostnameVerifier adapt(HostnameVerifier verifier) {
    if (verifier == null) {
      throw new NullPointerException("verifier:null");
    }

    if (verifier instanceof X509HostnameVerifier) {
      return (X509HostnameVerifier) verifier;
    }

    return new X509HostnameVerifierAdapter(verifier);
  }
1101574
static void ensureHostnamePatternMatchesDefaultHostname(String hostnamePattern, String defaultHostname) {
        if ("*".equals(hostnamePattern)) {
            return;
        }

        // Pretty convoluted way to validate but it's done only once and
        // we don't need to duplicate the pattern matching logic.
        final DomainNameMapping<Boolean> mapping =
                new DomainNameMappingBuilder<>(Boolean.FALSE).add(hostnamePattern, Boolean.TRUE).build();

        if (!mapping.map(defaultHostname)) {
            throw new IllegalArgumentException(
                    "defaultHostname: " + defaultHostname +
                    " (must be matched by hostnamePattern: " + hostnamePattern + ')');
        }
    }
1281249
def is_valid_hostname(hostname):
    ''''''
    if not isinstance(hostname, str):
        raise TypeError('hostname must be a string')
    # strip exactly one dot from the right, if present
    if hostname and hostname[-1] == ".":
        hostname = hostname[:-1]
    if not hostname or len(hostname) > 253:
        return False
    labels = hostname.split('.')
    # the TLD must be not all-numeric
    if re.match(NUMERIC_REGEX, labels[-1]):
        return False
    return all(LABEL_REGEX.match(label) for label in labels)
99539
def valid_hostnames(hostname_list):
    
    for entry in hostname_list:
        if len(entry) > 255:
            return False
        allowed = re.compile('(?!-)[A-Z\d-]{1,63}(?<!-)$', re.IGNORECASE)
        if not all(allowed.match(x) for x in entry.split(".")):
            return False
    return True
74725
def valid_hostname(host):
    
    if len(host) > 255:
        return False

    if host[-1:] == '.':
        host = host[:-1]

    return all(_hostname_re.match(c) for c in host.split('.'))
37514
static boolean isInvalidLocalHost(String host) {
        return StringUtils.isBlank(host)
            || isAnyHost(host)
            || isLocalHost(host);
    }
74933
public java.lang.String getHost() {
    java.lang.Object ref = host_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (bs.isValidUtf8()) {
        host_ = s;
      }
      return s;
    }
  }
754344
@Beta
  public static SSLContext trustAllSSLContext() throws GeneralSecurityException {
    TrustManager[] trustAllCerts =
        new TrustManager[] {
          new X509TrustManager() {

            public void checkClientTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

            public void checkServerTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

            public X509Certificate[] getAcceptedIssuers() {
              return null;
            }
          }
        };
    SSLContext context = getTlsSslContext();
    context.init(null, trustAllCerts, null);
    return context;
  }
273223
private boolean isValidEndpoint(String endpoint) {
    if (InetAddressValidator.getInstance().isValid(endpoint)) {
      return true;
    }

    // endpoint may be a hostname
    // refer https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
    // why checks are done like below
    if (endpoint.length() < 1 || endpoint.length() > 253) {
      return false;
    }

    for (String label : endpoint.split("\\.")) {
      if (label.length() < 1 || label.length() > 63) {
        return false;
      }

      if (!(label.matches("^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$"))) {
        return false;
      }
    }

    return true;
  }
1280424
static boolean isValidHostNameForSNI(String hostname) {
        return hostname != null &&
               hostname.indexOf('.') > 0 &&
               !hostname.endsWith(".") &&
               !NetUtil.isValidIpV4Address(hostname) &&
               !NetUtil.isValidIpV6Address(hostname);
    }
1093055
public KieServerHttpRequest trustAllHosts() {
        final HttpURLConnection connection = getConnection();
        if( connection instanceof HttpsURLConnection )
            ((HttpsURLConnection) connection).setHostnameVerifier(getTrustedVerifier());
        return this;
    }
650448
public static boolean isIpv4(String hostName) {
		int periodCount = 0;
		int numberCount = 0;
		int lowerCount = 0;
		int upperCount = 0;
		int otherCount = 0;
		
		for(int i = 0; i < hostName.length(); i++ ) {
			char myChar = hostName.charAt(i);
			if (myChar=='.') {
				periodCount++;
			} else if (myChar >= '0' && myChar <= '9') {
				numberCount++;
			} else if (myChar >= 'a' & myChar <= 'z') {
				lowerCount++;
			} else if (myChar >= 'A' & myChar <= 'Z') {
				upperCount++;
			} else {
				otherCount++;
			}
		}
		
		if (periodCount==3 && numberCount >= 4 && lowerCount==0 && upperCount==0 && otherCount==0) {
			return true;
		} else {
			return false;
		}
	}
470857
@Override
	public boolean validate(final Problems problems, final String compName, final String model) {
		try {
			final URL url = new URL(model);
			// java.net.url does not require US-ASCII host names,
			// but the spec does
			final String host = url.getHost();
			if (!"".equals(host)) { // NOI18N
				return new ValidHostNameOrIPValidator(true).validate(problems, compName, host);
			}
			final String protocol = url.getProtocol();
			if ("mailto".equals(protocol)) { // NOI18N
				String emailAddress = url.toString().substring("mailto:".length()); // NOI18N
				emailAddress = emailAddress == null ? "" : emailAddress;
				return new EmailAddressValidator().validate(problems, compName, emailAddress);
			}
			return true;
		} catch (final MalformedURLException e) {
			final String problem = ValidationBundle.getMessage(UrlValidator.class, "URL_NOT_VALID", model); // NOI18N
			problems.add(problem);
			return false;
		}
	}
1186034
@Trivial
    public static boolean validLocalHostName(String hostName) {
        InetAddress addr = findLocalHostAddress(hostName, PREFER_IPV6);
        return addr != null;
    }
906698
private boolean verifyHostname(String hostname, X509Certificate certificate) {
        hostname = hostname.toLowerCase(Locale.US);
        boolean hasDns = false;
        List<String> altNames = getSubjectAltNames(certificate, ALT_DNS_NAME);
        for (int i = 0, size = altNames.size(); i < size; i++) {
            hasDns = true;
            if (verifyHostname(hostname, altNames.get(i))) {
                return true;
            }
        }

        if (!hasDns) {
            X500Principal principal = certificate.getSubjectX500Principal();
            // RFC 2818 advises using the most specific name for matching.
            String cn = new DistinguishedNameParser(principal).findMostSpecific("cn");
            if (cn != null) {
                return verifyHostname(hostname, cn);
            }
            else {
                // NOTE: In case of empty Common Name (CN), not checking
                return true;
            }
        }

        return false;
    }