Java 8 HostnameVerifier - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 HostnameVerifier class.

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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
        + "hbV+rgRQqHIJd50216OWQJbU3BvdlPbca779NYO4+UZWTFdBM8BdQqs3H4B5Agvp\n" 
        + "y7HeSff1F7XRAgMBAAGjHzAdMBsGA1UdEQQUMBKCB2Jhci5jb22CB2Jhei5jb20w\n" 
        + "DQYJKoZIhvcNAQEFBQADQQBXpZZPOY2Dy1lGG81JTr8L4or9jpKacD7n51eS8iqI\n" 
        + "oTznPNuXHU5bFN0AAGX2ij47f/EahqTpo5RdS95P4sVm\n" 
        + "-----END CERTIFICATE-----"); 
    assertFalse(verifier.verify("foo.com", session));
    assertTrue(verifier.verify("bar.com", session));
    assertTrue(verifier.verify("baz.com", session));
    assertFalse(verifier.verify("a.foo.com", session));
    assertFalse(verifier.verify("quux.com", session));
  } 
 
  @Test public void subjectAltNameWithWildcard() throws Exception { 
    // $ cat ./cert.cnf 
    // [req] 
    // distinguished_name=distinguished_name 
    // req_extensions=req_extensions 
    // x509_extensions=x509_extensions 
    // [distinguished_name] 
    // [req_extensions] 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
 
        sslsock.connect(remoteAddress, connTimeout);
 
        sslsock.setSoTimeout(soTimeout);
        try { 
            hostnameVerifier.verify(host, sslsock);
            // verifyHostName() didn't blowup - good! 
        } catch (IOException iox) {
            // close the socket before re-throwing the exception 
            try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
            throw iox;
        } 
 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
                    + remoteAddress.getAddress() + " timed out");
        } 
        sslsock.setSoTimeout(soTimeout);
        if (this.hostnameVerifier != null) {
            try { 
                this.hostnameVerifier.verify(remoteAddress.getHostName(), sslsock);
                // verifyHostName() didn't blowup - good! 
            } catch (IOException iox) {
                // close the socket before re-throwing the exception 
                try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
                throw iox;
            } 
        } 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
                    + remoteAddress.getAddress() + " timed out");
        } 
        sslsock.setSoTimeout(soTimeout);
        if (this.hostnameVerifier != null) {
            try { 
                this.hostnameVerifier.verify(remoteAddress.getHostName(), sslsock);
                // verifyHostName() didn't blowup - good! 
            } catch (IOException iox) {
                // close the socket before re-throwing the exception 
                try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
                throw iox;
            } 
        } 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
        } catch (SocketTimeoutException ex) {
            throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
        } 
        sslsock.setSoTimeout(soTimeout);
        try { 
            hostnameVerifier.verify(host, sslsock);
            // verifyHostName() didn't blowup - good! 
        } catch (IOException iox) {
            // close the socket before re-throwing the exception 
            try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
            throw iox;
        } 
 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
 
        sslsock.connect(remoteAddress, connTimeout);
 
        sslsock.setSoTimeout(soTimeout);
        try { 
            hostnameVerifier.verify(host, sslsock);
            // verifyHostName() didn't blowup - good! 
        } catch (IOException iox) {
            // close the socket before re-throwing the exception 
            try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
            throw iox;
        } 
 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
         
        sslsock.connect(remoteAddress, connTimeout);
 
        sslsock.setSoTimeout(soTimeout);
        try { 
            hostnameVerifier.verify(host, sslsock);
            // verifyHostName() didn't blowup - good! 
        } catch (IOException iox) {
            // close the socket before re-throwing the exception 
            try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
            throw iox;
        } 
 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
3
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: verify
         
        sslsock.connect(remoteAddress, connTimeout);
 
        sslsock.setSoTimeout(soTimeout);
        try { 
            hostnameVerifier.verify(host, sslsock);
            // verifyHostName() didn't blowup - good! 
        } catch (IOException iox) {
            // close the socket before re-throwing the exception 
            try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
            throw iox;
        } 
 
        return sslsock;
    } 
 
 
    /** 
     * Checks whether a socket connection is secure. 
     * This factory creates TLS/SSL socket connections 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 HostnameVerifier Questions & Answers:

See Code Examples for Java 8 HostnameVerifier Methods: