manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
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 GMT
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;
   }
 



Mime
View raw message