public static HttpClient getHttpClient() { HttpClient httpClient = null; TrustStrategy easyStrategy = new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }; try { SSLSocketFactory sf = new SSLSocketFactory(easyStrategy, new AllowAllHostnameVerifier()); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", DEFAULT_PORT, sf)); ClientConnectionManager ccm = new BasicClientConnectionManager(registry); httpClient = new DefaultHttpClient(ccm); } catch (KeyManagementException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } catch (UnrecoverableKeyException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } catch (NoSuchAlgorithmException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } catch (KeyStoreException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } return httpClient; }
public ManagedClientConnection getConnection( final long timeout, final TimeUnit tunit) { return BasicClientConnectionManager.this.getConnection( route, state); }
@Override protected void finalize() throws Throwable { try { shutdown(); } finally { // Make sure we call overridden method even if shutdown barfs super.finalize(); } }
public void closeExpiredConnections() { synchronized (this) { assertNotShutdown(); final long now = System.currentTimeMillis(); if (this.poolEntry != null && this.poolEntry.isExpired(now)) { this.poolEntry.close(); this.poolEntry.getTracker().reset(); } } }
/** * Creates a new simple connection manager. * * @param schreg the scheme registry */ public BasicClientConnectionManager(final SchemeRegistry schreg) { Args.notNull(schreg, "Scheme registry"); this.schemeRegistry = schreg; this.connOperator = createConnectionOperator(schreg); }
synchronized (this) { if (this.shutdown) { shutdownConnection(managedConn); return; shutdownConnection(managedConn);
public void closeExpiredConnections() { synchronized (this) { assertNotShutdown(); final long now = System.currentTimeMillis(); if (this.poolEntry != null && this.poolEntry.isExpired(now)) { this.poolEntry.close(); this.poolEntry.getTracker().reset(); } } }
/** * Creates a new simple connection manager. * * @param schreg the scheme registry */ public BasicClientConnectionManager(final SchemeRegistry schreg) { Args.notNull(schreg, "Scheme registry"); this.schemeRegistry = schreg; this.connOperator = createConnectionOperator(schreg); }
synchronized (this) { if (this.shutdown) { shutdownConnection(managedConn); return; shutdownConnection(managedConn);
protected DefaultHttpClient getHttpsClient() { try { SSLContext sslContext = SSLUtils.getSSLContext(); X509TrustManager tm = new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; sslContext.init(null, new TrustManager[] {tm}, new SecureRandom()); SSLSocketFactory socketFactory = new SSLSocketFactory(sslContext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", nmsUrl.getPort(), socketFactory)); BasicClientConnectionManager mgr = new BasicClientConnectionManager(registry); return new DefaultHttpClient(mgr); } catch (NoSuchAlgorithmException ex) { throw new CloudRuntimeException(ex.getMessage()); } catch (KeyManagementException ex) { throw new CloudRuntimeException(ex.getMessage()); } }
@Override public void closeExpiredConnections() { synchronized (this) { assertNotShutdown(); final long now = System.currentTimeMillis(); if (this.poolEntry != null && this.poolEntry.isExpired(now)) { this.poolEntry.close(); this.poolEntry.getTracker().reset(); } } }
@Override public ManagedClientConnection getConnection( final long timeout, final TimeUnit tunit) { return BasicClientConnectionManager.this.getConnection( route, state); }
/** * Creates a new simple connection manager. * * @param schreg the scheme registry */ public BasicClientConnectionManager(final SchemeRegistry schreg) { Args.notNull(schreg, "Scheme registry"); this.schemeRegistry = schreg; this.connOperator = createConnectionOperator(schreg); }
@Override protected void finalize() throws Throwable { try { shutdown(); } finally { // Make sure we call overridden method even if shutdown barfs super.finalize(); } }
synchronized (this) { if (this.shutdown) { shutdownConnection(managedConn); return; shutdownConnection(managedConn);
final SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", DEFAULT_AGENT_PORT, sf)); final ClientConnectionManager ccm = new BasicClientConnectionManager(registry); httpClient = new DefaultHttpClient(ccm); } catch (final KeyManagementException e) {
@Override public void closeExpiredConnections() { synchronized (this) { assertNotShutdown(); final long now = System.currentTimeMillis(); if (this.poolEntry != null && this.poolEntry.isExpired(now)) { this.poolEntry.close(); this.poolEntry.getTracker().reset(); } } }
public ManagedClientConnection getConnection( final long timeout, final TimeUnit tunit) { return BasicClientConnectionManager.this.getConnection( route, state); }
/** * Creates a new simple connection manager. * * @param schreg the scheme registry */ public BasicClientConnectionManager(final SchemeRegistry schreg) { Args.notNull(schreg, "Scheme registry"); this.schemeRegistry = schreg; this.connOperator = createConnectionOperator(schreg); }
@Override protected void finalize() throws Throwable { try { shutdown(); } finally { // Make sure we call overridden method even if shutdown barfs super.finalize(); } }