List of usage examples for org.apache.commons.httpclient.protocol SSLProtocolSocketFactory SSLProtocolSocketFactory
SSLProtocolSocketFactory
From source file:de.juwimm.cms.common.http.HttpClientWrapper.java
protected HttpClientWrapper() { // Protocol.registerProtocol("https", new Protocol("https", new // EasySSLProtocolSocketFactory(), 443)); Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new SSLProtocolSocketFactory(), 443)); System.setProperty("java.protocol.handler.pkgs", "org.apache.commons.httpclient"); connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(20); connectionManager.getParams().setMaxTotalConnections(40); connectionManager.getParams().setStaleCheckingEnabled(true); setHttpProxyHost(System.getProperty("https.proxyHost")); setHttpProxyPort(System.getProperty("https.proxyPort")); if (propFile.exists()) { try {// w ww .j a va 2 s . c o m FileInputStream fis = new FileInputStream(propFile); fileProp = new Properties(); fileProp.load(fis); fis.close(); setHttpProxyUser(fileProp.getProperty("http.proxyUser", "").toString()); // setHttpProxyPassword(fileProp.getProperty("http.proxyPassword", // "").toString()); setHttpProxyPassword(fileProp.getProperty(HttpClientWrapper.CQ_HTTP_PPROXY_PASSWORD_ENCRYPTED, "no") .equalsIgnoreCase("no") ? fileProp.getProperty("http.proxyPassword").toString() : new ClientDesEncrypter().decrypt(fileProp.getProperty("http.proxyPassword"))); } catch (Exception exe) { log.error("Could not update the localuser properties from the .tizzit file", exe); } } }
From source file:de.codecentric.jira.jenkins.plugin.servlet.OverviewServlet.java
public OverviewServlet(TemplateRenderer templateRenderer, JiraAuthenticationContext authenticationContext, PluginSettingsFactory settingsFactory, ApplicationProperties applicationProperties) { this.templateRenderer = templateRenderer; this.authenticationContext = authenticationContext; this.serverList = new ServerList(settingsFactory); this.client = new HttpClient(new MultiThreadedHttpConnectionManager()); //test if jiraversion < 4.3 IsPriorToJiraVersion isPrior = new IsPriorToJiraVersion(applicationProperties); isPrior.setmaxMajorVersion(4);//from ww w. j a v a 2 s .co m isPrior.setmaxMinorVersion(3); this.old = isPrior.shouldDisplay(null); client.getParams().setAuthenticationPreemptive(true); //set SSLContext to accept all certificates try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); SSLContext.setDefault(ctx); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } SecureProtocolSocketFactory secureProtocolSocketFactory = new SSLProtocolSocketFactory(); Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) secureProtocolSocketFactory, 443)); }
From source file:de.codecentric.jira.jenkins.plugin.servlet.RecentBuildsServlet.java
public RecentBuildsServlet(TemplateRenderer templateRenderer, JiraAuthenticationContext authenticationContext, PluginSettingsFactory settingsFactory, ApplicationProperties applicationProperties) { this.templateRenderer = templateRenderer; this.authenticationContext = authenticationContext; this.client = new HttpClient(new MultiThreadedHttpConnectionManager()); this.serverList = new ServerList(settingsFactory); //test if jiraversion < 4.3 IsPriorToJiraVersion isPrior = new IsPriorToJiraVersion(applicationProperties); isPrior.setmaxMajorVersion(4);//from w w w.j a v a 2 s . c o m isPrior.setmaxMinorVersion(3); this.old = isPrior.shouldDisplay(null); client.getParams().setAuthenticationPreemptive(true); //set SSLContext to accept all certificates try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); SSLContext.setDefault(ctx); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } SecureProtocolSocketFactory secureProtocolSocketFactory = new SSLProtocolSocketFactory(); Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) secureProtocolSocketFactory, 443)); }
From source file:com.google.enterprise.connector.sharepoint.client.SharepointClientContext.java
public SharepointClientContext(ClientFactory clientFactory, String sharepointUrl, final String inDomain, final String inKdcHost, final String inUsername, final String inPassword, final String inGoogleConnectorWorkDir, final String inGoogleGlobalNamespace, final String inGoogleLocalNamespace, final String includedURls, final String excludedURls, final String inMySiteBaseURL, final String inAliasMapString, final FeedType inFeedType, boolean useSPSearchVisibility) throws SharepointException { // Avoid a deprecation warning on an overloaded Protocol constructor // by passing the argument as a ProtocolSocketFactory instead of an // SSLProtocolSocketFactory. ProtocolSocketFactory socketFactory = new SSLProtocolSocketFactory(); Protocol.registerProtocol("https", new Protocol("https", socketFactory, SPConstants.SSL_DEFAULT_PORT)); this.clientFactory = clientFactory; kdcServer = inKdcHost;/*from www. j av a 2 s. c o m*/ if (sharepointUrl == null) { throw new SharepointException("sharepoint URL is null"); } if (inUsername == null) { throw new SharepointException("Username is null."); } if (inPassword == null) { throw new SharepointException("Password is null."); } if (inGoogleConnectorWorkDir == null) { throw new SharepointException("Working Directory is null."); } if (inFeedType == null) { throw new SharepointException("Feed Type is null."); } sharepointUrl = sharepointUrl.trim(); if (sharepointUrl.endsWith(SPConstants.SLASH)) { sharepointUrl = sharepointUrl.substring(0, sharepointUrl.lastIndexOf(SPConstants.SLASH)); } // Why to construct a SharePoint URL with default port as 80. try { final URL url = new URL(sharepointUrl); int port = url.getPort(); if (-1 == port) { port = url.getDefaultPort(); } siteURL = url.getProtocol() + SPConstants.URL_SEP + url.getHost() + SPConstants.COLON + port + url.getPath(); } catch (final MalformedURLException e) { throw new SharepointException("Failed to construct sharepoint URL...", e); } if ((inDomain == null) || inDomain.trim().equals("")) { LOGGER.log(Level.CONFIG, "Trying to get domain information from username specified [ " + inUsername + " ] because domain field has not been explicitly specified."); domain = Util.getDomainFromUsername(inUsername); } else { domain = inDomain; } LOGGER.finest("domain set to " + domain); username = Util.getUserFromUsername(inUsername); LOGGER.finest("username set to " + username); this.setExcludedURlList(excludedURls, SPConstants.SEPARATOR); this.setIncludedURlList(includedURls, SPConstants.SEPARATOR); password = inPassword; googleGlobalNamespace = inGoogleGlobalNamespace; googleLocalNamespace = inGoogleLocalNamespace; googleConnectorWorkDir = inGoogleConnectorWorkDir; LOGGER.finest("googleConnectorWorkDir set to " + googleConnectorWorkDir); excludedURL_ParentDir = googleConnectorWorkDir + SPConstants.SLASH + SPConstants.EXCLUDED_URL_DIR; mySiteBaseURL = inMySiteBaseURL; LOGGER.finest("mySiteBaseURL set to " + mySiteBaseURL); aliasMap = parseAlias(inAliasMapString); feedType = inFeedType; LOGGER.finest("feedType set to " + feedType); LOGGER.finest("bFQDNConversion set to " + bFQDNConversion); this.useSPSearchVisibility = useSPSearchVisibility; LOGGER.config(" sharepointUrl = [" + sharepointUrl + "] , domain = [" + inDomain + "] , username = [" + inUsername + "] , googleConnectorWorkDir = [" + inGoogleConnectorWorkDir + "] , googleGlobalNamespace = [" + inGoogleGlobalNamespace + "] , googleLocalNamespace = [" + inGoogleLocalNamespace + "] , includedURls = [" + includedURls + "] , excludedURls = [" + excludedURls + "] , mySiteBaseURL = [" + inMySiteBaseURL + "], aliasMapString = [" + inAliasMapString + "], FeedType [" + inFeedType + "], useSPSearchVisibility = [" + useSPSearchVisibility + "]"); }
From source file:org.apache.nutch.protocol.webdriver.Http.java
/** * Configures the HTTP client// w w w .java 2s. c o m */ private void configureClient() { // Set up an HTTPS socket factory that accepts self-signed certs. ProtocolSocketFactory factory = new SSLProtocolSocketFactory(); Protocol https = new Protocol("https", factory, 443); Protocol.registerProtocol("https", https); HttpConnectionManagerParams params = connectionManager.getParams(); params.setConnectionTimeout(timeout); params.setSoTimeout(timeout); params.setSendBufferSize(BUFFER_SIZE); params.setReceiveBufferSize(BUFFER_SIZE); params.setMaxTotalConnections(maxThreadsTotal); // Also set max connections per host to maxThreadsTotal since all threads // might be used to fetch from the same host - otherwise timeout errors can // occur params.setDefaultMaxConnectionsPerHost(maxThreadsTotal); // executeMethod(HttpMethod) seems to ignore the connection timeout on // the connection manager. // set it explicitly on the HttpClient. client.getParams().setConnectionManagerTimeout(timeout); HostConfiguration hostConf = client.getHostConfiguration(); if (useProxy) { hostConf.setProxy(proxyHost, proxyPort); } ArrayList<Header> headers = new ArrayList<Header>(); // prefer English headers.add(new Header("Accept-Language", "en-us,en-gb,en;q=0.7,*;q=0.3")); // prefer UTF-8 headers.add(new Header("Accept-Charset", "utf-8,ISO-8859-1;q=0.7,*;q=0.7")); // prefer understandable formats headers.add(new Header("Accept", "text/html,application/xml;q=0.9,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5")); // accept gzipped content // headers.add(new Header("Accept-Encoding", "x-gzip, gzip, deflate")); hostConf.getParams().setParameter("http.default-headers", headers); }
From source file:org.jboss.orion.openshift.server.proxy.JsonProxyServlet.java
/** * Initialize the <code>ProxyServlet</code> * * @param config The Servlet configuration passed in by the servlet container */// w w w .j a va2 s. c o m @Override public void init(ServletConfig config) throws ServletException { HttpProxyRuleBase ruleBase = new HttpProxyRuleBase(); loadRuleBase(config, ruleBase); resolver.setMappingRules(ruleBase); Protocol.registerProtocol("http", new Protocol("http", new NonBindingSocketFactory(), 80)); Protocol.registerProtocol("https", new Protocol("https", new SSLProtocolSocketFactory(), 443)); // Protocol.registerProtocol("https", new Protocol("https", new NonBindingSocketFactory(), 443)); }
From source file:org.lockss.plugin.silverchair.PostHttpClientUrlConnection.java
private static SecureProtocolSocketFactory getDefaultSocketFactory(ServerTrustLevel stl) { switch (stl) { case Trusted: return new SSLProtocolSocketFactory(); case SelfSigned: return new EasySSLProtocolSocketFactory(); case Untrusted: default:/*from ww w .j av a 2 s . c om*/ return new PermissiveSSLProtocolSocketFactory(); } }
From source file:smilehouse.opensyncro.defaultcomponents.http.HTTPDestination.java
protected void initializeProtocol(int port) { ProtocolSocketFactory factory;/*from w w w. j a v a 2s . com*/ if ((getAcceptSelfSignedCertificates().booleanValue())) { factory = new EasySSLProtocolSocketFactory(); Protocol easyhttps = new Protocol("https", factory, port); Protocol.registerProtocol("https", easyhttps); } else { factory = new SSLProtocolSocketFactory(); Protocol stricthttps = new Protocol("https", factory, port); Protocol.registerProtocol("https", stricthttps); } }