Java 类javax.net.ssl.HostnameVerifier 实例源码

项目:GitHub    文件:Address.java   
public Address(String uriHost, int uriPort, Dns dns, SocketFactory socketFactory,
    @Nullable SSLSocketFactory sslSocketFactory, @Nullable HostnameVerifier hostnameVerifier,
    @Nullable CertificatePinner certificatePinner, Authenticator proxyAuthenticator,
    @Nullable Proxy proxy, List<Protocol> protocols, List<ConnectionSpec> connectionSpecs,
    ProxySelector proxySelector) {
  this.url = new HttpUrl.Builder()
      .scheme(sslSocketFactory != null ? "https" : "http")
      .host(uriHost)
      .port(uriPort)
      .build();

  if (dns == null) throw new NullPointerException("dns == null");
  this.dns = dns;

  if (socketFactory == null) throw new NullPointerException("socketFactory == null");
  this.socketFactory = socketFactory;

  if (proxyAuthenticator == null) {
    throw new NullPointerException("proxyAuthenticator == null");
  }
  this.proxyAuthenticator = proxyAuthenticator;

  if (protocols == null) throw new NullPointerException("protocols == null");
  this.protocols = Util.immutableList(protocols);

  if (connectionSpecs == null) throw new NullPointerException("connectionSpecs == null");
  this.connectionSpecs = Util.immutableList(connectionSpecs);

  if (proxySelector == null) throw new NullPointerException("proxySelector == null");
  this.proxySelector = proxySelector;

  this.proxy = proxy;
  this.sslSocketFactory = sslSocketFactory;
  this.hostnameVerifier = hostnameVerifier;
  this.certificatePinner = certificatePinner;
}
项目:RoughWorld    文件:WebClient.java   
public static void disableCertificateValidation() 
{
    // Create a trust manager that does not validate certificate chains
    TrustManager[] trustAllCerts = new TrustManager[] 
    { 
      new TrustAllManager() 
    };

    // Ignore differences between given hostname and certificate hostname
    HostnameVerifier hv = new TrustAllHostnameVerifier();

    // Install the all-trusting trust manager
    try 
    {
      SSLContext sc = SSLContext.getInstance("SSL");
      sc.init(null, trustAllCerts, new SecureRandom());
      HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
      HttpsURLConnection.setDefaultHostnameVerifier(hv);
    } catch (Exception e) {}
}
项目:calcite-avatica    文件:AvaticaCommonsHttpClientImpl.java   
/**
 * Creates the {@code HostnameVerifier} given the provided {@code verification}.
 *
 * @param verification The intended hostname verification action.
 * @return A verifier for the request verification.
 * @throws IllegalArgumentException if the provided verification cannot be handled.
 */
HostnameVerifier getHostnameVerifier(HostnameVerification verification) {
  // Normally, the configuration logic would give us a default of STRICT if it was not
  // provided by the user. It's easy for us to do a double-check.
  if (verification == null) {
    verification = HostnameVerification.STRICT;
  }
  switch (verification) {
  case STRICT:
    return SSLConnectionSocketFactory.getDefaultHostnameVerifier();
  case NONE:
    return NoopHostnameVerifier.INSTANCE;
  default:
    throw new IllegalArgumentException("Unhandled HostnameVerification: "
        + hostnameVerification);
  }
}
项目:boohee_v5.6    文件:HttpsTrustManager.java   
public static void allowAllSSL() {
    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
        public boolean verify(String arg0, SSLSession arg1) {
            return true;
        }
    });
    SSLContext context = null;
    if (trustManagers == null) {
        trustManagers = new TrustManager[]{new HttpsTrustManager()};
    }
    try {
        context = SSLContext.getInstance("TLS");
        context.init(null, trustManagers, new SecureRandom());
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (KeyManagementException e2) {
        e2.printStackTrace();
    }
    HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
}
项目:GitHub    文件:OkHttp.java   
@Override public void prepare(Benchmark benchmark) {
  super.prepare(benchmark);
  client = new OkHttpClient.Builder()
      .protocols(benchmark.protocols)
      .build();

  if (benchmark.tls) {
    SslClient sslClient = SslClient.localhost();
    SSLSocketFactory socketFactory = sslClient.socketFactory;
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
      @Override public boolean verify(String s, SSLSession session) {
        return true;
      }
    };
    client = new OkHttpClient.Builder()
        .sslSocketFactory(socketFactory, sslClient.trustManager)
        .hostnameVerifier(hostnameVerifier)
        .build();
  }
}
项目:hadoop-oss    文件:SSLFactory.java   
public static HostnameVerifier getHostnameVerifier(String verifier)
  throws GeneralSecurityException, IOException {
  HostnameVerifier hostnameVerifier;
  if (verifier.equals("DEFAULT")) {
    hostnameVerifier = SSLHostnameVerifier.DEFAULT;
  } else if (verifier.equals("DEFAULT_AND_LOCALHOST")) {
    hostnameVerifier = SSLHostnameVerifier.DEFAULT_AND_LOCALHOST;
  } else if (verifier.equals("STRICT")) {
    hostnameVerifier = SSLHostnameVerifier.STRICT;
  } else if (verifier.equals("STRICT_IE6")) {
    hostnameVerifier = SSLHostnameVerifier.STRICT_IE6;
  } else if (verifier.equals("ALLOW_ALL")) {
    hostnameVerifier = SSLHostnameVerifier.ALLOW_ALL;
  } else {
    throw new GeneralSecurityException("Invalid hostname verifier: " +
                                       verifier);
  }
  return hostnameVerifier;
}
项目:yyox    文件:OkHttpManager.java   
public static OkHttpManager getInstance() {
    if (sOkHttpManager == null) {
        synchronized (OkHttpManager.class) {
            if (sOkHttpManager == null) {
                sOkHttpManager = new OkHttpManager();
                sOkHttpClient = new OkHttpClient.Builder()
                        .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                        .connectTimeout(20, TimeUnit.SECONDS)
                        .readTimeout(20, TimeUnit.SECONDS)
                        .writeTimeout(20, TimeUnit.SECONDS)
                        .retryOnConnectionFailure(true)
                        .addNetworkInterceptor(new HttpInterceptor(SPUtils.getUserAgent()))
                        .hostnameVerifier(new HostnameVerifier() {
                            @Override
                            public boolean verify(String hostname, SSLSession session) {
                                return true;
                            }
                        })
                        .sslSocketFactory(TrustSSLContext.getSSLSocketFactory())

                        .build();
            }
        }
    }
    return sOkHttpManager;
}
项目:JRediClients    文件:JedisFactory.java   
public JedisFactory(final URI uri, final int connectionTimeout, final int soTimeout, final String clientName,
        final boolean ssl, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    if (!JedisURIHelper.isValid(uri)) {
        throw new InvalidURIException(
                String.format("Cannot open Redis connection due invalid URI. %s", uri.toString()));
    }

    this.hostAndPort.set(new HostAndPort(uri.getHost(), uri.getPort()));
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.password = JedisURIHelper.getPassword(uri);
    this.database = JedisURIHelper.getDBIndex(uri);
    this.clientName = clientName;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:calcite-avatica    文件:AvaticaCommonsHttpClientImplTest.java   
@Test public void testHostnameVerification() throws Exception {
  AvaticaCommonsHttpClientImpl client = mock(AvaticaCommonsHttpClientImpl.class);
  // Call the real method
  when(client.getHostnameVerifier(nullable(HostnameVerification.class)))
      .thenCallRealMethod();

  // No verification should give the default (strict) verifier
  HostnameVerifier actualVerifier = client.getHostnameVerifier(null);
  assertNotNull(actualVerifier);
  assertTrue(actualVerifier instanceof DefaultHostnameVerifier);

  actualVerifier = client.getHostnameVerifier(HostnameVerification.STRICT);
  assertNotNull(actualVerifier);
  assertTrue(actualVerifier instanceof DefaultHostnameVerifier);

  actualVerifier = client.getHostnameVerifier(HostnameVerification.NONE);
  assertNotNull(actualVerifier);
  assertTrue(actualVerifier instanceof NoopHostnameVerifier);
}
项目:AndroidModulePattern    文件:HttpsUtils.java   
/**
 * 主机名校验方法,请把”192.168.0.10”换成你们公司的主机IP:
 */
public static HostnameVerifier getHostnameVerifier() {
    return new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            if ("192.168.0.10".equals(hostname)) {
                return true;
            } else {
                HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
                return hv.verify(hostname, session);
            }
        }
    };
}
项目:ITSM    文件:GlideUtils.java   
public static synchronized OkHttpClient getOkHttpClient() {
  if (okHttpClient == null) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.connectTimeout(90, TimeUnit.SECONDS);
    builder.sslSocketFactory(createSSLSocketFactory());
    builder.hostnameVerifier(new HostnameVerifier() {
      @Override public boolean verify(String hostname, SSLSession session) {
        return true;
      }
    });
    if (BuildConfig.DEBUG) {
      // Log信息拦截器
      HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
      loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);//这里可以选择拦截级别

      //设置 Debug Log 模式
      builder.addInterceptor(loggingInterceptor);
    }
    okHttpClient = builder.build();
  }
  return okHttpClient;
}
项目:JRediClients    文件:JedisClusterInfoCache.java   
public JedisPool setupNodeIfNotExist(HostAndPort node, boolean ssl, SSLSocketFactory sslSocketFactory,
        SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    w.lock();
    try {
        String nodeKey = getNodeKey(node);
        JedisPool existingPool = nodes.get(nodeKey);
        if (existingPool != null)
            return existingPool;

        JedisPool nodePool = new JedisPool(poolConfig, node.getHost(), node.getPort(), connectionTimeout, soTimeout,
                password, 0, null, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
        nodes.put(nodeKey, nodePool);
        return nodePool;
    } finally {
        w.unlock();
    }
}
项目:JRediClients    文件:SSLJedisTest.java   
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifier() {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
项目:alexa-gira-bridge    文件:Util.java   
public static String triggerHttpGetWithCustomSSL(String requestUrl) {
    String result = null;
    try {
        SSLContextBuilder builder = new SSLContextBuilder();
        builder.loadTrustMaterial(null, new TrustSelfSignedStrategy() {
            public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                return true;
            }
        });
        @SuppressWarnings("deprecation")
        HostnameVerifier hostnameVerifier = SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;

        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), hostnameVerifier);

        CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();

        HttpGet httpGet = new HttpGet("https://" + requestUrl);
        CloseableHttpResponse response = httpclient.execute(httpGet);
        try {
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                HttpEntity entity = response.getEntity();
                result = EntityUtils.toString(entity);
                log.debug("Received response: " + result);
            } else {
                log.error("Request not successful. StatusCode was " + response.getStatusLine().getStatusCode());
            }
        } finally {
            response.close();
        }
    } catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
        log.error("Error executing the request.", e);
    }
    return result;
}
项目:JRediClients    文件:SSLJedisTest.java   
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier. This test should fail because "127.0.0.1" does not match the
 * certificate subject common name and there are no subject alternative names
 * in the certificate.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifierByIpAddress() {
  final URI uri = URI.create("rediss://127.0.0.1:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  try {
    jedis.get("foo");
    Assert.fail("The code did not throw the expected JedisConnectionException.");
  } catch (JedisConnectionException e) {
    Assert.assertEquals("The JedisConnectionException does not contain the expected message.",
        "The connection to '127.0.0.1' failed ssl/tls hostname verification.", e.getMessage());
  }

  try {
    jedis.close();
  } catch (Throwable e1) {
    // Expected.
  }
}
项目:aliyun-cloudphotos-android-demo    文件:SSLUtil.java   
/**
 * 忽略HTTPS请求的SSL证书,必须在openConnection之前调用
 * @throws Exception
 */
public static void ignoreSsl() throws Exception{
    HostnameVerifier hv = new HostnameVerifier() {
        public boolean verify(String urlHostName, SSLSession session) {
            return true;
        }
    };
    trustAllHttpsCertificates();
    HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
项目:LoRaWAN-Smart-Parking    文件:HttpEngine.java   
/** Connect to the origin server either directly or via a proxy. */
protected final void connect() throws IOException {
  if (connection != null) {
    return;
  }
  if (routeSelector == null) {
    String uriHost = uri.getHost();
    if (uriHost == null) {
      throw new UnknownHostException(uri.toString());
    }
    SSLSocketFactory sslSocketFactory = null;
    HostnameVerifier hostnameVerifier = null;
    if (uri.getScheme().equalsIgnoreCase("https")) {
      sslSocketFactory = client.getSslSocketFactory();
      hostnameVerifier = client.getHostnameVerifier();
    }
    Address address = new Address(uriHost, getEffectivePort(uri), sslSocketFactory,
        hostnameVerifier, client.getAuthenticator(), client.getProxy(), client.getTransports());
    routeSelector = new RouteSelector(address, uri, client.getProxySelector(),
        client.getConnectionPool(), Dns.DEFAULT, client.getRoutesDatabase());
  }
  connection = routeSelector.next(method);
  if (!connection.isConnected()) {
    connection.connect(client.getConnectTimeout(), client.getReadTimeout(), getTunnelConfig());
    client.getConnectionPool().maybeShare(connection);
    client.getRoutesDatabase().connected(connection.getRoute());
  } else if (!connection.isSpdy()) {
      connection.updateReadTimeout(client.getReadTimeout());
  }
  connected(connection);
  if (connection.getRoute().getProxy() != client.getProxy()) {
    // Update the request line if the proxy changed; it may need a host name.
    requestHeaders.getHeaders().setRequestLine(getRequestLine());
  }
}
项目:aws-sdk-java-v2    文件:SdkTlsSocketFactory.java   
public SdkTlsSocketFactory(final SSLContext sslContext, final HostnameVerifier hostnameVerifier) {
    super(sslContext, hostnameVerifier);
    if (sslContext == null) {
        throw new IllegalArgumentException(
                "sslContext must not be null. " + "Use SSLContext.getDefault() if you are unsure.");
    }
    this.sslContext = sslContext;
}
项目:boohee_v5.6    文件:Address.java   
public Address(String uriHost, int uriPort, Dns dns, SocketFactory socketFactory,
               SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier,
               CertificatePinner certificatePinner, Authenticator authenticator, Proxy proxy,
               List<Protocol> protocols, List<ConnectionSpec> connectionSpecs, ProxySelector
                       proxySelector) {
    this.url = new Builder().scheme(sslSocketFactory != null ? b.a : "http").host(uriHost)
            .port(uriPort).build();
    if (dns == null) {
        throw new IllegalArgumentException("dns == null");
    }
    this.dns = dns;
    if (socketFactory == null) {
        throw new IllegalArgumentException("socketFactory == null");
    }
    this.socketFactory = socketFactory;
    if (authenticator == null) {
        throw new IllegalArgumentException("authenticator == null");
    }
    this.authenticator = authenticator;
    if (protocols == null) {
        throw new IllegalArgumentException("protocols == null");
    }
    this.protocols = Util.immutableList((List) protocols);
    if (connectionSpecs == null) {
        throw new IllegalArgumentException("connectionSpecs == null");
    }
    this.connectionSpecs = Util.immutableList((List) connectionSpecs);
    if (proxySelector == null) {
        throw new IllegalArgumentException("proxySelector == null");
    }
    this.proxySelector = proxySelector;
    this.proxy = proxy;
    this.sslSocketFactory = sslSocketFactory;
    this.hostnameVerifier = hostnameVerifier;
    this.certificatePinner = certificatePinner;
}
项目:fort_w    文件:Web.java   
/**
 * @see http://literatejava.com/networks/ignore-ssl-certificate-errors-apache-httpclient-4-4/
 * @return
 * @throws Exception
 */
public static synchronized HttpClient getHttpClient() throws Exception
{
   HttpClientBuilder b = HttpClientBuilder.create();

   // setup a Trust Strategy that allows all certificates.
   //
   SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()
      {
         public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
         {
            return true;
         }
      }).build();
   b.setSslcontext(sslContext);

   // don't check Hostnames, either.
   //      -- use SSLConnectionSocketFactory.getDefaultHostnameVerifier(), if you don't want to weaken
   HostnameVerifier hostnameVerifier = SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;

   // here's the special part:
   //      -- need to create an SSL Socket Factory, to use our weakened "trust strategy";
   //      -- and create a Registry, to register it.
   //
   SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
   //Registry<ConnectionSocketFactory> socketFactoryRegistry = ;

   // now, we create connection-manager using our Registry.
   //      -- allows multi-threaded use
   PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory> create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslSocketFactory).build());
   b.setConnectionManager(connMgr);

   // finally, build the HttpClient;
   //      -- done!
   HttpClient client = b.build();

   return client;
}
项目:GitHub    文件:Main.java   
private static HostnameVerifier createInsecureHostnameVerifier() {
  return new HostnameVerifier() {
    @Override public boolean verify(String s, SSLSession sslSession) {
      return true;
    }
  };
}
项目:af-pay    文件:HttpsUtils.java   
@Override
public boolean verify(String hostname, SSLSession session) {
    System.out.println("verify " + hostname);
    HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
    return hv.verify(hostname, session);
}
项目:GitHub    文件:UrlConnection.java   
@Override public void prepare(Benchmark benchmark) {
  super.prepare(benchmark);
  if (benchmark.tls) {
    SslClient sslClient = SslClient.localhost();
    SSLSocketFactory socketFactory = sslClient.socketFactory;
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
      @Override public boolean verify(String s, SSLSession session) {
        return true;
      }
    };
    HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
    HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
  }
}
项目:cas4.0.x-server-wechat    文件:SimpleHttpClientTests.java   
private HostnameVerifier getFriendlyToAllHostnameVerifier() {
    final HostnameVerifier hv = new HostnameVerifier() {
        @Override
        public boolean verify(final String hostname, final SSLSession session) { return true; }
    };
    return hv;
}
项目:StubbornJava    文件:HttpClient.java   
public static OkHttpClient trustAllSslClient(OkHttpClient client) {
    log.warn("Using the trustAllSslClient is highly discouraged and should not be used in Production!");
    Builder builder = client.newBuilder();
    builder.sslSocketFactory(trustAllSslSocketFactory, (X509TrustManager)trustAllCerts[0]);
    builder.hostnameVerifier(new HostnameVerifier() {
      @Override
      public boolean verify(String hostname, SSLSession session) {
        return true;
      }
    });
    return builder.build();
}
项目:CrawlerSYS    文件:WebCrawler.java   
/**
 * 忽略HTTPS请求的SSL证书,必须在openConnection之前调用
 * @throws Exception
 */
public static void ignoreSsl() throws Exception{
    HostnameVerifier hv = new HostnameVerifier() {
        @Override
        public boolean verify(String urlHostName, SSLSession session) {
            System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
            logger.info("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
            return true;
        }
    };
    trustAllHttpsCertificates();
    HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:RestTestCase.java   
@Test
public void testSSLContext() throws Exception {
    logger.info("start SSL Context test");
    Client client = newClient();
    HostnameVerifier hostnameVerifier = client.getHostnameVerifier();
    assertNotNull("Java Utility", hostnameVerifier);
    assertNull("no SSL by default", client.getSslContext());
}
项目:cas-5.1.0    文件:SSOPostProfileCallbackHandlerController.java   
/**
 * Instantiates a new idp-sso post saml profile handler controller.
 *
 * @param samlObjectSigner                             the saml object signer
 * @param parserPool                                   the parser pool
 * @param authenticationSystemSupport                  the authentication system support
 * @param servicesManager                              the services manager
 * @param webApplicationServiceFactory                 the web application service factory
 * @param samlRegisteredServiceCachingMetadataResolver the saml registered service caching metadata resolver
 * @param configBean                                   the config bean
 * @param responseBuilder                              the response builder
 * @param authenticationContextClassMappings           the authentication context class mappings
 * @param serverPrefix                                 the server prefix
 * @param serverName                                   the server name
 * @param authenticationContextRequestParameter        the authentication context request parameter
 * @param loginUrl                                     the login url
 * @param logoutUrl                                    the logout url
 * @param forceSignedLogoutRequests                    the force signed logout requests
 * @param singleLogoutCallbacksDisabled                the single logout callbacks disabled
 * @param samlObjectSignatureValidator                 the saml object signature validator
 */
public SSOPostProfileCallbackHandlerController(final BaseSamlObjectSigner samlObjectSigner,
                                               final ParserPool parserPool,
                                               final AuthenticationSystemSupport authenticationSystemSupport,
                                               final ServicesManager servicesManager,
                                               final ServiceFactory<WebApplicationService> webApplicationServiceFactory,
                                               final SamlRegisteredServiceCachingMetadataResolver samlRegisteredServiceCachingMetadataResolver,
                                               final OpenSamlConfigBean configBean,
                                               final SamlProfileObjectBuilder<Response> responseBuilder,
                                               final Set<String> authenticationContextClassMappings,
                                               final String serverPrefix,
                                               final String serverName,
                                               final String authenticationContextRequestParameter,
                                               final String loginUrl,
                                               final String logoutUrl,
                                               final boolean forceSignedLogoutRequests,
                                               final boolean singleLogoutCallbacksDisabled,
                                               final SamlObjectSignatureValidator samlObjectSignatureValidator,
                                               final HostnameVerifier hostnameVerifier) {
    super(samlObjectSigner,
            parserPool,
            authenticationSystemSupport,
            servicesManager,
            webApplicationServiceFactory,
            samlRegisteredServiceCachingMetadataResolver,
            configBean,
            responseBuilder,
            authenticationContextClassMappings,
            serverPrefix,
            serverName,
            authenticationContextRequestParameter,
            loginUrl,
            logoutUrl,
            forceSignedLogoutRequests,
            singleLogoutCallbacksDisabled,
            samlObjectSignatureValidator);
    this.hostnameVerifier = hostnameVerifier;
}
项目:CXJPadProject    文件:OKClient.java   
public OKClient() {
    client = new OkHttpClient.Builder()
            .connectTimeout(HttpUtils.CONNECT_TIMEOUT, TimeUnit.MILLISECONDS)
            .readTimeout(HttpUtils.READ_TIMEOUT, TimeUnit.MILLISECONDS)
            .writeTimeout(HttpUtils.READ_TIMEOUT, TimeUnit.MILLISECONDS)
            .hostnameVerifier(new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }
            })
            .build();
}
项目:beadledom    文件:X509HostnameVerifierAdapter.java   
/**
 * Adapts a {@link HostnameVerifier} to be compatible with the HttpClient
 * {@link X509HostnameVerifier}.
 */
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);
}
项目:dremio-oss    文件:SSLHelper.java   
/**
 * We will accept all hostnames
 * @return
 */
public static HostnameVerifier newAllValidHostnameVerifier() {
  return new HostnameVerifier() {
    @Override
    public boolean verify(String hostname, SSLSession session) {
      return true;
    }
  };
}
项目:JRediClients    文件:JedisFactory.java   
public JedisFactory(final String host, final int port, final int connectionTimeout, final int soTimeout,
        final String password, final int database, final String clientName, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    this.hostAndPort.set(new HostAndPort(host, port));
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.password = password;
    this.database = database;
    this.clientName = clientName;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:pcloud-networking-java    文件:PCloudAPIClient.java   
/**
 * Sets the {@linkplain HostnameVerifier} for the client
 *
 * @param hostnameVerifier The {@linkplain HostnameVerifier} to be set to the client
 * @return A reference to the {@linkplain Builder} object
 * @throws IllegalArgumentException on a null {@linkplain HostnameVerifier} argument
 */
public Builder setHostnameVerifier(HostnameVerifier hostnameVerifier) {
    if (hostnameVerifier == null) {
        throw new IllegalArgumentException("HostnameVerifier cannot be null.");
    }
    this.hostnameVerifier = hostnameVerifier;
    return this;
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host, int port, int timeout,
        final String password, final int database, final String clientName, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    this(poolConfig, host, port, timeout, timeout, password, database, clientName, ssl, sslSocketFactory,
            sslParameters, hostnameVerifier);
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host, int port, final int connectionTimeout,
        final int soTimeout, final String password, final int database, final String clientName, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    super(poolConfig, new JedisFactory(host, port, connectionTimeout, soTimeout, password, database, clientName,
            ssl, sslSocketFactory, sslParameters, hostnameVerifier));
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final GenericObjectPoolConfig poolConfig, final URI uri, final int connectionTimeout,
        final int soTimeout, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    super(poolConfig, new JedisFactory(uri, connectionTimeout, soTimeout, null,
                    (uri.getScheme() != null && uri.getScheme().equals("rediss")), sslSocketFactory, sslParameters,
                    hostnameVerifier));
}
项目:OpenJSharp    文件:HttpClientTransport.java   
protected boolean checkHTTPS(HttpURLConnection connection) {
    if (connection instanceof HttpsURLConnection) {

        // TODO The above property needs to be removed in future version as the semantics of this property are not preoperly defined.
        // One should use JAXWSProperties.HOSTNAME_VERIFIER to control the behavior

        // does the client want client hostname verification by the service
        String verificationProperty =
            (String) context.invocationProperties.get(HOSTNAME_VERIFICATION_PROPERTY);
        if (verificationProperty != null) {
            if (verificationProperty.equalsIgnoreCase("true")) {
                ((HttpsURLConnection) connection).setHostnameVerifier(new HttpClientVerifier());
            }
        }

        // Set application's HostNameVerifier for this connection
        HostnameVerifier verifier =
            (HostnameVerifier) context.invocationProperties.get(JAXWSProperties.HOSTNAME_VERIFIER);
        if (verifier != null) {
            ((HttpsURLConnection) connection).setHostnameVerifier(verifier);
        }

        // Set application's SocketFactory for this connection
        SSLSocketFactory sslSocketFactory =
            (SSLSocketFactory) context.invocationProperties.get(JAXWSProperties.SSL_SOCKET_FACTORY);
        if (sslSocketFactory != null) {
            ((HttpsURLConnection) connection).setSSLSocketFactory(sslSocketFactory);
        }

        return true;
    }
    return false;
}
项目:JRediClients    文件:BinaryJedis.java   
public BinaryJedis(final URI uri, final int connectionTimeout, final int soTimeout,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    initializeClientFromURI(uri, sslSocketFactory, sslParameters, hostnameVerifier);
    client.setConnectionTimeout(connectionTimeout);
    client.setSoTimeout(soTimeout);
}
项目:ScriptSpider    文件:HttpUtils.java   
/**
 * 创建httpclient连接池,并初始化httpclient
 */
public void init() {
    try {
        SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null,
                new TrustSelfSignedStrategy())
                .build();
        HostnameVerifier hostnameVerifier = SSLConnectionSocketFactory.getDefaultHostnameVerifier();
        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                sslcontext, hostnameVerifier);
        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("http", PlainConnectionSocketFactory.getSocketFactory())
                .register("https", sslsf)
                .build();
        httpClientConnectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
        // Increase max total connection to 200
        httpClientConnectionManager.setMaxTotal(maxTotalPool);
        // Increase default max connection per route to 20
        httpClientConnectionManager.setDefaultMaxPerRoute(maxConPerRoute);
        SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(socketTimeout).build();
        httpClientConnectionManager.setDefaultSocketConfig(socketConfig);
    } catch (Exception e) {

    }
}
项目:JRediClients    文件:JedisShardInfo.java   
public JedisShardInfo(String host, int port, int connectionTimeout, int soTimeout, int weight, boolean ssl,
        SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    super(weight);
    this.host = host;
    this.port = port;
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}