Upgrade JCIFS connector to jcifs-ng

git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/branches/CONNECTORS-1498@1857777 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/connectors/jcifs/build.xml b/connectors/jcifs/build.xml
index 8447573..376097d 100644
--- a/connectors/jcifs/build.xml
+++ b/connectors/jcifs/build.xml
@@ -30,17 +30,21 @@
 
     <import file="${mcf-dist}/connector-build.xml"/>
 
-    <property name="jcifs.version" value="1.3.18.3"/>
+    <property name="jcifs-ng.version" value="2.1.2"/>
+    
+    <!--groupId>eu.agno3.jcifs</groupId>
+    <artifactId>jcifs-ng</artifactId>
+    <version>2.1.2</version/-->
     
     <target name="calculate-condition">
-        <available file="lib-proprietary/jcifs-${jcifs.version}.jar" property="jcifsStatus"/>
+        <available file="lib-proprietary/jcifs-ng-${jcifs-ng.version}.jar" property="jcifsStatus"/>
         <condition property="build-present">
             <isset property="jcifsStatus"/>
         </condition>
     </target>
 
     <target name="precompile-warn" depends="calculate-condition" unless="build-present">
-        <echo message="JCifs Connector cannot be built without jcifs.jar"/>
+        <echo message="JCifs Connector cannot be built without jcifs-ng.jar"/>
     </target>
 
     <path id="connector-classpath">
@@ -57,10 +61,10 @@
 
     <target name="download-jcifs">
         <antcall target="download-via-maven">
-            <param name="project-path" value="org/codelibs"/>
-            <param name="artifact-version" value="${jcifs.version}"/>
+            <param name="project-path" value="eu/agno3/jcifs"/>
+            <param name="artifact-version" value="${jcifs-ng.version}"/>
             <param name="target" value="lib-proprietary"/>
-            <param name="artifact-name" value="jcifs"/>
+            <param name="artifact-name" value="jcifs-ng"/>
             <param name="artifact-type" value="jar"/>
         </antcall>
     </target>
diff --git a/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java b/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
index f1a50b9..7a4a4a1 100644
--- a/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
+++ b/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
@@ -16,11 +16,12 @@
 */
 package org.apache.manifoldcf.crawler.connectors.sharedrive;
 
-import jcifs.smb.ACE;
-import jcifs.smb.NtlmPasswordAuthentication;
+import jcifs.ACE;
+import jcifs.smb.NtlmPasswordAuthenticator;
 import jcifs.smb.SmbException;
 import jcifs.smb.SmbFile;
 import jcifs.smb.SmbFileFilter;
+import jcifs.context.SingletonContext;
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 import org.apache.manifoldcf.connectorcommon.extmimemap.ExtensionMimeMap;
@@ -127,7 +128,7 @@
   private boolean useSIDs = true;
   private String binName = null;
   
-  private NtlmPasswordAuthentication pa;
+  private NtlmPasswordAuthenticator pa;
   
   /** Deny access token for default authority */
   private final static String defaultAuthorityDenyToken = GLOBAL_DENY_TOKEN;
@@ -182,8 +183,8 @@
       try
       {
         // use NtlmPasswordAuthentication so that we can reuse credential for DFS support
-        pa = new NtlmPasswordAuthentication(domain,username,password);
-        SmbFile smbconnection = new SmbFile("smb://" + server + "/",pa);
+        pa = new NtlmPasswordAuthenticator(domain,username,password);
+        SmbFile smbconnection = new SmbFile("smb://" + server + "/",SingletonContext.getInstance().withCredentials(pa));
         smbconnectionPath = getFileCanonicalPath(smbconnection);
       }
       catch (MalformedURLException e)
@@ -594,7 +595,7 @@
       
       try
       {
-        file = new SmbFile(documentIdentifier,pa);
+        file = new SmbFile(documentIdentifier,SingletonContext.getInstance().withCredentials(pa));
         fileExists = fileExists(file);
 
         // File has to exist AND have a non-null canonical path to be readable.  If the canonical path is
@@ -625,7 +626,7 @@
                 // It's a file of acceptable length.
                 // The ability to get ACLs, list files, and an inputstream under DFS all work now.
                 // The SmbFile for parentFolder acls.
-                SmbFile parentFolder = new SmbFile(file.getParent(),pa);
+                SmbFile parentFolder = new SmbFile(file.getParent(),SingletonContext.getInstance().withCredentials(pa));
 
                 // Compute the security information
                 String[] modelArray = new String[0];
@@ -1401,7 +1402,7 @@
     SmbFile server = null;
     try
     {
-      server = new SmbFile(serverURI,pa);
+      server = new SmbFile(serverURI,SingletonContext.getInstance().withCredentials(pa));
     }
     catch (MalformedURLException e1)
     {
@@ -2147,7 +2148,7 @@
   {
     String smburi = smbconnectionPath;
     String uri = smburi + path + "/";
-    return getFileCanonicalPath(new SmbFile(uri,pa));
+    return getFileCanonicalPath(new SmbFile(uri,SingletonContext.getInstance().withCredentials(pa)));
   }
 
   // These methods allow me to experiment with cluster-mandated error handling on an entirely local level.  They correspond to individual SMBFile methods.
@@ -4624,7 +4625,7 @@
     SmbFile server = null;
     try
     {
-      server = new SmbFile(serverURI,pa);
+      server = new SmbFile(serverURI,SingletonContext.getInstance().withCredentials(pa));
     }
     catch (MalformedURLException e1)
     {
@@ -4665,7 +4666,7 @@
     SmbFile currentDirectory = null;
     try
     {
-      currentDirectory = new SmbFile(uri,pa);
+      currentDirectory = new SmbFile(uri,SingletonContext.getInstance().withCredentials(pa));
     }
     catch (MalformedURLException e1)
     {
@@ -4734,7 +4735,7 @@
     SmbFile currentDirectory = null;
     try
     {
-      currentDirectory = new SmbFile(uri,pa);
+      currentDirectory = new SmbFile(uri,SingletonContext.getInstance().withCredentials(pa));
     }
     catch (MalformedURLException e1)
     {
diff --git a/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveHelpers.java b/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveHelpers.java
index d865ba0..abf9208 100644
--- a/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveHelpers.java
+++ b/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveHelpers.java
@@ -31,11 +31,12 @@
 import java.util.HashMap;
 import java.util.Iterator;
 
-import jcifs.smb.ACE;
-import jcifs.smb.NtlmPasswordAuthentication;
+import jcifs.ACE;
+import jcifs.smb.NtlmPasswordAuthenticator;
 import jcifs.smb.SmbException;
 import jcifs.smb.SmbFile;
 import jcifs.smb.SmbFileFilter;
+import jcifs.context.SingletonContext;
 
 /** This class contains test code that is useful for performing test operations
 using JCifs from the appliance.  Basic operations are: addDocument, deleteDocument,
@@ -45,7 +46,7 @@
 {
   public static final String _rcsid = "@(#)$Id: SharedDriveHelpers.java 988245 2010-08-23 18:39:35Z kwright $";
 
-  private NtlmPasswordAuthentication pa;
+  private NtlmPasswordAuthenticator pa;
   private SmbFile smbconnection;
 
   /** Construct the helper and initialize the connection.
@@ -60,8 +61,8 @@
     {
       // make the smb connection to the server
       // use NtlmPasswordAuthentication so that we can reuse credential for DFS support
-      pa = new NtlmPasswordAuthentication(userName + ":" + password);
-      smbconnection = new SmbFile("smb://" + serverName + "/",pa);
+      pa = new NtlmPasswordAuthenticator(userName, password);
+      smbconnection = new SmbFile("smb://" + serverName + "/",SingletonContext.getInstance().withCredentials(pa));
     }
     catch (MalformedURLException e)
     {
@@ -90,7 +91,7 @@
     try
     {
       String identifier = mapToIdentifier(targetPath);
-      SmbFile file = new SmbFile(identifier,pa);
+      SmbFile file = new SmbFile(identifier,SingletonContext.getInstance().withCredentials(pa));
       if (file.exists())
         return targetPath;
       return "";
@@ -113,7 +114,7 @@
     try
     {
       String identifier = mapToIdentifier(targetPath);
-      SmbFile file = new SmbFile(identifier,pa);
+      SmbFile file = new SmbFile(identifier,SingletonContext.getInstance().withCredentials(pa));
       // Open source file for read
       InputStream is = new FileInputStream(sourceFile);
       try
@@ -122,7 +123,7 @@
         if (!file.exists())
         {
           file.createNewFile();
-          file = new SmbFile(identifier,pa);
+          file = new SmbFile(identifier,SingletonContext.getInstance().withCredentials(pa));
         }
         OutputStream os = file.getOutputStream();
         try
@@ -164,7 +165,7 @@
     try
     {
       String identifier = mapToIdentifier(targetPath);
-      SmbFile file = new SmbFile(identifier,pa);
+      SmbFile file = new SmbFile(identifier,SingletonContext.getInstance().withCredentials(pa));
       file.delete();
     }
     catch (IOException e)
@@ -202,7 +203,7 @@
   {
     String smburi = smbconnection.getCanonicalPath();
     String uri = smburi + path + "/";
-    return new SmbFile(uri,pa).getCanonicalPath();
+    return new SmbFile(uri,SingletonContext.getInstance().withCredentials(pa)).getCanonicalPath();
   }
 
 }