/** * Lazily registers the protocol with the given id. * * @param id the protocol ID * * @return the lazily registered protocol * * @throws IllegalStateException if the protocol with id is not recognized */ private static Protocol lazyRegisterProtocol(String id) throws IllegalStateException { if ("http".equals(id)) { final Protocol http = new Protocol("http", DefaultProtocolSocketFactory.getSocketFactory(), 80); Protocol.registerProtocol("http", http); return http; } if ("https".equals(id)) { final Protocol https = new Protocol("https", SSLProtocolSocketFactory.getSocketFactory(), 443); Protocol.registerProtocol("https", https); return https; } throw new IllegalStateException("unsupported protocol: '" + id + "'"); }
@After public void reset() { Protocol.registerProtocol("https", original); }
static void replaceProtocol(ProtocolSocketFactory socketFactory, String schema, int defaultPort) { // // switch protocol // due to how HttpCommons work internally this dance is best to be kept as is // Protocol directHttp = Protocol.getProtocol(schema); if (directHttp instanceof DelegatedProtocol) { // unwrap the original directHttp = ((DelegatedProtocol)directHttp).getOriginal(); assert directHttp instanceof DelegatedProtocol == false; } Protocol proxiedHttp = new DelegatedProtocol(socketFactory, directHttp, schema, defaultPort); // NB: register the new protocol since when using absolute URIs, HttpClient#executeMethod will override the configuration (#387) // NB: hence why the original/direct http protocol is saved - as otherwise the connection is not closed since it is considered different // NB: (as the protocol identities don't match) // this is not really needed since it's being replaced later on // hostConfig.setHost(proxyHost, proxyPort, proxiedHttp); Protocol.registerProtocol(schema, proxiedHttp); // end dance }
public UcsHttpClient(String ip) { url = String.format("http://%s/nuova", ip); Protocol.registerProtocol("https", ucsHttpsProtocol); }
public HttpComponent3Factory() { httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); httpClient.getParams().setHttpElementCharset(Consts.UTF_8.name()); httpClient.getParams().setParameter("http.protocol.uri-charset", Consts.UTF_8.name()); // httpMethod.getParams().setUriCharset(Consts.UTF_8.name()); httpClient.getParams().setContentCharset(Consts.UTF_8.name()); Protocol.registerProtocol("https", new Protocol("https", new SSLProtocolSocketFactory( HttpClientFactory.allowSSLContext()), 443)); }
protected NeutronRestApi(final Class<? extends HttpMethodBase> httpClazz, final String protocol, final int port) { client = createHttpClient(); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); this.httpClazz = httpClazz; try { // Cast to ProtocolSocketFactory to avoid the deprecated constructor // with the SecureProtocolSocketFactory parameter Protocol.registerProtocol(protocol, new Protocol(protocol, (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), HTTPS_PORT)); } catch (IOException e) { s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e); } }
public BigSwitchBcfApi() { _client = createHttpClient(); _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); try { // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), _port)); } catch (IOException e) { S_LOGGER.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e); } }
private static void registerEasyHttps() { // by pass all https issue if (EASY_HTTPS == null) { EASY_HTTPS = new Protocol("https", (ProtocolSocketFactory) new DefaultSslProtocolSocketFactory(), 443); Protocol.registerProtocol("https", EASY_HTTPS); } }
private void registerSsl() { Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new DefaultSslProtocolSocketFactory(), 443)); }
private void resolveHttpParams(HttpParams params) { if (params != null) { if (params.getProxy() != null) { InetSocketAddress socketAddress = (InetSocketAddress) params .getProxy().address(); httpClient.getHostConfiguration().setProxy( socketAddress.getHostName(), socketAddress.getPort()); } if (params.getSSLContext() != null) { Protocol.registerProtocol("https", new Protocol("https", new SSLProtocolSocketFactory(params.getSSLContext()), 443)); } httpClient.getHttpConnectionManager().getParams() .setConnectionTimeout(params.getConnectTimeout()); } }
/** * Register the specified secure socket factory on the specified port */ public static void registerFactory(SecureProtocolSocketFactory factory, int port) { Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)factory, port)); }
public void register() { ProtocolSocketFactory socketFactory = new TrustAllSocketFactory(); Protocol easyhttps = new Protocol("https", (ProtocolSocketFactory) socketFactory, 443); Protocol.registerProtocol("https", easyhttps); LOG.info("Registered " + TrustAllCertsEnvironment.class + " as default https handler."); } }
public void registerProtocol(String scheme, int port) { SocketFactory factory = new SocketFactory(); Protocol protocol = new Protocol(scheme, factory, port); Protocol.registerProtocol(scheme, protocol); }
/** * Method registers the EasySSLProtocolSocketFactory as default https handler. */ public void register() { Protocol easyhttps = new Protocol("https", (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443); Protocol.registerProtocol("https", easyhttps); LOG.info("Registered " + EasySSLEnvironment.class + " as default https handler."); } }
private static void registerEasyHttps() { // by pass all https issue if (EASY_HTTPS == null) { EASY_HTTPS = new Protocol("https", (ProtocolSocketFactory) new DefaultSslProtocolSocketFactory(), 443); Protocol.registerProtocol("https", EASY_HTTPS); } }
/** * Initializes the Apache Commons HttpClient library. */ protected static void initializeHttpClient() { if (!Boolean.getBoolean(SYSPROP_HTTPCLIENT_HTTPS_DISABLE_HOSTNAME_VERIFICATION)) { ProtocolSocketFactory socketFactory = new TLSProtocolSocketFactory(null, null, new StrictHostnameVerifier()); Protocol.registerProtocol("https", new Protocol("https", socketFactory, 443)); } }
/** * Permantently damage the HTTP client by having it accept bogus certificates. */ public static void allowSelfSignedCertificate() { Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443)); }
protected synchronized HttpClient initialValue() { HttpClientParams params = new HttpClientParams(); params.setParameter(HttpClientParams.RETRY_HANDLER, noRetryHandler); IPHttpConnectionManager manager = new IPHttpConnectionManager(); Protocol dnsTimedProtocol = new Protocol("http", new DNSTimingProtocolSocketFactory(), 80); Protocol.registerProtocol("http", dnsTimedProtocol); manager.getParams().setConnectionTimeout(connectionTimeoutMS); manager.getParams().setSoTimeout(socketTimeoutMS); return new HttpClient(params, manager); } };
public WSFacade(final CTeConfig config) throws IOException, KeyManagementException, UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException { Protocol.registerProtocol("https", new Protocol("https", new DFSocketFactory(config), 443)); this.wsStatusConsulta = new WSStatusConsulta(config); this.wsRecepcaoLote = new WSRecepcaoLote(config); this.wsRecepcaoLoteRetorno = new WSRecepcaoLoteRetorno(config); this.wsNotaConsulta = new WSNotaConsulta(config); this.wsCancelamento = new WSCancelamento(config); }
public WSFacade(final MDFeConfig config) throws IOException, KeyManagementException, UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException { Protocol.registerProtocol("https", new Protocol("https", new DFSocketFactory(config), 443)); this.wsStatusConsulta = new WSStatusConsulta(config); this.wsRecepcaoLote = new WSRecepcaoLote(config); // this.wsRecepcaoLoteRetorno = new WSRecepcaoLoteRetorno(config); this.wsNotaConsulta = new WSNotaConsulta(config); this.wsCancelamento = new WSCancelamento(config); this.wsEncerramento = new WSEncerramento(config); this.wsConsultaRecibo = new WSConsultaRecibo(config); this.wsConsultaNaoEncerrados = new WSConsultaNaoEncerrados(config); this.wsIncluirCondutor = new WSIncluirCondutor(config); }