package edu.tamu.tcat.account.apacheds;

import java.util.Properties;

import edu.tamu.tcat.account.apacheds.internal.LdapHelperAdImpl;

public class LdapHelperADFactory
{

   private static final String DEFAULT_SEARCH_OU = "edu.tamu.tcat.ldap.ad.defaultSearchOu";
   private static final String USE_SSL = "edu.tamu.tcat.ldap.ad.useSsl";
   private static final String USER_PASSWORD = "edu.tamu.tcat.ldap.ad.userPassword";
   private static final String USER_DN = "edu.tamu.tcat.ldap.ad.userDn";
   private static final String PORT = "edu.tamu.tcat.ldap.ad.port";
   private static final String IP = "edu.tamu.tcat.ldap.ad.ip";

   public LdapHelperReader getReader(String ip, int port, String userDn, String userPassword, boolean useSsl, String defaultSearchOu){
      return getHelper(ip, port, userDn, userPassword, useSsl, defaultSearchOu);
   }

   public LdapHelperReader getReader(Properties props){
      return getHelper(props);
   }

   public LdapHelperMutator getWriter(String ip, int port, String userDn, String userPassword, boolean useSsl, String defaultSearchOu){
      return getHelper(ip, port, userDn, userPassword, useSsl, defaultSearchOu);
   }
   
   public LdapHelperMutator getWriter(Properties props){
      return getHelper(props);
   }
   
   private LdapHelperAdImpl getHelper(Properties props)
   {
      return getHelper(props.getProperty(IP), 
            Integer.parseInt(props.getProperty(PORT)),
            props.getProperty(USER_DN), 
            props.getProperty(USER_PASSWORD), 
            Boolean.parseBoolean(props.getProperty(USE_SSL)), 
            props.getProperty(DEFAULT_SEARCH_OU));
   }
   
   private LdapHelperAdImpl getHelper(String ip, int port, String userDn, String userPassword, boolean useSsl, String defaultSearchOu){
      LdapHelperAdImpl helper = new LdapHelperAdImpl();
      helper.configure(ip, port, userDn, userPassword, useSsl, defaultSearchOu);
      helper.init();
      return helper;
   }
   
   
}

@@ -30,24 +30,46 @@
 .apacheds;%0A%0A
+import java.util.Map;%0A
 import java.
@@ -85,16 +85,16 @@
 erties;%0A
-
 %0Aimport 
@@ -953,24 +953,124 @@
 props);%0A   %7D
+%0A   %0A   public LdapHelperReader getReader(Map%3CString, ?%3E props)%7B%0A      return getHelper(props);%0A   %7D
 %0A%0A   public 
@@ -1273,36 +1273,33 @@
 SearchOu);%0A   %7D%0A
-   
 %0A
+
    public LdapHe
@@ -1371,32 +1371,130 @@
 rops);%0A   %7D%0A   %0A
+   public LdapHelperMutator getWriter(Map%3CString, ?%3E props)%7B%0A      return getHelper(props);%0A   %7D%0A%0A
    private LdapH
@@ -1787,24 +1787,24 @@
 USE_SSL)), %0A
-
             
@@ -1847,24 +1847,364 @@
 );%0A   %7D%0A   %0A
+   private LdapHelperAdImpl getHelper(Map%3CString, ?%3E props)%0A   %7B%0A      return getHelper((String)props.get(IP), %0A            (Integer)props.get(PORT),%0A            (String)props.get(USER_DN), %0A            (String)props.get(USER_PASSWORD), %0A            (Boolean)props.get(USE_SSL), %0A            (String)props.get(DEFAULT_SEARCH_OU));%0A   %7D%0A   %0A
    private L

add Map argument helper constructor to facilitate construction from json encoded properties