incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1325593 - /incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
Date Fri, 13 Apr 2012 02:54:13 GMT
Author: kwright
Date: Fri Apr 13 02:54:12 2012
New Revision: 1325593

URL: http://svn.apache.org/viewvc?rev=1325593&view=rev
Log:
Make sure each domain controller appears only once in list.

Modified:
    incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java

Modified: incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java?rev=1325593&r1=1325592&r2=1325593&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
(original)
+++ incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
Fri Apr 13 02:54:12 2012
@@ -590,66 +590,46 @@ public class ActiveDirectoryAuthority ex
       ConfigurationNode cn;
       String op;
       
+      Set<String> seenDomains = new HashSet<String>();
+      
       while (i < count)
       {
         op = variableContext.getParameter("dcrecord_op_"+i);
         if (op != null && op.equals("Insert"))
         {
           // Insert a new record right here
-          suffix = variableContext.getParameter("dcrecord_suffix");
-          domainControllerName = variableContext.getParameter("dcrecord_domaincontrollername");
-          userName = variableContext.getParameter("dcrecord_username");
-          password = variableContext.getParameter("dcrecord_password");
-          authentication = variableContext.getParameter("dcrecord_authentication");
-          userACLsUsername = variableContext.getParameter("dcrecord_userACLsUsername");
-          cn = new ConfigurationNode(ActiveDirectoryConfig.NODE_DOMAINCONTROLLER);
-          cn.setAttribute(ActiveDirectoryConfig.ATTR_SUFFIX,suffix);
-          cn.setAttribute(ActiveDirectoryConfig.ATTR_DOMAINCONTROLLER,domainControllerName);
-          cn.setAttribute(ActiveDirectoryConfig.ATTR_USERNAME,userName);
-          cn.setAttribute(ActiveDirectoryConfig.ATTR_PASSWORD,ManifoldCF.obfuscate(password));
-          cn.setAttribute(ActiveDirectoryConfig.ATTR_AUTHENTICATION,authentication);
-          cn.setAttribute(ActiveDirectoryConfig.ATTR_USERACLsUSERNAME,userACLsUsername);
-          parameters.addChild(parameters.getChildCount(),cn);
+          addDomainController(seenDomains,parameters,
+            variableContext.getParameter("dcrecord_suffix"),
+            variableContext.getParameter("dcrecord_domaincontrollername"),
+            variableContext.getParameter("dcrecord_username"),
+            variableContext.getParameter("dcrecord_password"),
+            variableContext.getParameter("dcrecord_authentication"),
+            variableContext.getParameter("dcrecord_userACLsUsername"));
         }
-        else if (op != null && op.equals("Delete"))
+        else if (op == null || !op.equals("Delete"))
         {
-          i++;
-          continue;
+          // Add this record back in
+          addDomainController(seenDomains,parameters,
+            variableContext.getParameter("dcrecord_suffix_"+i),
+            variableContext.getParameter("dcrecord_domaincontrollername_"+i),
+            variableContext.getParameter("dcrecord_username_"+i),
+            variableContext.getParameter("dcrecord_password_"+i),
+            variableContext.getParameter("dcrecord_authentication_"+i),
+            variableContext.getParameter("dcrecord_userACLsUsername_"+i));
         }
-        // Add this record back in
-        suffix = variableContext.getParameter("dcrecord_suffix_"+i);
-        domainControllerName = variableContext.getParameter("dcrecord_domaincontrollername_"+i);
-        userName = variableContext.getParameter("dcrecord_username_"+i);
-        password = variableContext.getParameter("dcrecord_password_"+i);
-        authentication = variableContext.getParameter("dcrecord_authentication_"+i);
-        userACLsUsername = variableContext.getParameter("dcrecord_userACLsUsername_"+i);
-        cn = new ConfigurationNode(ActiveDirectoryConfig.NODE_DOMAINCONTROLLER);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_SUFFIX,suffix);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_DOMAINCONTROLLER,domainControllerName);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_USERNAME,userName);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_PASSWORD,ManifoldCF.obfuscate(password));
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_AUTHENTICATION,authentication);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_USERACLsUSERNAME,userACLsUsername);
-        parameters.addChild(parameters.getChildCount(),cn);
+        i++;
       }
       op = variableContext.getParameter("dcrecord_op");
       if (op != null && op.equals("Add"))
       {
         // Insert a new record right here
-        suffix = variableContext.getParameter("dcrecord_suffix");
-        domainControllerName = variableContext.getParameter("dcrecord_domaincontrollername");
-        userName = variableContext.getParameter("dcrecord_username");
-        password = variableContext.getParameter("dcrecord_password");
-        authentication = variableContext.getParameter("dcrecord_authentication");
-        userACLsUsername = variableContext.getParameter("dcrecord_userACLsUsername");
-        cn = new ConfigurationNode(ActiveDirectoryConfig.NODE_DOMAINCONTROLLER);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_SUFFIX,suffix);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_DOMAINCONTROLLER,domainControllerName);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_USERNAME,userName);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_PASSWORD,ManifoldCF.obfuscate(password));
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_AUTHENTICATION,authentication);
-        cn.setAttribute(ActiveDirectoryConfig.ATTR_USERACLsUSERNAME,userACLsUsername);
-        parameters.addChild(parameters.getChildCount(),cn);
+        addDomainController(seenDomains,parameters,
+          variableContext.getParameter("dcrecord_suffix"),
+          variableContext.getParameter("dcrecord_domaincontrollername"),
+          variableContext.getParameter("dcrecord_username"),
+          variableContext.getParameter("dcrecord_password"),
+          variableContext.getParameter("dcrecord_authentication"),
+          variableContext.getParameter("dcrecord_userACLsUsername"));
       }
     }
     
@@ -663,6 +643,25 @@ public class ActiveDirectoryAuthority ex
     return null;
   }
   
+  protected static void addDomainController(Set<String> seenDomains, ConfigParams parameters,
+    String suffix, String domainControllerName, String userName, String password, String
authentication,
+    String userACLsUsername)
+    throws ManifoldCFException
+  {
+    if (!seenDomains.contains(domainControllerName))
+    {
+      ConfigurationNode cn = new ConfigurationNode(ActiveDirectoryConfig.NODE_DOMAINCONTROLLER);
+      cn.setAttribute(ActiveDirectoryConfig.ATTR_SUFFIX,suffix);
+      cn.setAttribute(ActiveDirectoryConfig.ATTR_DOMAINCONTROLLER,domainControllerName);
+      cn.setAttribute(ActiveDirectoryConfig.ATTR_USERNAME,userName);
+      cn.setAttribute(ActiveDirectoryConfig.ATTR_PASSWORD,ManifoldCF.obfuscate(password));
+      cn.setAttribute(ActiveDirectoryConfig.ATTR_AUTHENTICATION,authentication);
+      cn.setAttribute(ActiveDirectoryConfig.ATTR_USERACLsUSERNAME,userACLsUsername);
+      parameters.addChild(parameters.getChildCount(),cn);
+      seenDomains.add(domainControllerName);
+    }
+  }
+  
   /** View configuration.
   * This method is called in the body section of the authority connector's view configuration
page.  Its purpose is to present the connection information to the user.
   * The coder can presume that the HTML that is output from this configuration will be within
appropriate <html> and <body> tags.



Mime
View raw message