import org.apache.http.NameValuePair; import org.apache.http.client.utils.URLEncodedUtils; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; public class InputUtils { public static String getCognitoIDFromBody(Map inputMap) { System.out.println(inputMap.keySet()); System.out.println(inputMap.entrySet()); Map contextMap = getMap(inputMap, "context"); System.out.println(inputMap.get("context")); System.out.println(contextMap.get("sub")); return contextMap.get("sub").toString(); } public static Map getBody(Map inputMap) { return getMap(inputMap, "body"); } public static HashMap getQueryParams(Map inputMap) { return (HashMap) (getMap(inputMap, "params").get("querystring")); } public static Map getMap(Map parentMap, String childKey) { if ((parentMap.get(childKey) != null) && (parentMap.get(childKey) instanceof Map)) { return ((Map) parentMap.get(childKey)); } throw new IllegalArgumentException("The key \"" + childKey + "\" must exist and be a map"); } }