directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject directory-kerby git commit: [DIRKRB-295]-Implementing getIdentities for LdapIdentityBackend. Contributed by Yaning.
Date Thu, 25 Jun 2015 21:33:33 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 0b7690e33 -> 895044000


[DIRKRB-295]-Implementing getIdentities for LdapIdentityBackend. Contributed by Yaning.


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

Branch: refs/heads/master
Commit: 895044000c4b4e51cb9411ea53f7ea29af782bc8
Parents: 0b7690e
Author: Stefan Seelmann <mail@stefan-seelmann.de>
Authored: Thu Jun 25 23:32:54 2015 +0200
Committer: Stefan Seelmann <mail@stefan-seelmann.de>
Committed: Thu Jun 25 23:32:54 2015 +0200

----------------------------------------------------------------------
 .../identitybackend/LdapIdentityBackend.java    | 30 ++++++++++++++++++--
 .../backend/LdapIdentityBackendTest.java        |  5 ++++
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/89504400/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 69803dd..4fb6c9d 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
@@ -19,12 +19,15 @@
  */
 package org.apache.kerby.kerberos.kdc.identitybackend;
 
+import org.apache.directory.api.ldap.model.cursor.CursorException;
+import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.message.ModifyRequest;
 import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
+import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.name.Rdn;
 import org.apache.directory.api.util.GeneralizedTime;
@@ -40,6 +43,8 @@ import sun.security.krb5.Asn1Exception;
 
 import java.io.IOException;
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -242,11 +247,32 @@ public class LdapIdentityBackend extends AbstractIdentityBackend {
 
     @Override
     public List<String> getIdentities(int start, int limit) {
-        return null;
+        List<String> identityNames = getIdentities();
+        return identityNames.subList(start, limit);
     }
 
     @Override
     public List<String> getIdentities() {
-        return null;
+        List<String> identityNames = new ArrayList<>();
+        EntryCursor cursor;
+        Entry entry;
+        try {
+            cursor = connection.search( BASE_DN, "(objectclass=*)", SearchScope.ONELEVEL,
+                    "krb5PrincipalName");
+            if (cursor == null) {
+                return null;
+            }
+            while (cursor.next()) {
+                entry = cursor.get();
+                identityNames.add(entry.get("krb5PrincipalName").getString());
+            }
+            cursor.close();
+            Collections.sort(identityNames);
+        } catch (LdapException e) {
+            e.printStackTrace();
+        } catch (CursorException e) {
+            e.printStackTrace();
+        }
+        return identityNames;
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/89504400/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 8ad5cf3..7a2e6ea 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
@@ -95,4 +95,9 @@ public class LdapIdentityBackendTest extends AbstractLdapIdentityBackendTest
     public void testDelete() {
         super.testDelete(backend);
     }
+
+    @Test
+    public void testGetIdentities() {
+        super.testGetIdentities(backend);
+    }
 }
\ No newline at end of file


Mime
View raw message