org.apache.http.conn.ssl.BrowserCompatHostnameVerifier Java Examples
The following examples show how to use
org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractRestTemplateClient.java From documentum-rest-client-java with Apache License 2.0 | 6 votes |
public AbstractRestTemplateClient ignoreAuthenticateServer() { //backward compatible with android httpclient 4.3.x if(restTemplate.getRequestFactory() instanceof HttpComponentsClientHttpRequestFactory) { try { SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); X509HostnameVerifier verifier = ignoreSslWarning ? new AllowAllHostnameVerifier() : new BrowserCompatHostnameVerifier(); SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, verifier); HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); ((HttpComponentsClientHttpRequestFactory)restTemplate.getRequestFactory()).setHttpClient(httpClient); } catch (Exception e) { e.printStackTrace(); } } else { Debug.error("the request factory " + restTemplate.getRequestFactory().getClass().getName() + " does not support ignoreAuthenticateServer"); } return this; }
Example #2
Source File: JSSETruststoreConfigurator.java From keycloak with Apache License 2.0 | 6 votes |
public HostnameVerifier getHostnameVerifier() { if (provider == null) { return null; } HostnameVerificationPolicy policy = provider.getPolicy(); switch (policy) { case ANY: return new HostnameVerifier() { @Override public boolean verify(String s, SSLSession sslSession) { return true; } }; case WILDCARD: return new BrowserCompatHostnameVerifier(); case STRICT: return new StrictHostnameVerifier(); default: throw new IllegalStateException("Unknown policy: " + policy.name()); } }