当前位置: 首页>>代码示例>>Java>>正文


Java EasySSLProtocolSocketFactory类代码示例

本文整理汇总了Java中org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory的典型用法代码示例。如果您正苦于以下问题:Java EasySSLProtocolSocketFactory类的具体用法?Java EasySSLProtocolSocketFactory怎么用?Java EasySSLProtocolSocketFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EasySSLProtocolSocketFactory类属于org.apache.commons.httpclient.contrib.ssl包,在下文中一共展示了EasySSLProtocolSocketFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleCertificateExceptionAndRetry

import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; //导入依赖的package包/类
@Nullable
private static HttpMethod handleCertificateExceptionAndRetry(@NotNull IOException e, @NotNull String host,
                                                             @NotNull HttpClient client, @NotNull URI uri,
                                                             @NotNull ThrowableConvertor<String, HttpMethod, IOException> methodCreator)
                                                             throws IOException {
  if (!isCertificateException(e)) {
    throw e;
  }

  if (isTrusted(host)) {
    // creating a special configuration that allows connections to non-trusted HTTPS hosts
    // see the javadoc to EasySSLProtocolSocketFactory for details
    Protocol easyHttps = new Protocol("https", (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443);
    HostConfiguration hc = new HostConfiguration();
    hc.setHost(host, 443, easyHttps);
    String relativeUri = new URI(uri.getPathQuery(), false).getURI();
    // it is important to use relative URI here, otherwise our custom protocol won't work.
    // we have to recreate the method, because HttpMethod#setUri won't overwrite the host,
    // and changing host by hands (HttpMethodBase#setHostConfiguration) is deprecated.
    HttpMethod method = methodCreator.convert(relativeUri);
    client.executeMethod(hc, method);
    return method;
  }
  throw e;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:GithubSslSupport.java

示例2: sendRequest

import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; //导入依赖的package包/类
private String sendRequest(String service, String xmlRequest) throws ExecutionException {
    HttpClient client = new HttpClient();
    String response = null;
    PostMethod method = new PostMethod("/xmlIM/" + service);
    method.setRequestBody(xmlRequest);

    try {
        org.apache.commons.httpclient.protocol.Protocol myhttps = new org.apache.commons.httpclient.protocol.Protocol("https", new EasySSLProtocolSocketFactory(), 443);
        client.getHostConfiguration().setHost(_ip, 443, myhttps);
        int statusCode = client.executeMethod(method);

        if (statusCode != HttpStatus.SC_OK) {
            throw new Exception("Error code : " + statusCode);
        }
        response = method.getResponseBodyAsString();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        throw new ExecutionException(e.getMessage());
    }
    System.out.println(response);
    return response;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:23,代码来源:CiscoVnmcConnectionImpl.java

示例3: loadLifecycles

import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; //导入依赖的package包/类
@Override
public List<Lifecycle> loadLifecycles() throws Exception {
	List<Lifecycle> lifecycles = new LinkedList<Lifecycle>();
	// this validation of our service list needs to happen after we've
	// loaded our configs so it's a lifecycle
	lifecycles.add(new BaseLifecycle() {

		@Override
		public void start() throws Exception {
			// first check if we want to allow self-signed certificates for SSL communication
			if (Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.KSB_ALLOW_SELF_SIGNED_SSL)).booleanValue()) {
			    Protocol.registerProtocol("https", new Protocol("https",
				    (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443));
			}
			super.start();
		}
	});
	return lifecycles;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:20,代码来源:KSBConfigurer.java

示例4: easySSL

import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; //导入依赖的package包/类
protected void easySSL()
{
    ProtocolSocketFactory easySSLProtocolSocketFactory = new EasySSLProtocolSocketFactory();
    Protocol.unregisterProtocol("https");
    Protocol.registerProtocol("https", new Protocol("https",
        easySSLProtocolSocketFactory,
        getUrl().getPort() == -1 ? 443 : getUrl().getPort()));
}
 
开发者ID:hschott,项目名称:cargo-wso2-container,代码行数:9,代码来源:AbstractWSO2Carbon4xRemoteService.java

示例5: createAndInitHttpClient

import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; //导入依赖的package包/类
private HttpClient createAndInitHttpClient(String characterEncoding,
		boolean selfSignedSSL) {
	if (selfSignedSSL) {
		Protocol.registerProtocol("https", new Protocol("https",
				new EasySSLProtocolSocketFactory(), 443));
	}
	HttpClient httpClient = new HttpClient();
	WebUtil.configureHttpClient(httpClient, "Mylyn");
	httpClient.getParams().setContentCharset(characterEncoding);
	return httpClient;
}
 
开发者ID:project-open,项目名称:po-mylyn-integration,代码行数:12,代码来源:ProjectOpenHttpClient.java

示例6: initSSLCertPolicy

import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; //导入依赖的package包/类
private void initSSLCertPolicy() {
  EasySSLProtocolSocketFactory secureProtocolSocketFactory = new EasySSLProtocolSocketFactory();
  Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)secureProtocolSocketFactory, 443));
}
 
开发者ID:ktisha,项目名称:Crucible4IDEA,代码行数:5,代码来源:CrucibleSessionImpl.java


注:本文中的org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。