org.apache.http.conn.ssl.StrictHostnameVerifier Java Examples
The following examples show how to use
org.apache.http.conn.ssl.StrictHostnameVerifier.
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: 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()); } }
Example #2
Source File: AndroidSmackInitializer.java From Smack with Apache License 2.0 | 5 votes |
@Override public List<Exception> initialize() { SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier()); Base64.setEncoder(AndroidBase64Encoder.getInstance()); Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance()); return null; }
Example #3
Source File: HttpConnectionManager.java From Conversations with GNU General Public License v3.0 | 5 votes |
void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) { final X509TrustManager trustManager; final HostnameVerifier hostnameVerifier = mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifier(new StrictHostnameVerifier(), interactive); if (interactive) { trustManager = mXmppConnectionService.getMemorizingTrustManager().getInteractive(); } else { trustManager = mXmppConnectionService.getMemorizingTrustManager().getNonInteractive(); } try { final SSLSocketFactory sf = new TLSSocketFactory(new X509TrustManager[]{trustManager}, mXmppConnectionService.getRNG()); connection.setSSLSocketFactory(sf); connection.setHostnameVerifier(hostnameVerifier); } catch (final KeyManagementException | NoSuchAlgorithmException ignored) { } }