io.castle.client.internal.json.CastleHeadersSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of castle-java Show documentation
Show all versions of castle-java Show documentation
Castle adds real-time monitoring of your authentication stack, instantly notifying you and your users
on potential account hijacks.
package io.castle.client.internal.json;
import com.google.gson.*;
import io.castle.client.model.CastleHeader;
import io.castle.client.model.CastleHeaders;
import java.lang.reflect.Type;
import java.util.Iterator;
public class CastleHeadersSerializer implements JsonSerializer {
@Override
public JsonElement serialize(CastleHeaders headers, Type typeOfSrc, JsonSerializationContext context) {
JsonObject root = new JsonObject();
for (Iterator iterator = headers.getHeaders().iterator(); iterator.hasNext(); ) {
CastleHeader header = iterator.next();
String key = header.getKey();
String value = header.getValue();
root.add(key, new JsonPrimitive(value));
}
return root;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy