cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject [1/3] Add LDAP Plugin Implementation
Date Thu, 11 Jul 2013 14:04:33 GMT
Updated Branches:
  refs/heads/ldapplugin 92884d1aa -> a90affe4b


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
new file mode 100644
index 0000000..ece8d4b
--- /dev/null
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
@@ -0,0 +1,14 @@
+package groovy.org.apache.cloudstack.ldap
+
+import org.apache.cloudstack.ldap.NoSuchLdapUserException;
+
+class NoSuchLdapUserExceptionSpec extends spock.lang.Specification {
+    def "Test that the username is correctly set within the No such LDAP user exception object"() {
+        given: "You have created an No such LDAP user exception object with the username set"
+        def exception = new NoSuchLdapUserException(username)
+        expect: "The username is equal to the given data source"
+        exception.getUsername() == username
+        where: "The username is set to "
+        username << ["", null, "rmurphy"]
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 090d9c2..e667c69 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -78,7 +78,6 @@ import org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse;
 import org.apache.cloudstack.api.response.LBHealthCheckResponse;
 import org.apache.cloudstack.api.response.LBStickinessPolicyResponse;
 import org.apache.cloudstack.api.response.LBStickinessResponse;
-import org.apache.cloudstack.api.response.LDAPConfigResponse;
 import org.apache.cloudstack.api.response.LoadBalancerResponse;
 import org.apache.cloudstack.api.response.NetworkACLItemResponse;
 import org.apache.cloudstack.api.response.NetworkACLResponse;
@@ -2807,20 +2806,6 @@ public class ApiResponseHelper implements ResponseGenerator {
     }
 
     @Override
-    public LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String searchBase,
-            String bindDN) {
-        LDAPConfigResponse lr = new LDAPConfigResponse();
-        lr.setHostname(hostname);
-        lr.setPort(port.toString());
-        lr.setUseSSL(useSSL.toString());
-        lr.setQueryFilter(queryFilter);
-        lr.setBindDN(bindDN);
-        lr.setSearchBase(searchBase);
-        lr.setObjectName("ldapconfig");
-        return lr;
-    }
-
-    @Override
     public StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result) {
         StorageNetworkIpRangeResponse response = new StorageNetworkIpRangeResponse();
         response.setUuid(result.getUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index d3ed718..d47a2a5 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation (ASF) under one
+//Licensed to the Apache Software Foundation (ASF) under one
 // or more contributor license agreements.  See the NOTICE file
 // distributed with this work for additional information
 // regarding copyright ownership.  The ASF licenses this file
@@ -422,6 +422,15 @@ public enum Config {
     // object store
     S3EnableRRS("Advanced", ManagementServer.class, Boolean.class, "s3.rrs.enabled", "false", "enable s3 reduced redundancy storage", null),
 
+    // Ldap
+    LdapBasedn("Advanced", ManagementServer.class, String.class, "ldap.basedn", null, "Sets the basedn for LDAP", null),
+    LdapBindPassword("Advanced", ManagementServer.class, String.class, "ldap.bind.password", null, "Sets the bind password for LDAP", null),
+    LdapBindPrincipal("Advanced", ManagementServer.class, String.class, "ldap.bind.principal", null, "Sets the bind principal for LDAP", null),
+    LdapEmailAttribute("Advanced", ManagementServer.class, String.class, "ldap.email.attribute", "mail", "Sets the email attribute used within LDAP", null),
+    LdapRealnameAttribute("Advanced", ManagementServer.class, String.class, "ldap.realname.attribute", "cn", "Sets the realname attribute used within LDAP", null),
+    LdapUsernameAttribute("Advanced", ManagementServer.class, String.class, "ldap.username.attribute", "uid", "Sets the username attribute used within LDAP", null),
+    LdapUserObject("Advanced", ManagementServer.class, String.class, "ldap.user.object", "inetOrgPerson", "Sets the object type of users within LDAP", null),
+
 	// VMSnapshots
     VMSnapshotMax("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a vm", null),
     VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "1800", "In second, timeout for create vm snapshot", null),
@@ -434,7 +443,7 @@ public enum Config {
     InternalLbVmServiceOfferingId("Advanced", ManagementServer.class, String.class, "internallbvm.service.offering", null, "Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used", null),
     ExecuteInSequence("Advanced", ManagementServer.class, Boolean.class, "execute.in.sequence.hypervisor.commands", "false", "If set to true, StartCommand, StopCommand, CopyVolumeCommand, CreateCommand will be synchronized on the agent side." +
     		" If set to false, these commands become asynchronous. Default value is false.", null),
-    ExecuteInSequenceNetworkElementCommands("Advanced", NetworkManager.class, Boolean.class, "execute.in.sequence.network.element.commands", "false", "If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side." + 
+    ExecuteInSequenceNetworkElementCommands("Advanced", NetworkManager.class, Boolean.class, "execute.in.sequence.network.element.commands", "false", "If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side." +
             " If set to false, these commands become asynchronous. Default value is false.", null);
 	
 	private final String _category;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 8d8b126..8d73102 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -40,10 +40,7 @@ import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
 
 import org.apache.cloudstack.acl.SecurityChecker;
-import org.apache.cloudstack.api.ApiConstants.LDAPParams;
 import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
 import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
 import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
 import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
@@ -1551,175 +1548,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
     @Override
     @DB
-    public boolean removeLDAP(LDAPRemoveCmd cmd) {
-        _configDao.expunge(LDAPParams.hostname.toString());
-        _configDao.expunge(LDAPParams.port.toString());
-        _configDao.expunge(LDAPParams.queryfilter.toString());
-        _configDao.expunge(LDAPParams.searchbase.toString());
-        _configDao.expunge(LDAPParams.usessl.toString());
-        _configDao.expunge(LDAPParams.dn.toString());
-        _configDao.expunge(LDAPParams.passwd.toString());
-        _configDao.expunge(LDAPParams.truststore.toString());
-        _configDao.expunge(LDAPParams.truststorepass.toString());
-        return true;
-    }
-
-    @Override
-    @DB
-    public LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd) {
-        String hostname = _configDao.getValue(LDAPParams.hostname.toString());
-        cmd.setHostname(hostname == null ? "" : hostname);
-        String port = _configDao.getValue(LDAPParams.port.toString());
-        cmd.setPort(port == null ? 0 : Integer.valueOf(port));
-        String queryFilter = _configDao.getValue(LDAPParams.queryfilter.toString());
-        cmd.setQueryFilter(queryFilter == null ? "" : queryFilter);
-        String searchBase = _configDao.getValue(LDAPParams.searchbase.toString());
-        cmd.setSearchBase(searchBase == null ? "" : searchBase);
-        String useSSL = _configDao.getValue(LDAPParams.usessl.toString());
-        cmd.setUseSSL(useSSL == null ? Boolean.FALSE : Boolean.valueOf(useSSL));
-        String binddn = _configDao.getValue(LDAPParams.dn.toString());
-        cmd.setBindDN(binddn == null ? "" : binddn);
-        String truststore = _configDao.getValue(LDAPParams.truststore.toString());
-        cmd.setTrustStore(truststore == null ? "" : truststore);
-        return cmd;
-    }
-
-    @Override
-    @DB
-    public boolean updateLDAP(LDAPConfigCmd cmd) {
-        try {
-            // set the ldap details in the zone details table with a zone id of
-            // -12
-            String hostname = cmd.getHostname();
-            Integer port = cmd.getPort();
-            String queryFilter = cmd.getQueryFilter();
-            String searchBase = cmd.getSearchBase();
-            Boolean useSSL = cmd.getUseSSL();
-            String bindDN = cmd.getBindDN();
-            String bindPasswd = cmd.getBindPassword();
-            String trustStore = cmd.getTrustStore();
-            String trustStorePassword = cmd.getTrustStorePassword();
-
-            if (bindDN != null && bindPasswd == null) {
-                throw new InvalidParameterValueException(
-                        "If you specify a bind name then you need to provide bind password too.");
-            }
-
-            // check query filter if it contains valid substitution
-            if (!queryFilter.contains("%u") && !queryFilter.contains("%n") && !queryFilter.contains("%e")) {
-                throw new InvalidParameterValueException(
-                        "QueryFilter should contain at least one of the substitutions: %u, %n or %e: " + queryFilter);
-            }
-
-            // check if the info is correct
-            Hashtable<String, String> env = new Hashtable<String, String>(11);
-            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
-            String protocol = "ldap://";
-            if (useSSL) {
-                env.put(Context.SECURITY_PROTOCOL, "ssl");
-                protocol = "ldaps://";
-                if (trustStore == null || trustStorePassword == null) {
-                    throw new InvalidParameterValueException(
-                            "If you plan to use SSL then you need to configure the trust store.");
-                }
-                System.setProperty("javax.net.ssl.trustStore", trustStore);
-                System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
-            }
-            env.put(Context.PROVIDER_URL, protocol + hostname + ":" + port);
-            if (bindDN != null && bindPasswd != null) {
-                env.put(Context.SECURITY_AUTHENTICATION, "simple");
-                env.put(Context.SECURITY_PRINCIPAL, bindDN);
-                env.put(Context.SECURITY_CREDENTIALS, bindPasswd);
-            }
-            // Create the initial context
-            DirContext ctx = new InitialDirContext(env);
-            ctx.close();
-
-            // store the result in DB Configuration
-            ConfigurationVO cvo = _configDao.findByName(LDAPParams.hostname.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.hostname.toString(),
-                        null, "Hostname or ip address of the ldap server eg: my.ldap.com");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(hostname));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.port.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.port.toString(), null,
-                        "Specify the LDAP port if required, default is 389");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(port.toString()));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.queryfilter.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.queryfilter.toString(),
-                        null,
-                        "You specify a query filter here, which narrows down the users, who can be part of this domain");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(queryFilter));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.searchbase.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.searchbase.toString(),
-                        null,
-                        "The search base defines the starting point for the search in the directory tree Example:  dc=cloud,dc=com.");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(searchBase));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.usessl.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.usessl.toString(), null,
-                        "Check Use SSL if the external LDAP server is configured for LDAP over SSL.");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(useSSL.toString()));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.dn.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.dn.toString(), null,
-                        "Specify the distinguished name of a user with the search permission on the directory");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(bindDN));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.passwd.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.passwd.toString(), null,
-                        "Enter the password");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(bindPasswd));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.truststore.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.truststore.toString(),
-                        null, "Enter the path to trusted keystore");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(trustStore));
-            _configDao.persist(cvo);
-
-            cvo = _configDao.findByName(LDAPParams.truststorepass.toString());
-            if (cvo == null) {
-                cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server",
-                        LDAPParams.truststorepass.toString(), null, "Enter the password for trusted keystore");
-            }
-            cvo.setValue(DBEncryptionUtil.encrypt(trustStorePassword));
-            _configDao.persist(cvo);
-
-            s_logger.debug("The ldap server is configured: " + hostname);
-        } catch (NamingException ne) {
-            throw new InvalidParameterValueException("Naming Exception, check you ldap data ! " + ne.getMessage()
-                    + (ne.getCause() != null ? ("; Caused by:" + ne.getCause().getMessage()) : ""));
-        }
-        return true;
-    }
-
-    @Override
-    @DB
     @ActionEvent(eventType = EventTypes.EVENT_ZONE_EDIT, eventDescription = "editing zone", async = false)
     public DataCenter editZone(UpdateZoneCmd cmd) {
         // Parameter validation as from execute() method in V1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index da9d6a2..e5e28f9 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -88,8 +88,6 @@ import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
 import org.apache.cloudstack.api.command.admin.internallb.ListInternalLoadBalancerElementsCmd;
 import org.apache.cloudstack.api.command.admin.internallb.StartInternalLBVMCmd;
 import org.apache.cloudstack.api.command.admin.internallb.StopInternalLBVMCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
 import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd;
 import org.apache.cloudstack.api.command.admin.network.AddNetworkServiceProviderCmd;
 import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
@@ -2465,8 +2463,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(ReconnectHostCmd.class);
         cmdList.add(UpdateHostCmd.class);
         cmdList.add(UpdateHostPasswordCmd.class);
-        cmdList.add(LDAPConfigCmd.class);
-        cmdList.add(LDAPRemoveCmd.class);
         cmdList.add(AddNetworkDeviceCmd.class);
         cmdList.add(AddNetworkServiceProviderCmd.class);
         cmdList.add(CreateNetworkOfferingCmd.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
index 7a61978..fe146b0 100755
--- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
@@ -26,8 +26,6 @@ import javax.naming.ConfigurationException;
 import javax.naming.NamingException;
 
 import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
 import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
 import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
 import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
@@ -87,8 +85,6 @@ import com.cloud.user.Account;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.vm.VirtualMachine.Type;
 import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
 import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
 import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
 import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
@@ -384,33 +380,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
     }
 
     /* (non-Javadoc)
-     * @see com.cloud.configuration.ConfigurationService#updateLDAP(org.apache.cloudstack.api.commands.LDAPConfigCmd)
-     */
-    @Override
-    public boolean updateLDAP(LDAPConfigCmd cmd) throws NamingException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.configuration.ConfigurationService#removeLDAP(org.apache.cloudstack.api.commands.LDAPRemoveCmd)
-     */
-    @Override
-    public boolean removeLDAP(LDAPRemoveCmd cmd) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.configuration.ConfigurationService#listLDAPConfig(org.apache.cloudstack.api.commands.LDAPConfigCmd)
-     */
-    @Override
-    public LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
      * @see com.cloud.configuration.ConfigurationService#isOfferingForVpc(com.cloud.offering.NetworkOffering)
      */
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 5edf733..039afd5 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -2238,3 +2238,18 @@ CREATE VIEW `cloud`.`project_view` AS
             and resource_tags.resource_type = 'Project'
             left join
         `cloud`.`project_account` pacct ON projects.id = pacct.project_id;
+        
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.bind.principal', NULL, 'Specifies the bind principal to use for bind to LDAP');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.bind.password', NULL, 'Specifies the password to use for binding to LDAP');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.username.attribute', 'uid', 'Sets the username attribute used within LDAP');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.email.attribute', 'mail', 'Sets the email attribute used within LDAP');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.realname.attribute', 'cn', 'Sets the realname attribute used within LDAP');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.user.object', 'inetOrgPerson', 'Sets the object type of users within LDAP');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'ldap.basedn', NULL, 'Sets the basedn for LDAP');
+
+CREATE TABLE `cloud`.`ldap_configuration` (
+  `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
+  `hostname` varchar(255) NOT NULL COMMENT 'the hostname of the ldap server',
+  `port` int(10) COMMENT 'port that the ldap server is listening on',
+  PRIMARY KEY  (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index 33a7e75..f582340 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -118,7 +118,7 @@ known_categories = {
     'TrafficType': 'Usage',
     'Product': 'Product',
     'LB': 'Load Balancer',
-    'ldap': 'LDAP',
+    'Ldap': 'LDAP',
     'Swift': 'Swift',
     'S3' : 'S3',
     'SecondaryStorage': 'Host',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a90affe4/ui/scripts/globalSettings.js
----------------------------------------------------------------------
diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js
index 1ae73b7..ac63015 100644
--- a/ui/scripts/globalSettings.js
+++ b/ui/scripts/globalSettings.js
@@ -14,343 +14,316 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-
-(function(cloudStack) {
-  cloudStack.sections['global-settings'] = {
-    title: 'label.menu.global.settings',
-    id: 'global-settings',
-    sectionSelect: {
-      label: 'label.select-view'
-    },
-    sections: {
-      globalSettings: {
-        type: 'select',
+(function (cloudStack) {
+    cloudStack.sections['global-settings'] = {
         title: 'label.menu.global.settings',
-        listView: {
-          label: 'label.menu.global.settings',
-          actions: {
-            edit: {
-              label: 'label.change.value',
-              action: function(args) {    
-								var data = {
-								  name: args.data.jsonObj.name,
-									value: args.data.value
-								};								
-                $.ajax({
-                  url: createURL('updateConfiguration'),
-                  data: data,                  
-                  success: function(json) {                
-                    var item = json.updateconfigurationresponse.configuration;
-                    if(item.category == "Usage")
-                      cloudStack.dialog.notice({ message: _l('message.restart.mgmt.usage.server') });
-                    else
-                      cloudStack.dialog.notice({ message: _l('message.restart.mgmt.server') });	
-                    args.response.success({data: item});
-                  },
-                  error: function(json) {                
-                    args.response.error(parseXMLHttpResponse(json));
-                  }
-                });
-              }
-            }
-          },
-          fields: {
-            name: { label: 'label.name', id: true },
-            description: { label: 'label.description' },
-            value: { label: 'label.value', editable: true, truncate: true }
-          },
-          dataProvider: function(args) {
-            var data = {
-              page: args.page,
-              pagesize: pageSize
-            };
-
-            if (args.filterBy.search.value) {
-              data.name = args.filterBy.search.value;
-            }
-
-            $.ajax({
-              url: createURL('listConfigurations'),
-              data: data,
-              dataType: "json",
-              async: true,
-              success: function(json) {
-                var items = json.listconfigurationsresponse.configuration;
-                args.response.success({ data: items });
-              }
-            });
-          }
-        }
-      },
-
-      ldapConfiguration:{
-         type:'select',
-         title:'LDAP Configuration',
-         listView:{
-            id:'ldap',
-            label:'LDAP Configuration', 
-            fields:{
-                hostname: {label: 'Hostname'},
-                queryfilter: {label: 'Query Filter'},
-                searchbase: {label: 'Search Base'},
-                port: {label: 'LDAP Port'},
-                ssl: {
-                  label: 'SSL'
-
-                  }
-
-             },
-              dataProvider:function(args){
-                   var data = {};
-                   listViewDataProvider(args, data);
-                    $.ajax({
-              url: createURL('ldapConfig&listall=true'),   //Need a list LDAP configuration API call which needs to be implemented
-              data: data,
-                success: function(json) {
-                var items = json.ldapconfigresponse.ldapconfig;
-                args.response.success({data:items});
-                   },
-                   error: function(data) {
-                args.response.error(parseXMLHttpResponse(data));
-                  }
-               });
-           },
-
-          detailView: {
-            name: 'label.details',
-              actions: {
-
-              // Remove LDAP
-              remove: {
-                label: 'Remove LDAP',
-                messages: {
-                  notification: function(args) {
-                    return 'LDAP Configuration Deleted';
-                  },
-                  confirm: function() {
-                    return 'Are you sure you want to delete the LDAP configuration?';
-                  }
-                },
-                action: function(args) {
-
-                  $.ajax({
-                       url:createURL("ldapRemove"),
-                       success:function(json){
-
-                  args.response.success();
-
-                       }
-
-                       });
-                    $(window).trigger('cloudStack.fullRefresh');
-
-                }
-              }
-          },
-
-           tabs:{
-
-               details: {
-                title: 'LDAP Configuration Details',
-                fields: [
-                  {
-                    hostname: { label: 'Hostname' },
-                    description: { label: 'label.description' },
-                    ssl : { label: 'SSL'}
-                  }
-                ],
-                dataProvider: function(args) {
-                                                                        $.ajax({
-                                                                                url: createURL("ldapConfig&listAll=true" ),
-                                                                                dataType: "json",
-                                                                                async: true,
-                                                                                success: function(json) {
-                                                                                        var item = json.ldapconfigresponse.ldapconfig;
-                                                                                        args.response.success({data: item});
-                                                                                }
-                                                                        });                                                                                                       
-                                                                }
-             
-                                                        }
-
-            }
-       }, 
-
-          actions: {
-               add:{
-
-               label: 'Configure LDAP',
- 
-               messages: {
-                confirm: function(args) {
-                  return 'Do you really want to configure LDAP ? ';
-                },
-                notification: function(args) {
-                  return 'LDAP configured';
+        id: 'global-settings',
+        sectionSelect: {
+            label: 'label.select-view'
+        },
+        sections: {
+            globalSettings: {
+                type: 'select',
+                title: 'label.menu.global.settings',
+                listView: {
+                    label: 'label.menu.global.settings',
+                    actions: {
+                        edit: {
+                            label: 'label.change.value',
+                            action: function (args) {
+                                var data = {
+                                    name: args.data.jsonObj.name,
+                                    value: args.data.value
+                                };
+                                $.ajax({
+                                    url: createURL('updateConfiguration'),
+                                    data: data,
+                                    success: function (json) {
+                                        var item = json.updateconfigurationresponse.configuration;
+                                        if (item.category == "Usage")
+                                            cloudStack.dialog.notice({
+                                                message: _l('message.restart.mgmt.usage.server')
+                                            });
+                                        else
+                                            cloudStack.dialog.notice({
+                                                message: _l('message.restart.mgmt.server')
+                                            });
+                                        args.response.success({
+                                            data: item
+                                        });
+                                    },
+                                    error: function (json) {
+                                        args.response.error(parseXMLHttpResponse(json));
+                                    }
+                                });
+                            }
+                        }
+                    },
+                    fields: {
+                        name: {
+                            label: 'label.name',
+                            id: true
+                        },
+                        description: {
+                            label: 'label.description'
+                        },
+                        value: {
+                            label: 'label.value',
+                            editable: true,
+                            truncate: true
+                        }
+                    },
+                    dataProvider: function (args) {
+                        var data = {
+                            page: args.page,
+                            pagesize: pageSize
+                        };
+                        if (args.filterBy.search.value) {
+                            data.name = args.filterBy.search.value;
+                        }
+                        $.ajax({
+                            url: createURL('listConfigurations'),
+                            data: data,
+                            dataType: "json",
+                            async: true,
+                            success: function (json) {
+                                var items = json.listconfigurationsresponse.configuration;
+                                args.response.success({
+                                    data: items
+                                });
+                            }
+                        });
+                    }
                 }
-              },
-         
-              createForm: {
-                    
-                    title: 'Configure LDAP',
-                    fields:{
-                        name:{label: 'Bind DN' , validation: {required:true} },
-                        password: {label: 'Bind Password', validation: {required: true },isPassword:true },
-                        hostname: {label:'Hostname' , validation:{required:true}},
-                        queryfilter: {label:'Query Filter' , validation: {required:true} , docID:'helpLdapQueryFilter'},
-                        searchbase: {label:'SearchBase',validation:{required:true}},
-                        ssl:  {
-                               label:'SSL' ,
-                               isBoolean:true,
-                               isChecked:false
-                                
+            },
+            ldapConfiguration: {
+                type: 'select',
+                title: 'LDAP Configuration',
+                listView: {
+                    id: 'ldap',
+                    label: 'LDAP Configuration',
+                    fields: {
+                        hostname: {
+                            label: 'Hostname'
+                        },
+                        port: {
+                            label: 'LDAP Port'
+                        },
+                    },
+                    dataProvider: function (args) {
+                        var data = {};
+                        listViewDataProvider(args, data);
+                        $.ajax({
+                            url: createURL('listLdapConfigurations'),
+                            data: data,
+                            success: function (json) {
+                                var items = json.ldapconfigurationresponse.LdapConfiguration;
+                                args.response.success({
+                                    data: items
+                                });
                             },
-                        port: {  label: 'Port' , defaultValue: '389' },
-                        truststore:{ label:'Trust Store' , isHidden:true , dependsOn:'ssl',validation:{required:true} },
-                        truststorepassword:{ label:'Trust Store Password' ,isHidden:true , dependsOn:'ssl', validation:{required:true}}
-                        
-                     }
- 
-
-              },
-            
-
-                action:function(args) {
-                     var array = [];
-                      array.push("&binddn=" + todb(args.data.name));
-                      array.push("&bindpass=" + todb(args.data.password));
-                      array.push("&hostname=" + todb(args.data.hostname));
-                      array.push("&searchbase=" +todb(args.data.searchbase));
-                      array.push("&queryfilter=" +todb(args.data.queryfilter));
-                      array.push("&port=" +todb(args.data.port));
-
-                      if(args.$form.find('.form-item[rel=ssl]').find('input[type=checkbox]').is(':Checked')== true)  {
-
-                            array.push("&ssl=true");
-                            if(args.data.truststore != "")
-                            array.push("&truststore=" +todb(args.data.truststore));
-
-                            if(args.data.truststorepassword !="")
-                            array.push("&truststorepass=" +todb(args.data.truststorepassword));
-
+                            error: function (data) {
+                                args.response.error(parseXMLHttpResponse(data));
+                            }
+                        });
+                    },
+                    detailView: {
+                        name: 'label.details',
+                        actions: {
+                            remove: {
+                                label: 'Remove LDAP',
+                                messages: {
+                                    notification: function (args) {
+                                        return 'LDAP Configuration Deleted';
+                                    },
+                                    confirm: function () {
+                                        return 'Are you sure you want to delete the LDAP configuration?';
+                                    }
+                                },
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("deleteLdapConfiguration&hostname=" + args.context.ldapConfiguration[0].hostname),
+                                        success: function (json) {
+                                            args.response.success();
+                                        }
+                                    });
+                                    $(window).trigger('cloudStack.fullRefresh');
+                                }
+                            }
+                        },
+                        tabs: {
+                            details: {
+                                title: 'LDAP Configuration Details',
+                                fields: [{
+                                    hostname: {
+                                        label: 'Hostname'
+                                    },
+                                    port: {
+                                        label: 'Port'
+                                    }
+                                }],
+                                dataProvider: function (args) {
+                                    var items = [];
+                                    console.log(args);
+                                    $.ajax({
+                                        url: createURL("listLdapConfigurations&hostname=" + args.context.ldapConfiguration[0].hostname),
+                                        dataType: "json",
+                                        async: true,
+                                        success: function (json) {
+                                            var item = json.ldapconfigurationresponse.LdapConfiguration;
+                                            args.response.success({
+                                                data: item[0]
+                                            });
+                                        }
+                                    });
+                                }
+                            }
                         }
-
-                      else
-                        array.push("&ssl=false");
-
-                  $.ajax({
-                    url: createURL("ldapConfig" + array.join("")),
-                    dataType: "json",
-                    async: true,
-                    success: function(json) {
-                       var items = json.ldapconfigresponse.ldapconfig;
-                       args.response.success({
-                                   data: items
-                             });
-
-                      },
-
-                   error:function(json){
-                      args.response.error(parseXMLHttpResponse(json));
-
-                     }
-
-
-                     });
-
-
-                }
-             }
-
-           }
-
- 
-
-          }
-
-
-
-       },
-      hypervisorCapabilities: {
-        type: 'select',
-        title: 'label.hypervisor.capabilities',
-        listView: {
-          id: 'hypervisorCapabilities',
-          label: 'label.hypervisor.capabilities',
-          fields: {
-            hypervisor: { label: 'label.hypervisor' },
-            hypervisorversion: { label: 'label.hypervisor.version' },
-            maxguestslimit: { label: 'label.max.guest.limit' }
-          },
-          dataProvider: function(args) {					  
-						var data = {};
-						listViewDataProvider(args, data);					
-										  
-            $.ajax({
-              url: createURL('listHypervisorCapabilities'),
-              data: data,              
-              success: function(json) {
-                var items = json.listhypervisorcapabilitiesresponse.hypervisorCapabilities;
-                args.response.success({data:items});
-              },
-              error: function(data) {
-                args.response.error(parseXMLHttpResponse(data));
-              }
-            });
-          },
-
-          detailView: {
-            name: 'label.details',
-            actions: {
-              edit: {
-                label: 'label.edit',
-                action: function(args) {
-                  var data = {
-									  id: args.context.hypervisorCapabilities[0].id,
-										maxguestslimit: args.data.maxguestslimit
-									};
-                  
-                  $.ajax({
-                    url: createURL('updateHypervisorCapabilities'),
-                    data: data,
-                    success: function(json) {
-                      var item = json.updatehypervisorcapabilitiesresponse['null'];
-                      args.response.success({data: item});
                     },
-                    error: function(data) {
-                      args.response.error(parseXMLHttpResponse(data));
+                    actions: {
+                        add: {
+                            label: 'Configure LDAP',
+                            messages: {
+                                confirm: function (args) {
+                                    return 'Do you really want to configure LDAP ? ';
+                                },
+                                notification: function (args) {
+                                    console.log(args);
+                                    return 'Successfully added a new LDAP server';
+                                }
+                            },
+                            createForm: {
+                                title: 'Configure LDAP',
+                                fields: {
+                                    hostname: {
+                                        label: 'Hostname',
+                                        validation: {
+                                            required: true
+                                        }
+                                    },
+                                    port: {
+                                        label: 'Port',
+                                        validation: {
+                                            required: true
+                                        }
+                                    }
+                                }
+                            },
+                            action: function (args) {
+                                var array = [];
+                                array.push("&hostname=" + todb(args.data.hostname));
+                                array.push("&port=" + todb(args.data.port));;
+                                $.ajax({
+                                    url: createURL("addLdapConfiguration" + array.join("")),
+                                    dataType: "json",
+                                    async: true,
+                                    success: function (json) {
+                                        var items = json.ldapconfigurationresponse.LdapAddConfiguration;
+                                        args.response.success({
+                                            data: items
+                                        });
+                                    },
+                                    error: function (json) {
+                                        args.response.error(parseXMLHttpResponse(json));
+                                    }
+                                });
+                            }
+                        }
                     }
-                  });
                 }
-              }
             },
+            hypervisorCapabilities: {
+                type: 'select',
+                title: 'label.hypervisor.capabilities',
+                listView: {
+                    id: 'hypervisorCapabilities',
+                    label: 'label.hypervisor.capabilities',
+                    fields: {
+                        hypervisor: {
+                            label: 'label.hypervisor'
+                        },
+                        hypervisorversion: {
+                            label: 'label.hypervisor.version'
+                        },
+                        maxguestslimit: {
+                            label: 'label.max.guest.limit'
+                        }
+                    },
+                    dataProvider: function (args) {
+                        var data = {};
+                        listViewDataProvider(args, data);
+
+                        $.ajax({
+                            url: createURL('listHypervisorCapabilities'),
+                            data: data,
+                            success: function (json) {
+                                var items = json.listhypervisorcapabilitiesresponse.hypervisorCapabilities;
+                                args.response.success({
+                                    data: items
+                                });
+                            },
+                            error: function (data) {
+                                args.response.error(parseXMLHttpResponse(data));
+                            }
+                        });
+                    },
 
-            tabs: {
-              details: {
-                title: 'label.details',
-                fields: [
-                  {
-                    id: { label: 'label.id' },
-                    hypervisor: { label: 'label.hypervisor' },
-                    hypervisorversion: { label: 'label.hypervisor.version' },
-                    maxguestslimit: {
-                      label: 'label.max.guest.limit',
-                      isEditable: true
-                    }
-                  }
-                ],
-                dataProvider: function(args) {
-                  args.response.success(
-                    {
-                      data:args.context.hypervisorCapabilities[0]
+                    detailView: {
+                        name: 'label.details',
+                        actions: {
+                            edit: {
+                                label: 'label.edit',
+                                action: function (args) {
+                                    var data = {
+                                        id: args.context.hypervisorCapabilities[0].id,
+                                        maxguestslimit: args.data.maxguestslimit
+                                    };
+
+                                    $.ajax({
+                                        url: createURL('updateHypervisorCapabilities'),
+                                        data: data,
+                                        success: function (json) {
+                                            var item = json.updatehypervisorcapabilitiesresponse['null'];
+                                            args.response.success({
+                                                data: item
+                                            });
+                                        },
+                                        error: function (data) {
+                                            args.response.error(parseXMLHttpResponse(data));
+                                        }
+                                    });
+                                }
+                            }
+                        },
+
+                        tabs: {
+                            details: {
+                                title: 'label.details',
+                                fields: [{
+                                    id: {
+                                        label: 'label.id'
+                                    },
+                                    hypervisor: {
+                                        label: 'label.hypervisor'
+                                    },
+                                    hypervisorversion: {
+                                        label: 'label.hypervisor.version'
+                                    },
+                                    maxguestslimit: {
+                                        label: 'label.max.guest.limit',
+                                        isEditable: true
+                                    }
+                                }],
+                                dataProvider: function (args) {
+                                    args.response.success({
+                                        data: args.context.hypervisorCapabilities[0]
+                                    });
+                                }
+                            }
+                        }
                     }
-                  );
                 }
-              }
             }
-          }
         }
-      }
-    }
-  };
+    };
 })(cloudStack);


Mime
View raw message