Best code examples for Java 8 HostnameVerifier class (javax.net.ssl.HostnameVerifier)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 HostnameVerifier class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 HostnameVerifier examples from Open Source projects
This code example shows how to use the following methods: verify
        + "uUrabmn+CxHF5gpy6g1Qs2IjVYWA5f7FROn/J+Ad8gJYc1azOWCLQqSyfpNRLSvY\n" 
        + "EriQFEV63XvkJ8JrG62b+2OT2lqT4OO07gSPetppdlSa8NBSKP6Aro9RIX1ZjUZQ\n" 
        + "SpQFCfo02NO0uNRDPUdJx2huycdNb+AXHaO7eXevDLJ+QnqImIzxWiY6zLOdzjjI\n" 
        + "VBMkLHmnP7SjGSQ3XA4ByrQOxfOUTyLyE7NuemhHppuQPxE=\n" 
        + "-----END CERTIFICATE-----\n"); 
    assertFalse(verifier.verify("foo.com", session));
    assertFalse(verifier.verify("a.foo.com", session));
    assertFalse(verifier.verify("bar.com", session));
    assertFalse(verifier.verify("a.bar.com", session));
    assertTrue(verifier.verify("\u82b1\u5b50.co.jp", session));
    assertFalse(verifier.verify("a.\u82b1\u5b50.co.jp", session));
  } 
 
  @Test public void verifyWilcardCn() throws Exception { 
    // CN=*.foo.com 
    SSLSession session = session(""
        + "-----BEGIN CERTIFICATE-----\n" 
        + "MIIESDCCAzCgAwIBAgIJAIz+EYMBU6aUMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD\n" 
        + "VQQGEwJDQTELMAkGA1UECBMCQkMxEjAQBgNVBAcTCVZhbmNvdXZlcjEWMBQGA1UE\n" 
        + "ChMNd3d3LmN1Y2JjLmNvbTEUMBIGA1UECxQLY29tbW9uc19zc2wxHTAbBgNVBAMU\n" 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: verify
        } 
        // TODO: Instead of reporting the name of the server we think we're connecting to, 
        // we should be reporting the bad name in the certificate.  Unfortunately this is buried 
        // in the verifier code and is not available in the verifier API, and extracting the 
        // CN & alts is beyond the scope of this patch. 
        if (!HOSTNAME_VERIFIER.verify(hostname, session)) {
            throw new SSLPeerUnverifiedException(
                    "Certificate hostname not useable for server: " + hostname);
        } 
    } 
 
    /** 
     * Set the socket timeout. 
     * @param timeoutMilliseconds the read timeout value if greater than {@code 0}, or 
     *            {@code 0} for an infinite timeout. 
     */ 
    @Override 
    public void setSoTimeout(int timeoutMilliseconds) throws SocketException {
        mSocket.setSoTimeout(timeoutMilliseconds);
    } 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: verify
        + "uUrabmn+CxHF5gpy6g1Qs2IjVYWA5f7FROn/J+Ad8gJYc1azOWCLQqSyfpNRLSvY\n" 
        + "EriQFEV63XvkJ8JrG62b+2OT2lqT4OO07gSPetppdlSa8NBSKP6Aro9RIX1ZjUZQ\n" 
        + "SpQFCfo02NO0uNRDPUdJx2huycdNb+AXHaO7eXevDLJ+QnqImIzxWiY6zLOdzjjI\n" 
        + "VBMkLHmnP7SjGSQ3XA4ByrQOxfOUTyLyE7NuemhHppuQPxE=\n" 
        + "-----END CERTIFICATE-----\n"); 
    assertFalse(verifier.verify("foo.com", session));
    assertFalse(verifier.verify("a.foo.com", session));
    assertFalse(verifier.verify("bar.com", session));
    assertFalse(verifier.verify("a.bar.com", session));
    assertTrue(verifier.verify("\u82b1\u5b50.co.jp", session));
    assertFalse(verifier.verify("a.\u82b1\u5b50.co.jp", session));
  } 
 
  @Test public void verifyWilcardCn() throws Exception { 
    // CN=*.foo.com 
    SSLSession session = session(""
        + "-----BEGIN CERTIFICATE-----\n" 
        + "MIIESDCCAzCgAwIBAgIJAIz+EYMBU6aUMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD\n" 
        + "VQQGEwJDQTELMAkGA1UECBMCQkMxEjAQBgNVBAcTCVZhbmNvdXZlcjEWMBQGA1UE\n" 
        + "ChMNd3d3LmN1Y2JjLmNvbTEUMBIGA1UECxQLY29tbW9uc19zc2wxHTAbBgNVBAMU\n" 
Full Snippet Info
5
CodeRank
Related Java 8 HostnameVerifier Questions & Answers:
See Code Examples for Java 8 HostnameVerifier Methods: