Code example for HostnameVerifier

Methods: verify

0
        + "YdYLSFr/OEgSumtwqtZKJTB4wqTW/eKbBCEzxnyUMxWZIqUGu353PzwfOuWp2re3\n" 
        + "nvVV+QDYQlh9AgMBAAGjITAfMB0GA1UdEQQWMBSCB2Jhci5jb22CCSouYmF6LmNv\n" 
        + "bTANBgkqhkiG9w0BAQUFAANBAB8yrSl8zqy07i0SNYx2B/FnvQY734pxioaqFWfO\n" 
        + "Bqo1ZZl/9aPHEWIwBrxYNVB0SGu/kkbt/vxqOjzzrkXukmI=\n" 
        + "-----END CERTIFICATE-----"); 
    assertFalse(verifier.verify("foo.com", session));
    assertTrue(verifier.verify("bar.com", session));
    assertTrue(verifier.verify("a.baz.com", session));
    assertTrue(verifier.verify("baz.com", session));
    assertFalse(verifier.verify("a.foo.com", session));
    assertFalse(verifier.verify("a.bar.com", session));
    assertFalse(verifier.verify("quux.com", session));
  } 
 
  @Test public void verifyAsIpAddress() { 
    // IPv4 
    assertTrue(OkHostnameVerifier.verifyAsIpAddress("127.0.0.1")); 
    assertTrue(OkHostnameVerifier.verifyAsIpAddress("1.2.3.4")); 
 
    // IPv6 
    assertTrue(OkHostnameVerifier.verifyAsIpAddress("::1"));