Remove LdifName
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 14 Jan 2017 13:47:58 +0000 (14:47 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 14 Jan 2017 13:47:58 +0000 (14:47 +0100)
org.argeo.enterprise/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java
org.argeo.enterprise/ext/test/org/argeo/osgi/useradmin/LdifUserAdminTest.java
org.argeo.enterprise/src/org/argeo/osgi/useradmin/LdifName.java [deleted file]

index b732a98acaa58b13c5e06d0131082afb683dbb24..75bfe11ff294c6789372d86ea96011f9a210d231 100644 (file)
@@ -10,10 +10,11 @@ import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.ldap.LdapName;
 
-import junit.framework.TestCase;
-
+import org.argeo.naming.LdapAttrs;
 import org.argeo.naming.LdifParser;
 
+import junit.framework.TestCase;
+
 public class LdifParserTest extends TestCase implements BasicTestConstants {
        public void testBasicLdif() throws Exception {
                LdifParser ldifParser = new LdifParser();
@@ -23,9 +24,9 @@ public class LdifParserTest extends TestCase implements BasicTestConstants {
                Attributes rootAttributes = res.get(rootDn);
                assertNotNull(rootAttributes);
                assertEquals("Superuser",
-                               rootAttributes.get(LdifName.description.name()).get());
+                               rootAttributes.get(LdapAttrs.description.name()).get());
                byte[] rawPwEntry = (byte[]) rootAttributes.get(
-                               LdifName.userPassword.name()).get();
+                               LdapAttrs.userPassword.name()).get();
                assertEquals("{SHA}ieSV55Qc+eQOaYDRSha/AjzNTJE=",
                                new String(rawPwEntry));
                byte[] hashedPassword = DigestUtils.sha1("demo".getBytes());
@@ -35,7 +36,7 @@ public class LdifParserTest extends TestCase implements BasicTestConstants {
                LdapName adminDn = new LdapName(ADMIN_GROUP_DN);
                Attributes adminAttributes = res.get(adminDn);
                assertNotNull(adminAttributes);
-               Attribute memberAttribute = adminAttributes.get(LdifName.member.name());
+               Attribute memberAttribute = adminAttributes.get(LdapAttrs.member.name());
                assertNotNull(memberAttribute);
                NamingEnumeration<?> members = memberAttribute.getAll();
                List<String> users = new ArrayList<String>();
index 4cfb58b77af0e52e811ce7f98d67735e7a5b1765..d930a498170ed32d6f34693dbde0508aa80df053 100644 (file)
@@ -20,6 +20,7 @@ import java.util.UUID;
 
 import javax.transaction.TransactionManager;
 
+import org.argeo.naming.LdapAttrs;
 import org.osgi.service.useradmin.Authorization;
 import org.osgi.service.useradmin.Group;
 import org.osgi.service.useradmin.Role;
@@ -100,8 +101,8 @@ public class LdifUserAdminTest extends TestCase implements BasicTestConstants {
                // credentials
                byte[] hashedPassword = ("{SHA}" + Base64.getEncoder().encodeToString(DigestUtils.sha1("demo".getBytes())))
                                .getBytes();
-               assertTrue(rootUser.hasCredential(LdifName.userPassword.name(), hashedPassword));
-               assertTrue(demoUser.hasCredential(LdifName.userPassword.name(), hashedPassword));
+               assertTrue(rootUser.hasCredential(LdapAttrs.userPassword.name(), hashedPassword));
+               assertTrue(demoUser.hasCredential(LdapAttrs.userPassword.name(), hashedPassword));
 
                // search
                Role[] search = userAdmin.getRoles(null);
diff --git a/org.argeo.enterprise/src/org/argeo/osgi/useradmin/LdifName.java b/org.argeo.enterprise/src/org/argeo/osgi/useradmin/LdifName.java
deleted file mode 100644 (file)
index 9beac3a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.argeo.osgi.useradmin;
-
-import javax.naming.ldap.LdapName;
-
-import org.argeo.naming.LdapAttrs;
-import org.argeo.naming.LdapObjs;
-
-/**
- * Standard LDAP attributes and object classes leveraged in this implementation
- * of user admin. Named {@link LdifName} in order not to collide with
- * {@link LdapName}.
- * 
- * @deprecated Use {@link LdapAttrs} and {@link LdapObjs} instead.
- */
-@Deprecated
-public enum LdifName {
-       // Attributes
-       dn, dc, cn, sn, uid, mail, displayName, objectClass, userPassword, givenName, description, member,
-       // Object classes
-       inetOrgPerson, organizationalPerson, person, groupOfNames, groupOfUniqueNames, top;
-
-       public final static String PREFIX = "ldap:";
-
-       /** For use as XML name. */
-       public String property() {
-               return PREFIX + name();
-       }
-
-       public static LdifName local(String property) {
-               return LdifName.valueOf(property.substring(PREFIX.length()));
-       }
-}