@Test(expected = InvalidParseOperationException.class) public void givenJsonStringWhenValueIsTooBigORContainXMLTagUsingAll() throws InvalidParseOperationException, IOException { final File file = PropertiesUtils.findFile(JSON_TEST_FILE); final JsonNode json = JsonHandler.getFromFile(file); assertNotNull(json); SanityChecker.checkJsonAll(json.toString()); }
public static final void checkJsonAll(JsonNode json) throws InvalidParseOperationException { if (json == null || json.isMissingNode()) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } final String jsonish = JsonHandler.writeAsString(json); try { final String wellFormedJson = JsonSanitizer.sanitize(jsonish); if (!wellFormedJson.equals(jsonish)) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } } catch (final RuntimeException e) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK, e); } checkJsonFileSize(jsonish); checkJsonSanity(json); }
SanityChecker { public static final void checkJsonAll(JsonNode json) throws InvalidParseOperationException { if (json == null || json.isMissingNode()) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } final String jsonish = JsonHandler.writeAsString(json); try { final String wellFormedJson = JsonSanitizer.sanitize(jsonish); if (!wellFormedJson.equals(jsonish)) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } } catch (final RuntimeException e) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK, e); } checkJsonFileSize(jsonish); checkJsonSanity(json); } }
SanityChecker { public static final void checkJsonAll(JsonNode json) throws InvalidParseOperationException { if (json == null || json.isMissingNode()) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } final String jsonish = JsonHandler.writeAsString(json); try { final String wellFormedJson = JsonSanitizer.sanitize(jsonish); if (!wellFormedJson.equals(jsonish)) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } } catch (final RuntimeException e) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK, e); } checkJsonFileSize(jsonish); checkJsonSanity(json); } private  SanityChecker(); }
SanityChecker { public static final void checkJsonAll(JsonNode json) throws InvalidParseOperationException { if (json == null || json.isMissingNode()) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } final String jsonish = JsonHandler.writeAsString(json); try { final String wellFormedJson = JsonSanitizer.sanitize(jsonish); if (!wellFormedJson.equals(jsonish)) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } } catch (final RuntimeException e) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK, e); } checkJsonFileSize(jsonish); checkJsonSanity(json); } private  SanityChecker(); static boolean isValidFileName(String value); static final void checkXmlAll(File xmlFile); static final String sanitizeJson(JsonNode json); static final void checkJsonAll(JsonNode json); static final void checkJsonAll(String json); static final void checkParameter(String... params); static final void checkHTMLFile(File file); static final void checkHeaders(final HttpHeaders headers); static final void checkHeadersMap(MultivaluedMap<String, String> requestHeaders); static final void checkUriParametersMap(MultivaluedMap<String, String> uriParameters); static final long getLimitFileSize(); static final void setLimitFileSize(long limitFileSize); static final long getLimitJsonSize(); static final void setLimitJsonSize(long limitJsonSize); static final int getLimitFieldSize(); static final void setLimitFieldSize(int limitFieldSize); static final int getLimitParamSize(); static final void setLimitParamSize(int limitParamSize); }
SanityChecker { public static final void checkJsonAll(JsonNode json) throws InvalidParseOperationException { if (json == null || json.isMissingNode()) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } final String jsonish = JsonHandler.writeAsString(json); try { final String wellFormedJson = JsonSanitizer.sanitize(jsonish); if (!wellFormedJson.equals(jsonish)) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK); } } catch (final RuntimeException e) { throw new InvalidParseOperationException(JSON_IS_NOT_VALID_FROM_SANITIZE_CHECK, e); } checkJsonFileSize(jsonish); checkJsonSanity(json); } private  SanityChecker(); static boolean isValidFileName(String value); static final void checkXmlAll(File xmlFile); static final String sanitizeJson(JsonNode json); static final void checkJsonAll(JsonNode json); static final void checkJsonAll(String json); static final void checkParameter(String... params); static final void checkHTMLFile(File file); static final void checkHeaders(final HttpHeaders headers); static final void checkHeadersMap(MultivaluedMap<String, String> requestHeaders); static final void checkUriParametersMap(MultivaluedMap<String, String> uriParameters); static final long getLimitFileSize(); static final void setLimitFileSize(long limitFileSize); static final long getLimitJsonSize(); static final void setLimitJsonSize(long limitJsonSize); static final int getLimitFieldSize(); static final void setLimitFieldSize(int limitFieldSize); static final int getLimitParamSize(); static final void setLimitParamSize(int limitParamSize); static final String HTTP_PARAMETER_VALUE; }