manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1523233 - in /manifoldcf/trunk: ./ connectors/wiki/ connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/ connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/ conne...
Date Sat, 14 Sep 2013 13:19:44 GMT
Author: kwright
Date: Sat Sep 14 13:19:44 2013
New Revision: 1523233

URL: http://svn.apache.org/r1523233
Log:
Fix for CONNECTORS-774.

Added:
    manifoldcf/trunk/connectors/wiki/connector/src/main/resources/
      - copied from r1523232, manifoldcf/branches/CONNECTORS-774/connectors/wiki/connector/src/main/resources/
Removed:
    manifoldcf/trunk/connectors/wiki/connector/src/main/resource/
Modified:
    manifoldcf/trunk/   (props changed)
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/wiki/   (props changed)
    manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
    manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
    manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_en_US.properties
    manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_ja_JP.properties

Propchange: manifoldcf/trunk/
------------------------------------------------------------------------------
  Merged /manifoldcf/branches/CONNECTORS-774:r1521768-1523232

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1523233&r1=1523232&r2=1523233&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Sat Sep 14 13:19:44 2013
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 1.4-dev =====================
 
+CONNECTORS-774: Add support for proxies to Wiki connector.
+(Karl Wright)
+
 CONNECTORS-773: Add support for proxies to Jira connectors.
 (Karl Wright)
 

Propchange: manifoldcf/trunk/connectors/wiki/
------------------------------------------------------------------------------
  Merged /manifoldcf/branches/CONNECTORS-774/connectors/wiki:r1521768-1523232

Modified: manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java?rev=1523233&r1=1523232&r2=1523233&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
(original)
+++ manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
Sat Sep 14 13:19:44 2013
@@ -49,6 +49,13 @@ public class WikiConfig
   public static final String PARAM_ACCESSUSER = "accessuser";
   public static final String PARAM_ACCESSPASSWORD = "accesspassword";
   
+  // Proxy info
+  public static final String PARAM_PROXYHOST = "Proxy host";
+  public static final String PARAM_PROXYPORT = "Proxy port";
+  public static final String PARAM_PROXYDOMAIN = "Proxy domain";
+  public static final String PARAM_PROXYUSERNAME = "Proxy username";
+  public static final String PARAM_PROXYPASSWORD = "Proxy password";
+
   // Document specification
 
   /** Namespace and title prefix */

Modified: manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1523233&r1=1523232&r2=1523233&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
(original)
+++ manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
Sat Sep 14 13:19:44 2013
@@ -35,6 +35,7 @@ import org.apache.manifoldcf.agents.comm
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.auth.NTCredentials;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.client.HttpClient;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
@@ -43,13 +44,14 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.HttpEntity;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.NameValuePair;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.EntityUtils;
@@ -57,6 +59,7 @@ import org.apache.http.message.BasicHead
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.conn.params.ConnRoutePNames;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
@@ -116,11 +119,35 @@ public class WikiConnector extends org.a
   protected String accessUser = null;
   protected String accessPassword = null;
   
+  // Proxy parameters
+  protected String proxyHost = null;
+  protected String proxyPort = null;
+  protected String proxyDomain = null;
+  protected String proxyUsername = null;
+  protected String proxyPassword = null;
+  
   /** Connection management */
   protected ClientConnectionManager connectionManager = null;
 
   protected HttpClient httpClient = null;
   
+  // 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.
   */
   public WikiConnector()
@@ -152,6 +179,7 @@ public class WikiConnector extends org.a
   public void connect(ConfigParams configParameters)
   {
     super.connect(configParameters);
+
     server = params.getParameter(WikiConfig.PARAM_SERVER);
     serverLogin = params.getParameter(WikiConfig.PARAM_LOGIN);
     serverPass = params.getObfuscatedParameter(WikiConfig.PARAM_PASSWORD);
@@ -159,6 +187,12 @@ public class WikiConnector extends org.a
     accessRealm = params.getParameter(WikiConfig.PARAM_ACCESSREALM);
     accessUser = params.getParameter(WikiConfig.PARAM_ACCESSUSER);
     accessPassword = params.getObfuscatedParameter(WikiConfig.PARAM_ACCESSPASSWORD);
+
+    proxyHost = params.getParameter(WikiConfig.PARAM_PROXYHOST);
+    proxyPort = params.getParameter(WikiConfig.PARAM_PROXYPORT);
+    proxyDomain = params.getParameter(WikiConfig.PARAM_PROXYDOMAIN);
+    proxyUsername = params.getParameter(WikiConfig.PARAM_PROXYUSERNAME);
+    proxyPassword = params.getObfuscatedParameter(WikiConfig.PARAM_PROXYPASSWORD);
   }
 
   protected void getSession()
@@ -230,6 +264,43 @@ public class WikiConnector extends org.a
           localHttpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
       }
 
+      // 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;
       
       loginToAPI();
@@ -718,6 +789,11 @@ public class WikiConnector extends org.a
     accessUser = null;
     accessPassword = null;
     accessRealm = null;
+    proxyHost = null;
+    proxyPort = null;
+    proxyDomain = null;
+    proxyUsername = null;
+    proxyPassword = null;
     baseURL = null;
     userAgent = null;
 
@@ -905,6 +981,7 @@ public class WikiConnector extends org.a
   {
     tabsArray.add(Messages.getString(locale,"WikiConnector.Server"));
     tabsArray.add(Messages.getString(locale,"WikiConnector.Email"));
+    tabsArray.add(Messages.getString(locale,"WikiConnector.Proxy"));
 
     out.print(
 "<script type=\"text/javascript\">\n"+
@@ -929,6 +1006,12 @@ public class WikiConnector extends org.a
 "    editconnection.serverpath.focus();\n"+
 "    return false;\n"+
 "  }\n"+
+"  if (editconnection.proxyport.value != \"\" && !isInteger(editconnection.proxyport.value))\n"+
+"  {\n"+
+"    alert(\""+Messages.getBodyJavascriptString(locale,"WikiConnector.ProxyPortMustBeAValidInteger")+"\");\n"+
+"    editconnection.proxyport.focus();\n"+
+"    return false;\n"+
+"  }\n"+
 "  return true;\n"+
 "}\n"+
 "\n"+
@@ -962,6 +1045,13 @@ public class WikiConnector extends org.a
 "    editconnection.serverpath.focus();\n"+
 "    return false;\n"+
 "  }\n"+
+"  if (editconnection.proxyport.value != \"\" && !isInteger(editconnection.proxyport.value))\n"+
+"  {\n"+
+"    alert(\""+Messages.getBodyJavascriptString(locale,"WikiConnector.ProxyPortMustBeAValidInteger")+"\");\n"+
+"    SelectTab(\""+Messages.getBodyJavascriptString(locale,"WikiConnector.Proxy")+"\");\n"+
+"    editconnection.proxyport.focus();\n"+
+"    return false;\n"+
+"  }\n"+
 "  return true;\n"+
 "}\n"+
 "\n"+
@@ -1036,6 +1126,71 @@ public class WikiConnector extends org.a
     else
       accessPassword = out.mapPasswordToKey(accessPassword);
 
+    // Proxy parameters
+    
+    String proxyHost = parameters.getParameter(WikiConfig.PARAM_PROXYHOST);
+    if (proxyHost == null)
+      proxyHost = "";
+    
+    String proxyPort = parameters.getParameter(WikiConfig.PARAM_PROXYPORT);
+    if (proxyPort == null)
+      proxyPort = "";
+    
+    String proxyDomain = parameters.getParameter(WikiConfig.PARAM_PROXYDOMAIN);
+    if (proxyDomain == null)
+      proxyDomain = "";
+    
+    String proxyUsername = parameters.getParameter(WikiConfig.PARAM_PROXYUSERNAME);
+    if (proxyUsername == null)
+      proxyUsername = "";
+    
+    String proxyPassword = parameters.getObfuscatedParameter(WikiConfig.PARAM_PROXYPASSWORD);
+    if (proxyPassword == null)
+      proxyPassword = "";
+    else
+      proxyPassword = out.mapPasswordToKey(proxyPassword);
+
+    // Proxy tab
+    if (tabName.equals(Messages.getString(locale,"WikiConnector.Proxy")))
+    {
+      out.print(
+"<table class=\"displaytable\">\n"+
+"  <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+"  <tr>\n"+
+"    <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"WikiConnector.ProxyHostColon")
+ "</nobr></td>\n"+
+"    <td class=\"value\"><input type=\"text\" size=\"32\" name=\"proxyhost\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyHost)+"\"/></td>\n"+
+"  </tr>\n"+
+"  <tr>\n"+
+"    <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"WikiConnector.ProxyPortColon")
+ "</nobr></td>\n"+
+"    <td class=\"value\"><input type=\"text\" size=\"5\" name=\"proxyport\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyPort)+"\"/></td>\n"+
+"  </tr>\n"+
+"  <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+"  <tr>\n"+
+"    <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"WikiConnector.ProxyDomainColon")
+ "</nobr></td>\n"+
+"    <td class=\"value\"><input type=\"text\" size=\"32\" name=\"proxydomain\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyDomain)+"\"/></td>\n"+
+"  </tr>\n"+
+"  <tr>\n"+
+"    <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"WikiConnector.ProxyUsernameColon")
+ "</nobr></td>\n"+
+"    <td class=\"value\"><input type=\"text\" size=\"16\" name=\"proxyusername\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyUsername)+"\"/></td>\n"+
+"  </tr>\n"+
+"  <tr>\n"+
+"    <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"WikiConnector.ProxyPasswordColon")
+ "</nobr></td>\n"+
+"    <td class=\"value\"><input type=\"password\" size=\"16\" name=\"proxypassword\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyPassword)+"\"/></td>\n"+
+"  </tr>\n"+
+"</table>\n"
+      );
+    }
+    else
+    {
+      out.print(
+"<input type=\"hidden\" name=\"proxyhost\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyHost)+"\"/>\n"+
+"<input type=\"hidden\" name=\"proxyport\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyPort)+"\"/>\n"+
+"<input type=\"hidden\" name=\"proxydomain\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyDomain)+"\"/>\n"+
+"<input type=\"hidden\" name=\"proxyusername\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyUsername)+"\"/>\n"+
+"<input type=\"hidden\" name=\"proxypassword\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(proxyPassword)+"\"/>\n"
+      );
+    }
+    
     // Email tab
     if (tabName.equals(Messages.getString(locale,"WikiConnector.Email")))
     {
@@ -1210,6 +1365,31 @@ public class WikiConnector extends org.a
       parameters.setParameter(WikiConfig.PARAM_ACCESSREALM, accessRealm);
     }
 
+    String proxyHost = variableContext.getParameter("proxyhost");
+    if (proxyHost != null) {
+      parameters.setParameter(WikiConfig.PARAM_PROXYHOST, proxyHost);
+    }
+    
+    String proxyPort = variableContext.getParameter("proxyport");
+    if (proxyPort != null) {
+      parameters.setParameter(WikiConfig.PARAM_PROXYPORT, proxyPort);
+    }
+
+    String proxyDomain = variableContext.getParameter("proxydomain");
+    if (proxyDomain != null) {
+      parameters.setParameter(WikiConfig.PARAM_PROXYDOMAIN, proxyDomain);
+    }
+    
+    String proxyUsername = variableContext.getParameter("proxyusername");
+    if (proxyUsername != null) {
+      parameters.setParameter(WikiConfig.PARAM_PROXYUSERNAME, proxyUsername);
+    }
+
+    String proxyPassword = variableContext.getParameter("proxypassword");
+    if (proxyPassword != null) {
+      parameters.setObfuscatedParameter(WikiConfig.PARAM_PROXYPASSWORD, variableContext.mapKeyToPassword(proxyPassword));
+    }
+
     return null;
   }
   

Modified: manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_en_US.properties?rev=1523233&r1=1523232&r2=1523233&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_en_US.properties
(original)
+++ manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_en_US.properties
Sat Sep 14 13:19:44 2013
@@ -14,6 +14,9 @@
 # limitations under the License.
 
 WikiConnector.Server=Server
+WikiConnector.Email=Email
+WikiConnector.Proxy=Proxy
+
 WikiConnector.Protocol=Protocol:
 WikiConnector.ServerName=Server name:
 WikiConnector.Port=Port:
@@ -23,7 +26,6 @@ WikiConnector.ServerPassword=API passwor
 WikiConnector.ServerDomain=API domain:
 WikiConnector.NamespaceAndTitles=Namespace and Titles
 WikiConnector.NamespaceAndTitles2=Namespaces and titles:
-WikiConnector.Email=Email
 WikiConnector.Namespace=Namespace
 WikiConnector.TitlePrefix=Title prefix
 WikiConnector.Security=Security
@@ -51,3 +53,10 @@ WikiConnector.AccessUser=Basic auth user
 WikiConnector.AccessPassword=Basic auth password:
 WikiConnector.AccessRealm=Basic auth realm:
 
+WikiConnector.ProxyHostColon=Proxy host:
+WikiConnector.ProxyPortColon=Proxy port:
+WikiConnector.ProxyDomainColon=Proxy domain:
+WikiConnector.ProxyUsernameColon=Proxy user name:
+WikiConnector.ProxyPasswordColon=Proxy password:
+
+WikiConnector.ProxyPortMustBeAValidInteger=Proxy port must be a valid integer

Modified: manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_ja_JP.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_ja_JP.properties?rev=1523233&r1=1523232&r2=1523233&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_ja_JP.properties
(original)
+++ manifoldcf/trunk/connectors/wiki/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/wiki/common_ja_JP.properties
Sat Sep 14 13:19:44 2013
@@ -14,6 +14,9 @@
 # limitations under the License.
 
 WikiConnector.Server=サーバ
+WikiConnector.Email=メール
+WikiConnector.Proxy=Proxy
+
 WikiConnector.Protocol=プロトコル:
 WikiConnector.ServerName=サーバ名:
 WikiConnector.Port=ポート:
@@ -23,7 +26,6 @@ WikiConnector.ServerPassword=API passwor
 WikiConnector.ServerDomain=API domain:
 WikiConnector.NamespaceAndTitles=名前空間と題名
 WikiConnector.NamespaceAndTitles2=名前空間と題名:
-WikiConnector.Email=メール
 WikiConnector.Namespace=名前空間
 WikiConnector.TitlePrefix=題名接先頭辞
 WikiConnector.Security=Security
@@ -51,3 +53,10 @@ WikiConnector.AccessUser=Basic auth user
 WikiConnector.AccessPassword=Basic auth password:
 WikiConnector.AccessRealm=Basic auth realm:
 
+WikiConnector.ProxyHostColon=Proxy host:
+WikiConnector.ProxyPortColon=Proxy port:
+WikiConnector.ProxyDomainColon=Proxy domain:
+WikiConnector.ProxyUsernameColon=Proxy user name:
+WikiConnector.ProxyPasswordColon=Proxy password:
+
+WikiConnector.ProxyPortMustBeAValidInteger=Proxy port must be a valid integer



Mime
View raw message