import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays;
-import java.util.Base64;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
public class LdifUserAdminTest extends TestCase implements BasicTestConstants {
// We have to keep using JUnit because of
// https://issues.apache.org/jira/browse/SUREFIRE-1669
-
+
final static int TM_SIMPLE = 0;
final static int TM_BITRONIX = 1;
assert "root@localhost".equals(rootUser.getProperties().get("mail"));
// credentials
- byte[] hashedPassword = ("{SHA}" + Base64.getEncoder().encodeToString(DigestUtils.sha1("demo".getBytes())))
- .getBytes();
- assert rootUser.hasCredential(LdapAttrs.userPassword.name(), hashedPassword);
- assert demoUser.hasCredential(LdapAttrs.userPassword.name(), hashedPassword);
+ // {SHA}
+ assert rootUser.hasCredential(LdapAttrs.userPassword.name(), "demo".getBytes(StandardCharsets.UTF_8));
+ // {PBKDF2_SHA256}
+ assert demoUser.hasCredential(LdapAttrs.userPassword.name(), "demo".getBytes(StandardCharsets.UTF_8));
// search
Role[] search = userAdmin.getRoles(null);
mail: demo@localhost
sn: User
uid: demo
-userPassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+userPassword:: e1BCS0RGMl9TSEEyNTZ9QUFBSUFOMEtpaTA5Z0h5SHA4Q1Y2bHZhbE5DOWJPcjZTVGVpSFU3UDB
+ 5UGVxVUVIdnR2c2pIVmVadW5YV3FNNG5MV090U1gvWS9Jc1FsdXdjR3lFclBJVTRBVWlRVytNb1
+ Y0TTYzaWlPNnlkcXRFZ2dzSGlNK1lPamFZZGl2YUMrRERqRkNBeEN5VFdsdEFYNXZKaWZMMlBwa
+ S93OXFkTWI4YjgyRFFJMUIxZG9IMEdPZ2ZISFQwT2luYm95QlNjUmhvaDN6WGVPd1ZabWlqNHlH
+ Y1JPazhta1lRVm5SQXlyR2pvSHVsSXIwR3ovMnlhR3VFdWJSL2NLOUtsYTQyWWo5RTNRdmJJbkE
+ 3Y0Rjc2xYTlJHTENMZVBhYTdsSWUxc3pUR2JGRVZ4aVQ2M2xQck9RcHNwamRubEFlSjkvWUx5Z3
+ VFTHIrZDJoNmN1SzNmdGFLbmpiRWxTRFJBMy9OanIwRVVzUHBxZDFibWIxbmxMRHR3Mlo5Y3h0Y
+ WljQTdSOHE3eXVhZzFQc0xac2dxdk9HR1hsZ1RVSk4rVitkWkVYdk1BSEgra0YvY1hhU05Q
dn: uid=root,ou=users,dc=example,dc=com
objectClass: inetOrgPerson
int index = storedBase64.indexOf('}');
if (index > 0) {
passwordScheme = storedBase64.substring(1, index);
- byte[] storedValueBytes = Base64.getDecoder().decode(storedBase64.substring(index + 1));
+ String storedValueBase64 = storedBase64.substring(index + 1);
+ byte[] storedValueBytes = Base64.getDecoder().decode(storedValueBase64);
char[] passwordValue = DigestUtils.bytesToChars((byte[]) value);
byte[] valueBytes;
if (DigestUtils.PASSWORD_SCHEME_SHA.equals(passwordScheme)) {
- valueBytes = DigestUtils.toPasswordScheme(passwordScheme, passwordValue, null, null,
- null);
+ valueBytes = DigestUtils.toPasswordScheme(passwordScheme, passwordValue, null, null, null);
} else if (DigestUtils.PASSWORD_SCHEME_PBKDF2_SHA256.equals(passwordScheme)) {
// see https://www.thesubtlety.com/post/a-389-ds-pbkdf2-password-checker/
byte[] iterationsArr = Arrays.copyOfRange(storedValueBytes, 0, 4);