org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory Java Examples

The following examples show how to use org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CiscoVnmcConnectionImpl.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: CrucibleSessionImpl.java    From Crucible4IDEA with MIT License 4 votes vote down vote up
private void initSSLCertPolicy() {
  EasySSLProtocolSocketFactory secureProtocolSocketFactory = new EasySSLProtocolSocketFactory();
  Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)secureProtocolSocketFactory, 443));
}