X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.enterprise%2Fsrc%2Forg%2Fargeo%2Fnaming%2FLdifWriter.java;h=892fa885d8f46611de39d0d173bda5edc944482d;hb=9c1e0062044a1dcf34d34c7cda840334e56a289c;hp=6bd4809dbcacaf2881a57d16d9a09b4a71927af8;hpb=85688af22a77f82e7762e11e6eb38c6367eddb6c;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.enterprise/src/org/argeo/naming/LdifWriter.java b/org.argeo.enterprise/src/org/argeo/naming/LdifWriter.java index 6bd4809db..892fa885d 100644 --- a/org.argeo.enterprise/src/org/argeo/naming/LdifWriter.java +++ b/org.argeo.enterprise/src/org/argeo/naming/LdifWriter.java @@ -1,11 +1,11 @@ package org.argeo.naming; -import static org.argeo.osgi.useradmin.LdifName.dn; - import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Map; @@ -20,6 +20,7 @@ import org.argeo.osgi.useradmin.UserDirectoryException; /** Basic LDIF writer */ public class LdifWriter { + private final static Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; private final Writer writer; /** Writer must be closed by caller */ @@ -29,7 +30,7 @@ public class LdifWriter { /** Stream must be closed by caller */ public LdifWriter(OutputStream out) { - this(new OutputStreamWriter(out)); + this(new OutputStreamWriter(out, DEFAULT_CHARSET)); } public void writeEntry(LdapName name, Attributes attributes) throws IOException { @@ -41,13 +42,13 @@ public class LdifWriter { throw new UserDirectoryException( "Attribute " + nameAttr.getID() + "=" + nameAttr.get() + " not consistent with DN " + name); - writer.append(dn.name() + ":").append(name.toString()).append('\n'); + writer.append(LdapAttrs.DN + ":").append(name.toString()).append('\n'); Attribute objectClassAttr = attributes.get("objectClass"); if (objectClassAttr != null) writeAttribute(objectClassAttr); for (NamingEnumeration attrs = attributes.getAll(); attrs.hasMore();) { Attribute attribute = attrs.next(); - if (attribute.getID().equals(dn.name()) || attribute.getID().equals("objectClass")) + if (attribute.getID().equals(LdapAttrs.DN) || attribute.getID().equals("objectClass")) continue;// skip DN attribute writeAttribute(attribute); }