manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1325200 - in /incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory: ActiveDirectoryAuthority.java ActiveDirectoryConfig.java
Date Thu, 12 Apr 2012 10:44:23 GMT
Author: kwright
Date: Thu Apr 12 10:44:22 2012
New Revision: 1325200

URL: http://svn.apache.org/viewvc?rev=1325200&view=rev
Log:
Set up canonical form for multiple domain controllers.

Modified:
    incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
    incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryConfig.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=1325200&r1=1325199&r2=1325200&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
Thu Apr 12 10:44:22 2012
@@ -369,36 +369,89 @@ public class ActiveDirectoryAuthority ex
   }
   
   protected static void fillInDomainControllerTab(Map<String,Object> velocityContext,
ConfigParams parameters)
+    throws ManifoldCFException
   {
-    String domainControllerName = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_DOMAINCONTROLLER);
+    String domainControllerName = parameters.getParameter(ActiveDirectoryConfig.PARAM_DOMAINCONTROLLER);
+    String userName = parameters.getParameter(ActiveDirectoryConfig.PARAM_USERNAME);
+    String password = parameters.getObfuscatedParameter(ActiveDirectoryConfig.PARAM_PASSWORD);
+    String authentication = parameters.getParameter(ActiveDirectoryConfig.PARAM_AUTHENTICATION);
+    String userACLsUsername = parameters.getParameter(ActiveDirectoryConfig.PARAM_USERACLsUSERNAME);
+    List<Map<String,String>> domainControllers = new ArrayList<Map<String,String>>();
+    
+    // Backwards compatibility: if domain controller parameter is set, create an entry in
the map.
+    if (domainControllerName != null)
+    {
+      domainControllers.add(createDomainControllerMap("",domainControllerName,userName,password,authentication,userACLsUsername));
+    }
+    else
+    {
+      // Go through nodes looking for DC nodes
+      int i = 0;
+      while (i < parameters.getChildCount())
+      {
+        ConfigurationNode cn = parameters.getChild(i++);
+        if (cn.getType().equals(ActiveDirectoryConfig.NODE_DOMAINCONTROLLER))
+        {
+          // Grab the info
+          String dcSuffix = cn.getAttributeValue(ActiveDirectoryConfig.ATTR_SUFFIX);
+          String dcDomainController = cn.getAttributeValue(ActiveDirectoryConfig.ATTR_DOMAINCONTROLLER);
+          String dcUserName = cn.getAttributeValue(ActiveDirectoryConfig.ATTR_USERNAME);
+          String dcPassword = cn.getAttributeValue(ActiveDirectoryConfig.ATTR_PASSWORD);
+          if (dcPassword != null)
+            dcPassword = ManifoldCF.deobfuscate(dcPassword);
+          String dcAuthentication = cn.getAttributeValue(ActiveDirectoryConfig.ATTR_AUTHENTICATION);
+          String dcUserACLsUsername = cn.getAttributeValue(ActiveDirectoryConfig.ATTR_USERACLsUSERNAME);
+          domainControllers.add(createDomainControllerMap(dcSuffix,dcDomainController,dcUserName,dcPassword,dcAuthentication,dcUserACLsUsername));
+        }
+      }
+    }
+    velocityContext.put("DOMAINCONTROLLERS",domainControllers);
+    
     if (domainControllerName == null)
       domainControllerName = "";
-    velocityContext.put("DOMAINCONTROLLER",domainControllerName);
-    String userName = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_USERNAME);
     if (userName == null)
       userName = "";
-    velocityContext.put("USERNAME",userName);
-    String password = parameters.getObfuscatedParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_PASSWORD);
     if (password == null)
       password = "";
-    velocityContext.put("PASSWORD",password);
-    String authentication = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_AUTHENTICATION);
     if (authentication == null)
     	authentication = "DIGEST-MD5 GSSAPI";
-    velocityContext.put("AUTHENTICATION",authentication);
-    String userACLsUsername = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_USERACLsUSERNAME);
     if (userACLsUsername == null)
     	userACLsUsername = "sAMAccountName";
+    
+    // Until I can change the template too
     velocityContext.put("USERACLsUSERNAME",userACLsUsername);
+    velocityContext.put("AUTHENTICATION",authentication);
+    velocityContext.put("PASSWORD",password);
+    velocityContext.put("USERNAME",userName);
+    velocityContext.put("DOMAINCONTROLLER",domainControllerName);
+  }
+
+  protected static Map<String,String> createDomainControllerMap(String suffix, String
domainControllerName,
+    String userName, String password, String authentication, String userACLsUsername)
+  {
+    Map<String,String> defaultMap = new HashMap<String,String>();
+    if (suffix != null)
+      defaultMap.put("SUFFIX",suffix);
+    if (domainControllerName != null)
+      defaultMap.put("DOMAINCONTROLLER",domainControllerName);
+    if (userName != null)
+      defaultMap.put("USERNAME",userName);
+    if (password != null)
+      defaultMap.put("PASSWORD",password);
+    if (authentication != null)
+      defaultMap.put("AUTHENTICATION",authentication);
+    if (userACLsUsername != null)
+      defaultMap.put("USERACLsUSERNAME",userACLsUsername);
+    return defaultMap;
   }
   
   protected static void fillInCacheTab(Map<String,Object> velocityContext, ConfigParams
parameters)
   {
-    String cacheLifetime = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_CACHELIFETIME);
+    String cacheLifetime = parameters.getParameter(ActiveDirectoryConfig.PARAM_CACHELIFETIME);
     if (cacheLifetime == null)
       cacheLifetime = "1";
     velocityContext.put("CACHELIFETIME",cacheLifetime);
-    String cacheLRUsize = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_CACHELRUSIZE);
+    String cacheLRUsize = parameters.getParameter(ActiveDirectoryConfig.PARAM_CACHELRUSIZE);
     if (cacheLRUsize == null)
       cacheLRUsize = "1000";
     velocityContext.put("CACHELRUSIZE",cacheLRUsize);
@@ -419,25 +472,25 @@ public class ActiveDirectoryAuthority ex
   {
     String domainControllerName = variableContext.getParameter("domaincontrollername");
     if (domainControllerName != null)
-      parameters.setParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_DOMAINCONTROLLER,domainControllerName);
+      parameters.setParameter(ActiveDirectoryConfig.PARAM_DOMAINCONTROLLER,domainControllerName);
     String userName = variableContext.getParameter("username");
     if (userName != null)
-      parameters.setParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_USERNAME,userName);
+      parameters.setParameter(ActiveDirectoryConfig.PARAM_USERNAME,userName);
     String password = variableContext.getParameter("password");
     if (password != null)
-      parameters.setObfuscatedParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_PASSWORD,password);
+      parameters.setObfuscatedParameter(ActiveDirectoryConfig.PARAM_PASSWORD,password);
     String authentication = variableContext.getParameter("authentication");
     if (authentication != null)
-      parameters.setParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_AUTHENTICATION,authentication);
+      parameters.setParameter(ActiveDirectoryConfig.PARAM_AUTHENTICATION,authentication);
     String userACLsUsername = variableContext.getParameter("userACLsUsername");
     if (userACLsUsername != null)
-      parameters.setParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_USERACLsUSERNAME,userACLsUsername);
+      parameters.setParameter(ActiveDirectoryConfig.PARAM_USERACLsUSERNAME,userACLsUsername);
     String cacheLifetime = variableContext.getParameter("cachelifetime");
     if (cacheLifetime != null)
-      parameters.setParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_CACHELIFETIME,cacheLifetime);
+      parameters.setParameter(ActiveDirectoryConfig.PARAM_CACHELIFETIME,cacheLifetime);
     String cacheLRUsize = variableContext.getParameter("cachelrusize");
     if (cacheLRUsize != null)
-      parameters.setParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_CACHELRUSIZE,cacheLRUsize);
+      parameters.setParameter(ActiveDirectoryConfig.PARAM_CACHELRUSIZE,cacheLRUsize);
     
     return null;
   }

Modified: incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryConfig.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryConfig.java?rev=1325200&r1=1325199&r2=1325200&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryConfig.java
(original)
+++ incubator/lcf/branches/CONNECTORS-460/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryConfig.java
Thu Apr 12 10:44:22 2012
@@ -19,7 +19,7 @@
 package org.apache.manifoldcf.authorities.authorities.activedirectory;
 
 
-/** Parameters and output data for MetaCarta GTS output connector.
+/** Parameters and output data for Active Directory authority.
 */
 public class ActiveDirectoryConfig
 {
@@ -42,4 +42,22 @@ public class ActiveDirectoryConfig
   /** Cache LRU size */
   public static final String PARAM_CACHELRUSIZE = "Cache LRU size";
 
+  /** Domain controller node */
+  public static final String NODE_DOMAINCONTROLLER = "domaincontroller";
+  
+  // Domain controller node attributes
+  
+  /** Domain suffix */
+  public static final String ATTR_SUFFIX = "suffix";
+  /** DC server name */
+  public static final String ATTR_DOMAINCONTROLLER = "domaincontroller";
+  /** DC user name */
+  public static final String ATTR_USERNAME = "username";
+  /** DC password */
+  public static final String ATTR_PASSWORD = "password";
+  /** DC authentication method */
+  public static final String ATTR_AUTHENTICATION = "authentication";
+  /** DC user acls username attribute name */
+  public static final String ATTR_USERACLsUSERNAME = "useraclsusername";
+
 }



Mime
View raw message