LdapName rootDn = new LdapName(ROOT_USER_DN);
Attributes rootAttributes = res.get(rootDn);
assertNotNull(rootAttributes);
- assertEquals("Superuser", rootAttributes.get("description").get());
- byte[] rawPwEntry = (byte[]) rootAttributes.get("userpassword").get();
+ assertEquals("Superuser",
+ rootAttributes.get(LdifName.description.name()).get());
+ byte[] rawPwEntry = (byte[]) rootAttributes.get(
+ LdifName.userPassword.name()).get();
assertEquals("{SHA}ieSV55Qc+eQOaYDRSha/AjzNTJE=",
new String(rawPwEntry));
byte[] hashedPassword = DigestUtils.sha1("demo".getBytes());
assertEquals("{SHA}" + Base64.encodeBase64String(hashedPassword),
new String(rawPwEntry));
- LdapName adminDn = new LdapName(
- ADMIN_GROUP_DN);
+ LdapName adminDn = new LdapName(ADMIN_GROUP_DN);
Attributes adminAttributes = res.get(adminDn);
assertNotNull(adminAttributes);
- Attribute memberAttribute = adminAttributes.get("member");
+ Attribute memberAttribute = adminAttributes.get(LdifName.member.name());
assertNotNull(memberAttribute);
NamingEnumeration<?> members = memberAttribute.getAll();
List<String> users = new ArrayList<String>();
byte[] hashedPassword = ("{SHA}" + Base64
.encodeBase64String(DigestUtils.sha1("demo".getBytes())))
.getBytes();
- assertTrue(rootUser.hasCredential("userpassword", hashedPassword));
- assertTrue(demoUser.hasCredential("userpassword", hashedPassword));
+ assertTrue(rootUser.hasCredential(LdifName.userPassword.name(),
+ hashedPassword));
+ assertTrue(demoUser.hasCredential(LdifName.userPassword.name(),
+ hashedPassword));
// search
Role[] search = userAdmin.getRoles(null);
objectClass: top
cn: demo User
description: Demo user
-givenname: Demo
+givenName: Demo
mail: demo@localhost
sn: User
uid: demo
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+userPassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
dn: uid=root+cn=Super Admin,ou=People,dc=demo,dc=example,dc=org
objectClass: inetOrgPerson
objectClass: top
cn: Super Admin
description: Superuser
-givenname: Root
+givenName: Root
mail: root@localhost
sn: Root
uid: root
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+userPassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
dn: cn=admin,ou=Roles,dc=demo,dc=example,dc=org
objectClass: groupOfNames
*/
public enum LdifName {
// Attributes
- dn, cn, sn, uid, mail, displayName, objectClass, userPassword, givenName, description,
+ dn, cn, sn, uid, mail, displayName, objectClass, userPassword, givenName, description, member,
// POSIX attributes
uidNumber, gidNumber, homeDirectory, loginShell, gecos,
// Object classes