Skip to content

Commit 777e4ef

Browse files
committed
Remove DatatypeConverter Usage
Issue gh-626
1 parent 9dd4b01 commit 777e4ef

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

core/src/main/java/org/springframework/ldap/support/LdapEncoder.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121
import org.springframework.ldap.BadLdapGrammarException;
2222
import org.springframework.util.Assert;
23-
import org.springframework.util.ClassUtils;
24-
25-
import jakarta.xml.bind.DatatypeConverter;
2623

2724
/**
2825
* Helper class to encode and decode ldap names and values.
@@ -300,28 +297,10 @@ public static byte[] parseBase64Binary(String val) {
300297
}
301298

302299
private static String encode(byte[] decoded) {
303-
if (ClassUtils.isPresent("java.util.Base64", null)) {
304-
return java.util.Base64.getEncoder().encodeToString(decoded);
305-
} else {
306-
return Base64Converter.encode(decoded);
307-
}
300+
return Base64.getEncoder().encodeToString(decoded);
308301
}
309302

310303
private static byte[] decode(String encoded) {
311-
if (ClassUtils.isPresent("java.util.Base64", null)) {
312-
return java.util.Base64.getDecoder().decode(encoded);
313-
} else {
314-
return Base64Converter.decode(encoded);
315-
}
316-
}
317-
318-
private static class Base64Converter {
319-
static byte[] decode(String string) {
320-
return DatatypeConverter.parseBase64Binary(string);
321-
}
322-
323-
static String encode(byte[] bytes) {
324-
return DatatypeConverter.printBase64Binary(bytes);
325-
}
304+
return Base64.getDecoder().decode(encoded);
326305
}
327306
}

0 commit comments

Comments
 (0)