Java 类org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory 实例源码

项目:tools-idea    文件:GithubSslSupport.java   
@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;
}
项目:cloudstack    文件:CiscoVnmcConnectionImpl.java   
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;
}
项目:kuali_rice    文件:KSBConfigurer.java   
@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;
}
项目:cargo-wso2-container    文件:AbstractWSO2Carbon4xRemoteService.java   
protected void easySSL()
{
    ProtocolSocketFactory easySSLProtocolSocketFactory = new EasySSLProtocolSocketFactory();
    Protocol.unregisterProtocol("https");
    Protocol.registerProtocol("https", new Protocol("https",
        easySSLProtocolSocketFactory,
        getUrl().getPort() == -1 ? 443 : getUrl().getPort()));
}
项目:po-mylyn-integration    文件:ProjectOpenHttpClient.java   
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;
}
项目:Crucible4IDEA    文件:CrucibleSessionImpl.java   
private void initSSLCertPolicy() {
  EasySSLProtocolSocketFactory secureProtocolSocketFactory = new EasySSLProtocolSocketFactory();
  Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)secureProtocolSocketFactory, 443));
}