X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.security.core%2Fsrc%2Forg%2Fargeo%2Futil%2Fnaming%2FLdifParser.java;h=ec73e8accb29734c401b754d6684d2f92ffb0a3b;hb=8260f4470f514ea347ca53f5b4dfc632c4a4de66;hp=c2cd7718654a501ff0c7cfd01855ca325d592320;hpb=a7970d75a320e1702ff62392242499e7c2527ba3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.core/src/org/argeo/util/naming/LdifParser.java b/org.argeo.security.core/src/org/argeo/util/naming/LdifParser.java index c2cd77186..ec73e8acc 100644 --- a/org.argeo.security.core/src/org/argeo/util/naming/LdifParser.java +++ b/org.argeo.security.core/src/org/argeo/util/naming/LdifParser.java @@ -2,8 +2,12 @@ package org.argeo.util.naming; import static org.argeo.osgi.useradmin.LdifName.dn; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Base64; import java.util.List; import java.util.SortedMap; import java.util.TreeMap; @@ -17,8 +21,6 @@ import javax.naming.directory.BasicAttributes; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.osgi.useradmin.UserDirectoryException; @@ -50,7 +52,13 @@ public class LdifParser { public SortedMap read(InputStream in) throws IOException { SortedMap res = new TreeMap(); try { - List lines = IOUtils.readLines(in); + List lines = new ArrayList<>(); + try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { + String line; + while ((line = br.readLine()) != null) { + lines.add(line); + } + } if (lines.size() == 0) return res; // add an empty new line since the last line is not checked @@ -90,7 +98,7 @@ public class LdifParser { String attributeId = attrId.toString(); String cleanValueStr = currentEntry.toString().trim(); - Object attributeValue = isBase64 ? Base64.decodeBase64(cleanValueStr) : cleanValueStr; + Object attributeValue = isBase64 ? Base64.getDecoder().decode(cleanValueStr) : cleanValueStr; // manage DN attributes if (attributeId.equals(dn.name()) || isLastLine) { @@ -130,7 +138,7 @@ public class LdifParser { currentEntry.append(line); } } finally { - IOUtils.closeQuietly(in); + in.close(); } return res; }