coheigea commented on a change in pull request #45:
URL: https://github.com/apache/directory-kerby/pull/45#discussion_r501664401



##########
File path: 
kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
##########
@@ -87,19 +92,54 @@ public LdapIdentityBackend(Config config) {
     public LdapIdentityBackend(Config config,
                                LdapConnection connection) {
         setConfig(config);
+        if (isHa()) {
+            throw new IllegalArgumentException("Only one ldap connection 
provided, but two needed "
+                    + "when set ha hosts[" + config.getString("host") + "]");
+        }
         this.connection = connection;
+        String hostConfig = getConfig().getString("host");
+        hosts = new String[]{hostConfig};
+        connections.put(hostConfig, connection);
+    }
+
+    public LdapIdentityBackend(Config config, Map<String, LdapConnection> 
connections) {
+        setConfig(config);
+        String hostConfig = getConfig().getString("host");
+        hosts = hostConfig.trim().split(",");
+        if (hosts.length > 2) {
+            throw new IllegalArgumentException("More than two ldap hosts is 
not supported.");
+        }
+        if (hosts.length != connections.size()) {
+            throw new IllegalArgumentException("Number of ldap hosts[" + 
hosts.length
+                    + "] not equal to ldap connections[" + connections.size() 
+ "].");
+        }
+        this.connections = connections;

Review comment:
       We should instead do, so that connections can't be controlled outside 
the class: this.connections = new HashMap<>(connections) 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to