/** * Gets the attachment as a {@link javax.activation.DataHandler}. */ public DataHandler asDataHandler() { try { return ap.getDataHandler(); } catch (SOAPException e) { throw new WebServiceException(e); } }
@Override public DataHandler getDataHandler() { try { return saajAttachment.getDataHandler(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } }
/** * Gets the attachment as a {@link javax.activation.DataHandler}. */ public DataHandler asDataHandler() { try { return ap.getDataHandler(); } catch (SOAPException e) { throw new WebServiceException(e); } }
@Override public DataHandler getDataHandler() { try { return saajAttachment.getDataHandler(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } }
public DataHandler getDataHandler() { try { return saajAttachment.getDataHandler(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } }
@Override public DataHandler getDataHandler() { try { return saajAttachment.getDataHandler(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } } }
/** * Gets the attachment as a {@link javax.activation.DataHandler}. */ public DataHandler asDataHandler() { try { return ap.getDataHandler(); } catch (SOAPException e) { throw new WebServiceException(e); } }
public static final Object[] _getSignatureInput(AttachmentPart _part) throws SOAPException, IOException { Iterator mhItr = _part.getAllMimeHeaders(); Vector mhs = new Vector(); while (mhItr.hasNext()) mhs.add(mhItr.next()); // extract Content //Object content = _part.getContent(); OutputStream baos = new ByteArrayOutputStream(); _part.getDataHandler().writeTo(baos); return new Object[] {mhs, ((ByteArrayOutputStream)baos).toByteArray()}; } }
@Override public InputStream getInputStream() throws IOException { try { return saajAttachment.getDataHandler().getInputStream(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } }
@Override public InputStream getInputStream() throws IOException { try { return saajAttachment.getDataHandler().getInputStream(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } }
public InputStream getInputStream() throws IOException { try { return saajAttachment.getDataHandler().getInputStream(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } }
@Override public InputStream getInputStream() throws IOException { try { return saajAttachment.getDataHandler().getInputStream(); } catch (SOAPException ex) { throw new SaajAttachmentException(ex); } }
private javax.xml.crypto.Data canonicalize(AttachmentData data,OutputStream outputStream) throws javax.xml.crypto.dsig.TransformException{ try{ AttachmentPart attachment = data.getAttachmentPart(); ByteArrayOutputStream os = new ByteArrayOutputStream(); attachment.getDataHandler().writeTo(os); OutputStream byteStream = null; ByteArrayInputStream byteInputStream = new ByteArrayInputStream(os.toByteArray()); if(outputStream == null){ byteStream = new ByteArrayOutputStream(); }else{ byteStream = outputStream; } Canonicalizer canonicalizer = CanonicalizerFactory.getCanonicalizer(attachment.getContentType()); InputStream is = canonicalizer.canonicalize(byteInputStream,byteStream); if(is!= null) return new OctetStreamData(is); return null; }catch(javax.xml.crypto.dsig.TransformException te){ logger.log(Level.SEVERE,"WSS1318.ac.transform.error",te); throw te; }catch(Exception ex){ logger.log(Level.SEVERE,"WSS1318.ac.transform.error",ex); throw new javax.xml.crypto.dsig.TransformException(ex.getMessage()); } }
public static void cleanupAttachments(CommonMessageContext messageContext) { // cleanup attachments SOAPMessage msg = messageContext.getSOAPMessage(); if(msg!=null && (msg instanceof SOAPMessage)) // in case of http binding { Iterator<?> it = ((SOAPMessage)msg).getAttachments(); while(it.hasNext()) { AttachmentPart attachment = (AttachmentPart)it.next(); try { if(attachment.getDataHandler().getDataSource() instanceof SwapableMemoryDataSource) { SwapableMemoryDataSource swapFile = (SwapableMemoryDataSource)attachment.getDataHandler().getDataSource(); swapFile.cleanup(); } } catch (SOAPException e) { NativeLoggers.ROOT_LOGGER.failedToCleanupAttachmentPart(e); } } } } }
String contentId = attachment.getContentId(); if (contentId != null) { DataHandler dh = attachment.getDataHandler(); if (dh == null) { throw new SOAPException("Attachment with NULL DataHandler");
byte[] outputHeaderBytes = mHCanonicalizer._canonicalize(mimeHeaders); OutputStream byteStream = new UnsyncByteArrayOutputStream(); attachment.getDataHandler().writeTo(byteStream); ByteArrayInputStream byteInputStream = new ByteArrayInputStream(((ByteArrayOutputStream)byteStream).toByteArray()); byteStream.close();
/** * Convert a SAAJ message to an Axiom SOAP envelope object and process xop:Include * elements. * * @param message the SAAJ message * @return the OM SOAP envelope * @throws SOAPException */ public static org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope( javax.xml.soap.SOAPMessage message) throws SOAPException { Attachments attachments = new Attachments(); for (Iterator it = message.getAttachments(); it.hasNext(); ) { AttachmentPart attachment = (AttachmentPart)it.next(); String contentId = attachment.getContentId(); if (contentId != null) { DataHandler dh = attachment.getDataHandler(); if (dh == null) { throw new SOAPException("Attachment with NULL DataHandler"); } if (contentId.startsWith("<") && contentId.endsWith(">")) { contentId = contentId.substring(1, contentId.length()-1); } attachments.addDataHandler(contentId, dh); } } OMElement docElem = (OMElement)message.getSOAPPart().getDocumentElement(); MTOMStAXSOAPModelBuilder builder = new MTOMStAXSOAPModelBuilder(docElem.getXMLStreamReader(), attachments); return builder.getSOAPEnvelope(); }
part.getDataHandler().writeTo(baos); cipherInput = ((ByteArrayOutputStream)baos).toByteArray(); } else {
protected void addAttachmentParts(MimeMultipart multipart) throws SOAPException, MessagingException { Iterator attachmentParts = soapMessage.getAttachments(); while (attachmentParts.hasNext()) { AttachmentPart attachmentPart = (AttachmentPart)attachmentParts.next(); DataHandler handler = attachmentPart.getDataHandler(); MimeBodyPart mimePart = new MimeBodyPart(); mimePart.setDataHandler(handler); Iterator mimeHeaders = attachmentPart.getAllMimeHeaders(); while (mimeHeaders.hasNext()) { MimeHeader soapHeader = (MimeHeader)mimeHeaders.next(); mimePart.addHeader(soapHeader.getName(), soapHeader.getValue()); } if (mimePart.getHeader(MimeConstants.CONTENT_TYPE) == null) { String type = handler.getContentType(); mimePart.setHeader(MimeConstants.CONTENT_TYPE, (type != null) ? type : MimeConstants.TYPE_APPLICATION_OCTET_STREAM); } if (mimePart.getHeader(MimeConstants.CONTENT_ID) == null) { mimePart.setHeader(MimeConstants.CONTENT_ID, CIDGenerator.generateFromCount()); } // TODO - Binary encoding is the most efficient, however, some transports (old mail servers) // require 7 bit ascii. Can we ask the remoting layer about the transport's binary safety? mimePart.setHeader(MimeConstants.CONTENT_TRANSFER_ENCODING, MimeConstants.BINARY_ENCODING); multipart.addBodyPart(mimePart); } }
AttachmentImpl att = new AttachmentImpl(id); try { att.setDataHandler(part.getDataHandler()); } catch (SOAPException e) { throw new Fault(e);