Package google.registry.security
Class JsonHttp
java.lang.Object
google.registry.security.JsonHttp
Helper class for servlets that read or write JSON.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionread
(jakarta.servlet.http.HttpServletRequest req) Extracts a JSON object from a servlet request.static void
Writes a JSON servlet response securely with a parser breaker.
-
Field Details
-
JSON_SAFETY_PREFIX
String prefixed to all JSON-like responses.- See Also:
-
-
Constructor Details
-
JsonHttp
public JsonHttp()
-
-
Method Details
-
read
@Nullable public static Map<String,?> read(jakarta.servlet.http.HttpServletRequest req) throws IOException Extracts a JSON object from a servlet request.- Returns:
- JSON object or
null
on error, in which case servlet should return. - Throws:
IOException
- if we failed to read fromreq
.
-
write
public static void write(jakarta.servlet.http.HttpServletResponse rsp, Map<String, ?> jsonObject) throws IOExceptionWrites a JSON servlet response securely with a parser breaker.- Throws:
IOException
- if we failed to write torsp
.
-