wenxuanguan commented on a change in pull request #45:
URL: https://github.com/apache/directory-kerby/pull/45#discussion_r501635599
##########
File path:
kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
##########
@@ -51,13 +51,18 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.HashMap;
/**
* An LDAP based backend implementation.
*/
public class LdapIdentityBackend extends AbstractIdentityBackend {
+ private int currentConnectionIndex = 0;
+ private Map<String, LdapConnection> connections = new HashMap<>();
Review comment:
@coheigea Thanks for your review.
The changes in `connections` is in the constructor of LdapIdentityBackend or
`doInitialize`, which should not be called
multi-thread, so I think there is no thread-safety problem, anything I
missed?
##########
File path:
kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
##########
@@ -51,13 +51,18 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.HashMap;
/**
* An LDAP based backend implementation.
*/
public class LdapIdentityBackend extends AbstractIdentityBackend {
+ private int currentConnectionIndex = 0;
+ private Map<String, LdapConnection> connections = new HashMap<>();
Review comment:
@coheigea Thanks for your review.
The changes of `connections` is in the constructor of LdapIdentityBackend or
`doInitialize`, which should not be called multi-thread, so I think there is no
thread-safety problem, anything I missed?
##########
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:
make sense, thanks for your advice.
----------------------------------------------------------------
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]