Return-Path: X-Original-To: apmail-manifoldcf-commits-archive@www.apache.org Delivered-To: apmail-manifoldcf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93CAEC49C for ; Fri, 13 Sep 2013 06:16:58 +0000 (UTC) Received: (qmail 57673 invoked by uid 500); 13 Sep 2013 01:13:53 -0000 Delivered-To: apmail-manifoldcf-commits-archive@manifoldcf.apache.org Received: (qmail 57486 invoked by uid 500); 13 Sep 2013 01:13:49 -0000 Mailing-List: contact commits-help@manifoldcf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@manifoldcf.apache.org Delivered-To: mailing list commits@manifoldcf.apache.org Received: (qmail 57442 invoked by uid 99); 13 Sep 2013 01:13:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Sep 2013 01:13:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Sep 2013 01:13:46 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8F03C2388900; Fri, 13 Sep 2013 01:13:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1522756 - in /manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira: JiraRepositoryConnector.java JiraSession.java Date: Fri, 13 Sep 2013 01:13:26 -0000 To: commits@manifoldcf.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130913011326.8F03C2388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Fri Sep 13 01:13:26 2013 New Revision: 1522756 URL: http://svn.apache.org/r1522756 Log: Complete the repository connector too Modified: manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java Modified: manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java?rev=1522756&r1=1522755&r2=1522756&view=diff ============================================================================== --- manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java (original) +++ manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java Fri Sep 13 01:13:26 2013 @@ -129,6 +129,12 @@ public class JiraRepositoryConnector ext protected String clientid = null; protected String clientsecret = null; + protected String jiraproxyhost = null; + protected String jiraproxyport = null; + protected String jiraproxydomain = null; + protected String jiraproxyusername = null; + protected String jiraproxypassword = null; + public JiraRepositoryConnector() { super(); } @@ -181,6 +187,12 @@ public class JiraRepositoryConnector ext jirapath = null; clientid = null; clientsecret = null; + + jiraproxyhost = null; + jiraproxyport = null; + jiraproxydomain = null; + jiraproxyusername = null; + jiraproxypassword = null; } /** @@ -203,6 +215,13 @@ public class JiraRepositoryConnector ext jirapath = params.getParameter(JiraConfig.JIRA_PATH_PARAM); clientid = params.getParameter(JiraConfig.CLIENT_ID_PARAM); clientsecret = params.getObfuscatedParameter(JiraConfig.CLIENT_SECRET_PARAM); + + jiraproxyhost = params.getParameter(JiraConfig.JIRA_PROXYHOST_PARAM); + jiraproxyport = params.getParameter(JiraConfig.JIRA_PROXYPORT_PARAM); + jiraproxydomain = params.getParameter(JiraConfig.JIRA_PROXYDOMAIN_PARAM); + jiraproxyusername = params.getParameter(JiraConfig.JIRA_PROXYUSERNAME_PARAM); + jiraproxypassword = params.getObfuscatedParameter(JiraConfig.JIRA_PROXYPASSWORD_PARAM); + } /** @@ -271,7 +290,8 @@ public class JiraRepositoryConnector ext } String jiraurl = jiraprotocol + "://" + jirahost + (StringUtils.isEmpty(jiraport)?"":":"+jiraport) + jirapath; - session = new JiraSession(clientid, clientsecret, jiraurl); + session = new JiraSession(clientid, clientsecret, jiraurl, + jiraproxyhost, jiraproxyport, jiraproxydomain, jiraproxyusername, jiraproxypassword); } lastSessionFetch = System.currentTimeMillis(); Modified: manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java?rev=1522756&r1=1522755&r2=1522756&view=diff ============================================================================== --- manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java (original) +++ manifoldcf/branches/CONNECTORS-773/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java Fri Sep 13 01:13:26 2013 @@ -43,8 +43,10 @@ import org.apache.http.client.HttpClient import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; +import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.auth.NTCredentials; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.impl.client.DefaultHttpClient; @@ -53,6 +55,7 @@ import org.apache.http.util.EntityUtils; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; import org.apache.http.params.CoreConnectionPNames; +import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.client.params.ClientPNames; import org.apache.http.client.HttpRequestRetryHandler; import org.apache.http.protocol.HttpContext; @@ -78,10 +81,28 @@ public class JiraSession { private ClientConnectionManager connectionManager; private HttpClient httpClient; + // Current host name + private static String currentHost = null; + static + { + // Find the current host name + try + { + java.net.InetAddress addr = java.net.InetAddress.getLocalHost(); + + // Get hostname + currentHost = addr.getHostName(); + } + catch (java.net.UnknownHostException e) + { + } + } + /** * Constructor. Create a session. */ - public JiraSession(String clientId, String clientSecret, String URLbase) + public JiraSession(String clientId, String clientSecret, String URLbase, + String proxyHost, String proxyPort, String proxyDomain, String proxyUsername, String proxyPassword) throws ManifoldCFException { this.URLbase = URLbase; this.clientId = clientId; @@ -123,6 +144,8 @@ public class JiraSession { }); localHttpClient.setRedirectStrategy(new DefaultRedirectStrategy()); + + // If authentication needed, set that if (clientId != null) { localHttpClient.getCredentialsProvider().setCredentials( @@ -130,6 +153,43 @@ public class JiraSession { new UsernamePasswordCredentials(clientId,clientSecret)); } + // If there's a proxy, set that too. + if (proxyHost != null && proxyHost.length() > 0) + { + + int proxyPortInt; + if (proxyPort != null && proxyPort.length() > 0) + { + try + { + proxyPortInt = Integer.parseInt(proxyPort); + } + catch (NumberFormatException e) + { + throw new ManifoldCFException("Bad number: "+e.getMessage(),e); + } + } + else + proxyPortInt = 8080; + + // Configure proxy authentication + if (proxyUsername != null && proxyUsername.length() > 0) + { + if (proxyPassword == null) + proxyPassword = ""; + if (proxyDomain == null) + proxyDomain = ""; + + localHttpClient.getCredentialsProvider().setCredentials( + new AuthScope(proxyHost, proxyPortInt), + new NTCredentials(proxyUsername, proxyPassword, currentHost, proxyDomain)); + } + + HttpHost proxy = new HttpHost(proxyHost, proxyPortInt); + + localHttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); + } + httpClient = localHttpClient; }