directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject [2/4] directory-kerby git commit: Move connection parameter to config
Date Thu, 25 Jun 2015 22:20:46 GMT
Move connection parameter to config


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/b4449bda
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/b4449bda
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/b4449bda

Branch: refs/heads/master
Commit: b4449bdaed0be5b25f8b70a848f99e90302389d6
Parents: 89bcbb8
Author: Stefan Seelmann <mail@stefan-seelmann.de>
Authored: Fri Jun 26 00:13:04 2015 +0200
Committer: Stefan Seelmann <mail@stefan-seelmann.de>
Committed: Fri Jun 26 00:13:04 2015 +0200

----------------------------------------------------------------------
 .../kdc/identitybackend/LdapIdentityBackend.java     | 15 +++++++--------
 .../identity/backend/LdapIdentityBackendTest.java    |  8 ++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/b4449bda/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
----------------------------------------------------------------------
diff --git a/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
b/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
index 645ed92..2f8fa6e 100644
--- a/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
+++ b/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
@@ -52,8 +52,6 @@ import java.util.Map;
  *
  */
 public class LdapIdentityBackend extends AbstractIdentityBackend {
-    private static final String BASE_DN = "ou=users,dc=example,dc=com";
-    private static final String ADMIN_DN = "uid=admin,ou=system";
     private LdapNetworkConnection connection;
 
     public LdapIdentityBackend() {
@@ -70,9 +68,10 @@ public class LdapIdentityBackend extends AbstractIdentityBackend {
     }
 
     public void startConnection() throws LdapException {
-        this.connection = new LdapNetworkConnection( "localhost",
-                getConfig().getInt("port") );
-        connection.bind( ADMIN_DN, "secret" );
+        this.connection = new LdapNetworkConnection(getConfig().getString("host"),
+                getConfig().getInt("port"));
+        connection.bind(getConfig().getString("admin_dn"),
+                getConfig().getString("admin_pw"));
     }
 
     @Override
@@ -238,7 +237,7 @@ public class LdapIdentityBackend extends AbstractIdentityBackend {
     private Dn toDn(String principalName) throws LdapInvalidDnException {
         String[] names = principalName.split("@");
         String uid = names[0];
-        Dn dn = new Dn(new Rdn("uid", uid), new Dn(BASE_DN));
+        Dn dn = new Dn(new Rdn("uid", uid), new Dn(getConfig().getString("base_dn")));
         return dn;
     }
 
@@ -254,8 +253,8 @@ public class LdapIdentityBackend extends AbstractIdentityBackend {
         EntryCursor cursor;
         Entry entry;
         try {
-            cursor = connection.search( BASE_DN, "(objectclass=*)", SearchScope.ONELEVEL,
-                    "krb5PrincipalName");
+            cursor = connection.search( getConfig().getString("base_dn"), 
+                    "(objectclass=*)", SearchScope.ONELEVEL, "krb5PrincipalName");
             if (cursor == null) {
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/b4449bda/kerby-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapIdentityBackendTest.java
----------------------------------------------------------------------
diff --git a/kerby-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapIdentityBackendTest.java
b/kerby-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapIdentityBackendTest.java
index 7a2e6ea..5761845 100644
--- a/kerby-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapIdentityBackendTest.java
+++ b/kerby-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapIdentityBackendTest.java
@@ -59,12 +59,20 @@ import org.junit.runner.RunWith;
 )
 public class LdapIdentityBackendTest extends AbstractLdapIdentityBackendTest
 {
+    private static final String BASE_DN = "ou=users,dc=example,dc=com";
+    private static final String ADMIN_DN = "uid=admin,ou=system";
+    private static final String ADMIN_PW = "secret";
+
     private LdapIdentityBackend backend;
 
     @Before
     public void setUp() throws Exception {
         Conf config = new Conf();
+        config.setString( "host", "localhost" );
         config.setInt("port", getLdapServer().getPort());
+        config.setString("admin_dn", ADMIN_DN);
+        config.setString("admin_pw", ADMIN_PW);
+        config.setString("base_dn", BASE_DN);
         this.backend = new LdapIdentityBackend(config);
         backend.initialize();
         backend.start();


Mime
View raw message