public DepthRestrictingStreamReader(XMLStreamReader reader, int elementCountThreshold, int innerElementLevelThreshold, int innerElementCountThreshold) { this(reader, new DocumentDepthProperties(elementCountThreshold, innerElementLevelThreshold, innerElementCountThreshold)); }
protected JSONTokener createNewJSONTokener(String doc) { return new JSONTokener(doc, depthProps.getInnerElementCountThreshold()); } }
private static class LocationUserDataHandler implements UserDataHandler { public static final LocationUserDataHandler INSTANCE = new LocationUserDataHandler(); public void handle(short operation, String key, Object data, Node src, Node dst) { if (operation == NODE_CLONED) { dst.setUserData(key, data, this); } } }
@Override public int next() throws XMLStreamException { int next = super.next(); if (next == START_ELEMENT) { if (props.getInnerElementLevelThreshold() != -1 && getDepth() >= props.getInnerElementLevelThreshold()) { throw new DepthExceededStaxException(); } if (props.getElementCountThreshold() != -1 && ++totalElementCount >= props.getElementCountThreshold()) { throw new DepthExceededStaxException(); } if (props.getInnerElementCountThreshold() != -1) { if (!stack.empty()) { int currentCount = stack.pop(); if (++currentCount >= props.getInnerElementCountThreshold()) { throw new DepthExceededStaxException(); } else { stack.push(currentCount); } } stack.push(0); } } else if (next == END_ELEMENT && props.getInnerElementCountThreshold() != -1) { stack.pop(); } return next; } }
@SuppressWarnings({ "rawtypes" }) protected JAXBElementProvider<?> defaultJAXBProvider() { JAXBElementProvider<?> defaultJAXBProvider = new JAXBElementProvider(); DocumentDepthProperties depthProperties = new DocumentDepthProperties(); depthProperties.setInnerElementCountThreshold(500); defaultJAXBProvider.setDepthProperties(depthProperties); Map<String, Object> marshallerProperties = new HashMap<>(); marshallerProperties.put(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); defaultJAXBProvider.setMarshallerProperties(marshallerProperties); Map<String, String> collectionWrapperMap = new HashMap<>(); collectionWrapperMap.put(PolicyTO.class.getName(), "policies"); defaultJAXBProvider.setCollectionWrapperMap(collectionWrapperMap); return defaultJAXBProvider; }
protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) { DocumentDepthProperties props = getDepthProperties(); if (props != null && props.isEffective()) { reader = TransformUtils.createNewReaderIfNeeded(reader, is); reader = new DepthRestrictingStreamReader(reader, props); } else if (reader != null) { reader = configureReaderRestrictions(reader); } return reader; }
private static class LocationUserDataHandler implements UserDataHandler { public static final LocationUserDataHandler INSTANCE = new LocationUserDataHandler(); public void handle(short operation, String key, Object data, Node src, Node dst) { if (operation == NODE_CLONED) { dst.setUserData(key, data, this); } } }
@Override public int next() throws XMLStreamException { int next = super.next(); if (next == START_ELEMENT) { if (props.getInnerElementLevelThreshold() != -1 && getDepth() >= props.getInnerElementLevelThreshold()) { throw new DepthExceededStaxException(); } if (props.getElementCountThreshold() != -1 && ++totalElementCount >= props.getElementCountThreshold()) { throw new DepthExceededStaxException(); } if (props.getInnerElementCountThreshold() != -1) { if (!stack.empty()) { int currentCount = stack.pop(); if (++currentCount >= props.getInnerElementCountThreshold()) { throw new DepthExceededStaxException(); } stack.push(currentCount); } stack.push(0); } } else if (next == END_ELEMENT && props.getInnerElementCountThreshold() != -1) { stack.pop(); } return next; } }
@SuppressWarnings({ "rawtypes" }) protected JAXBElementProvider<?> defaultJAXBProvider() { JAXBElementProvider<?> defaultJAXBProvider = new JAXBElementProvider(); DocumentDepthProperties depthProperties = new DocumentDepthProperties(); depthProperties.setInnerElementCountThreshold(500); defaultJAXBProvider.setDepthProperties(depthProperties); Map<String, Object> marshallerProperties = new HashMap<>(); marshallerProperties.put(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); defaultJAXBProvider.setMarshallerProperties(marshallerProperties); Map<String, String> collectionWrapperMap = new HashMap<>(); collectionWrapperMap.put(PolicyTO.class.getName(), "policies"); defaultJAXBProvider.setCollectionWrapperMap(collectionWrapperMap); return defaultJAXBProvider; }
protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) { DocumentDepthProperties props = getDepthProperties(); if (props != null && props.isEffective()) { reader = TransformUtils.createNewReaderIfNeeded(reader, is); reader = new DepthRestrictingStreamReader(reader, props); } else if (reader != null) { reader = configureReaderRestrictions(reader); } return reader; }
private static class LocationUserDataHandler implements UserDataHandler { public static final LocationUserDataHandler INSTANCE = new LocationUserDataHandler(); public void handle(short operation, String key, Object data, Node src, Node dst) { if (operation == NODE_CLONED) { dst.setUserData(key, data, this); } } }
@Override public int next() throws XMLStreamException { int next = super.next(); if (next == START_ELEMENT) { if (props.getInnerElementLevelThreshold() != -1 && getDepth() >= props.getInnerElementLevelThreshold()) { throw new DepthExceededStaxException(); } if (props.getElementCountThreshold() != -1 && ++totalElementCount >= props.getElementCountThreshold()) { throw new DepthExceededStaxException(); } if (props.getInnerElementCountThreshold() != -1) { if (!stack.empty()) { int currentCount = stack.pop(); if (++currentCount >= props.getInnerElementCountThreshold()) { throw new DepthExceededStaxException(); } stack.push(currentCount); } stack.push(0); } } else if (next == END_ELEMENT && props.getInnerElementCountThreshold() != -1) { stack.pop(); } return next; } }
public DepthRestrictingStreamReader(XMLStreamReader reader, int elementCountThreshold, int innerElementLevelThreshold, int innerElementCountThreshold) { this(reader, new DocumentDepthProperties(elementCountThreshold, innerElementLevelThreshold, innerElementCountThreshold)); }
protected JSONTokener createNewJSONTokener(String doc) { return new JSONTokener(doc, depthProps.getInnerElementCountThreshold()); } }
private static class LocationUserDataHandler implements UserDataHandler { public static final LocationUserDataHandler INSTANCE = new LocationUserDataHandler(); public void handle(short operation, String key, Object data, Node src, Node dst) { if (operation == NODE_CLONED) { dst.setUserData(key, data, this); } } }
@Override public int next() throws XMLStreamException { int next = super.next(); if (next == START_ELEMENT) { if (props.getInnerElementLevelThreshold() != -1 && getDepth() >= props.getInnerElementLevelThreshold()) { throw new DepthExceededStaxException(); } if (props.getElementCountThreshold() != -1 && ++totalElementCount >= props.getElementCountThreshold()) { throw new DepthExceededStaxException(); } if (props.getInnerElementCountThreshold() != -1) { if (!stack.empty()) { int currentCount = stack.pop(); if (++currentCount >= props.getInnerElementCountThreshold()) { throw new DepthExceededStaxException(); } else { stack.push(currentCount); } } stack.push(0); } } else if (next == END_ELEMENT && props.getInnerElementCountThreshold() != -1) { stack.pop(); } return next; } }
public DepthRestrictingStreamReader(XMLStreamReader reader, int elementCountThreshold, int innerElementLevelThreshold, int innerElementCountThreshold) { this(reader, new DocumentDepthProperties(elementCountThreshold, innerElementLevelThreshold, innerElementCountThreshold)); }
protected JSONTokener createNewJSONTokener(String doc) { return new JSONTokener(doc, depthProps.getInnerElementCountThreshold()); } }
} catch (Throwable t) { p = new DocumentDepthProperties(); p.setInnerElementCountThreshold(maxChildElements); p = new DocumentDepthProperties(); p.setInnerElementLevelThreshold(maxElementDepth); p = new DocumentDepthProperties(); p.setElementCountThreshold(maxElementCount.intValue());
@Override public int next() throws XMLStreamException { int next = super.next(); if (next == START_ELEMENT) { if (props.getInnerElementLevelThreshold() != -1 && getDepth() >= props.getInnerElementLevelThreshold()) { throw new DepthExceededStaxException(); } if (props.getElementCountThreshold() != -1 && ++totalElementCount >= props.getElementCountThreshold()) { throw new DepthExceededStaxException(); } if (props.getInnerElementCountThreshold() != -1) { if (!stack.empty()) { int currentCount = stack.pop(); if (++currentCount >= props.getInnerElementCountThreshold()) { throw new DepthExceededStaxException(); } else { stack.push(currentCount); } } stack.push(0); } } else if (next == END_ELEMENT && props.getInnerElementCountThreshold() != -1) { stack.pop(); } return next; } }