mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

vharseko
02.18.2021 9ce6bb0d4577fde9ba4fe9b98029905cecf98aeb
FIX JSONEntryWriter escape DN values (#202)

1 files modified
3 ■■■■ changed files
opendj-core/src/main/java/org/openidentityplatform/opendj/ldif/JSONEntryWriter.java 3 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/openidentityplatform/opendj/ldif/JSONEntryWriter.java
@@ -15,6 +15,7 @@
import org.forgerock.opendj.ldif.EntryWriter;
import org.forgerock.util.Reject;
import com.fasterxml.jackson.core.io.JsonStringEncoder;
import com.fasterxml.jackson.databind.ObjectMapper;
public final class JSONEntryWriter implements EntryWriter {
@@ -48,7 +49,7 @@
    public JSONEntryWriter writeEntry(final Entry entry) throws IOException {
        Reject.ifNull(entry);
        
        this.out.println(((firstEntry)?" ":",")+"{\""+entry.getName().toString()+"\":[");
        this.out.println(((firstEntry)?" ":",")+"{\""+new String(JsonStringEncoder.getInstance().quoteAsString(entry.getName().toString())) +"\":[");
        firstEntry=false;
        
        final TreeMap<String,AbstractMap.SimpleEntry<String,ByteSequence>> attr=new TreeMap<>(); //sort by key:value