use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project zm-mailbox by Zimbra.
the class SocketFactories method register.
private static synchronized void register(X509TrustManager tm) {
if (registered)
return;
// Set default TrustManager
TrustManagers.setDefaultTrustManager(tm);
// Register Apache Commons HTTP/HTTPS protocol socket factories
ProtocolSocketFactory psf = defaultProtocolSocketFactory();
Protocol.registerProtocol(HTTP, new Protocol(HTTP, psf, 80));
ProtocolSocketFactory spsf = defaultSecureProtocolSocketFactory();
Protocol.registerProtocol(HTTPS, new Protocol(HTTPS, spsf, 443));
// HttpURLConnection already uses system ProxySelector by default
// Set HttpsURLConnection SSL socket factory and optional hostname verifier
HttpsURLConnection.setDefaultSSLSocketFactory(defaultSSLSocketFactory(false));
if (tm instanceof CustomTrustManager) {
HttpsURLConnection.setDefaultHostnameVerifier(new CustomHostnameVerifier());
}
// Set the system-wide default ProxySelector
ProxySelector.setDefault(ProxySelectors.defaultProxySelector());
registered = true;
}
use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project translationstudio8 by heartsome.
the class ServiceUtilTest method getService.
public static IService getService() throws MalformedURLException {
// Service srvcModel = new
// ObjectServiceFactory().create(IService.class);
// XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
// .newInstance().getXFire());
//
// IService srvc = (IService) factory.create(srvcModel,
// Constants.CONNECT_URL);
// return srvc;
ProtocolSocketFactory easy = new EasySSLProtocolSocketFactory();
Protocol protocol = new Protocol(HTTP_TYPE, easy, PORT);
Protocol.registerProtocol(HTTP_TYPE, protocol);
Service serviceModel = new ObjectServiceFactory().create(IService.class, SERVICE_NAME, SERVICE_NAMESPACE, null);
IService service = (IService) new XFireProxyFactory().create(serviceModel, SERVICE_URL);
Client client = ((XFireProxy) Proxy.getInvocationHandler(service)).getClient();
client.addOutHandler(new DOMOutHandler());
client.setProperty(CommonsHttpMessageSender.GZIP_ENABLED, Boolean.FALSE);
client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "1");
client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "0");
return service;
}
use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project camel by apache.
the class HttpsSslContextParametersGetTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
SSLContextParameters params = new SSLContextParameters();
ProtocolSocketFactory factory = new SSLContextParametersSecureProtocolSocketFactory(params, context);
Protocol.registerProtocol("https", new Protocol("https", factory, 443));
from("direct:start").to("https://mail.google.com/mail/").to("mock:results");
}
};
}
use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project zaproxy by zaproxy.
the class OptionsParamCertificate method setActiveCertificate.
public void setActiveCertificate() {
ProtocolSocketFactory sslFactory = Protocol.getProtocol("https").getSocketFactory();
if (sslFactory instanceof SSLConnector) {
SSLConnector ssl = (SSLConnector) sslFactory;
ssl.setActiveCertificate();
}
}
use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project zaproxy by zaproxy.
the class OptionsParamCertificate method setEnableCertificate.
public void setEnableCertificate(boolean enabled) {
ProtocolSocketFactory sslFactory = Protocol.getProtocol("https").getSocketFactory();
if (sslFactory instanceof SSLConnector) {
SSLConnector ssl = (SSLConnector) sslFactory;
ssl.setEnableClientCert(enabled);
setUseClientCert(enabled);
}
}
Aggregations