/** * @return count of bytes read */ public long length() throws IOException { if (localStream == null) { detach(); } return count; }
long getContentLength() throws IOException { if (contentLength > 0) { return contentLength; } else { // Ensure all parts are read fetchAllParts(); // Now get the count from the filter return filterIS.length(); } }
DetachableInputStream is = new DetachableInputStream(inputStream); messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is);
log.debug("detach caught exception. Processing continues:" + t); log.debug(" " + stackToString(t));
InputStream getInputStream(boolean preserve) throws IOException { if (!preserve && state == STATE_UNREAD) { checkParserState(parser.getState(), EntityState.T_BODY); state = STATE_STREAMING; detachableInputStream = new DetachableInputStream(getDecodedInputStream()); return detachableInputStream; } else { WritableBlob content = getContent(); if (preserve) { return content.getInputStream(); } else if (content instanceof MemoryBlob) { return ((MemoryBlob)content).readOnce(); } else { return new ReadOnceInputStreamWrapper(this, content.getInputStream()); } } }
/** * This method can be called by components wishing to detach the DetachableInputStream * object that is present on the MessageContext. This is meant to shield components * from any logic that needs to be executed on the DetachableInputStream in order to * have it effectively detached. If the DetachableInputStream is not present, or if * the supplied MessageContext is null, no action will be taken. */ public static void detachInputStream(MessageContext msgContext) throws AxisFault { try { if(msgContext != null && msgContext.getProperty(Constants.DETACHABLE_INPUT_STREAM) != null) { DetachableInputStream dis = (DetachableInputStream) msgContext.getProperty(Constants.DETACHABLE_INPUT_STREAM); if(log.isDebugEnabled()) { log.debug("Detaching DetachableInputStream: " + dis); } dis.detach(); } else { if(log.isDebugEnabled()) { log.debug("Detach not performed for MessageContext: " + msgContext); } } } catch(Throwable t) { throw AxisFault.makeFault(t); } }
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault { try { String charSetEncoding = (String) messageContext .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); // Apply a detachable inputstream. This can be used later // to (a) get the length of the incoming message or (b) // free transport resources. DetachableInputStream is = new DetachableInputStream(inputStream); messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is); // createSOAPModelBuilder takes care of configuring the underlying parser to // avoid the security issue described in CVE-2010-1632 OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(is, charSetEncoding); SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement(); BuilderUtil .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope); BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument() .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI()); return envelope; } catch (IOException e) { throw AxisFault.makeFault(e); } }
/** * @return inbound content length of 0 */ public long getInboundContentLength() throws IOException { // If there is an attachment map, the Attachments keep track // of the inbound content length. if (attachments != null) { // return attachments.getContentLength(); } // Otherwise the length is accumulated by the DetachableInputStream. DetachableInputStream dis = (DetachableInputStream) getProperty(Constants.DETACHABLE_INPUT_STREAM); if (dis != null) { return dis.length(); } return 0; } /**
detachableInputStream.detach(); } catch (IOException ex) { throw new OMException(ex);
filterIS = new DetachableInputStream(inStream); is = filterIS; } else {
log.debug("Detaching input stream after SOAPEnvelope construction"); dis.detach();