/** * Mark the requied Base64 text values as optimized * @param env * @param optimizeParts This is a set of xPath expressions * * @throws WSSecurityException */ public static void optimize(SOAPEnvelope env, String optimizeParts) throws WSSecurityException { String separater = "<>"; StringTokenizer tokenizer = new StringTokenizer(optimizeParts, separater); while(tokenizer.hasMoreTokens()) { String xpathExpr = tokenizer.nextToken(); //Find binary content List list = findElements(env,xpathExpr); Iterator cipherValueElements = list.iterator(); while (cipherValueElements.hasNext()) { OMElement element = (OMElement) cipherValueElements.next(); OMText text = (OMText)element.getFirstOMChild(); text.setOptimize(true); } } }
public OMElement echoMTOMtoBase64(OMElement omEle) { OMText omText = (OMText)(omEle.getFirstElement()).getFirstOMChild(); omText.setOptimize(false); return omEle; } }
public OMElement echoMTOMtoBase64(OMElement omEle) { OMText omText = (OMText)(omEle.getFirstElement()).getFirstOMChild(); omText.setOptimize(false); return omEle; } }
public OMElement echoMTOMtoBase64(OMElement omEle) { OMText omText = (OMText)(omEle.getFirstElement()).getFirstOMChild(); omText.setOptimize(false); return omEle; } }
public void MTOMPing(OMElement in) throws Exception { OMElement attachmentElem = in.getFirstChildWithName(new QName(applicationNamespaceName, Attachment)); if (attachmentElem == null) throw new AxisFault("'Attachment' element is not present as a child of the 'Ping' element"); OMText binaryElem = (OMText) attachmentElem.getFirstOMChild(); binaryElem.setOptimize(true); DataHandler dataHandler = (DataHandler) binaryElem.getDataHandler(); try { File destinationFile = new File(DESTINATION_IMAGE_FILE); if (destinationFile.exists()) destinationFile.delete(); FileOutputStream fileOutputStream = new FileOutputStream(DESTINATION_IMAGE_FILE); InputStream inputStream = dataHandler.getDataSource().getInputStream(); byte[] bytes = new byte[5000]; int length = inputStream.read(bytes); fileOutputStream.write(bytes, 0, length); fileOutputStream.close(); } catch (Exception e) { throw AxisFault.makeFault(e); } } }
public OMElement getBody() { OMElement sor = MetadataSupport.firstChildWithLocalName(metadataEle, "SubmitObjectsRequest"); if (sor == null) { String msg = "MtomBuilder: cannot find SubmitObjectsRequest child in PnR"; logger.error(msg); throw new ToolkitRuntimeException(msg); } for (String id : documentMap.getIds()) { Document document = documentMap.getDocument(id); javax.activation.DataHandler dataHandler = new javax.activation.DataHandler(document.getDataSource()); OMText t = MetadataSupport.om_factory.createOMText(dataHandler, true); t.setOptimize(true); OMElement documentEle = MetadataSupport.om_factory.createOMElement("Document", MetadataSupport.xdsB); documentEle.addAttribute("id", id, null); documentEle.addChild(t); // metadataEle.addChild(documentEle); sor.insertSiblingAfter(documentEle); } return metadataEle; }
public static void optimize(SOAPEnvelope env, List<String> expressions, Map namespaces) throws RampartException { SimpleNamespaceContext nsCtx = new SimpleNamespaceContext(); nsCtx.addNamespace(WSConstants.ENC_PREFIX,WSConstants.ENC_NS); nsCtx.addNamespace(WSConstants.SIG_PREFIX,WSConstants.SIG_NS); nsCtx.addNamespace(WSConstants.WSSE_PREFIX,WSConstants.WSSE_NS); nsCtx.addNamespace(WSConstants.WSU_PREFIX,WSConstants.WSU_NS); Iterator keys = namespaces.keySet().iterator(); while(keys.hasNext()){ String strPrefix = (String)keys.next(); String strNS = (String)namespaces.get(strPrefix); nsCtx.addNamespace(strPrefix,strNS); } try { for (String exp : expressions) { XPath xp = new AXIOMXPath(exp); xp.setNamespaceContext(nsCtx); List list = xp.selectNodes(env); for (Object aList : list) { OMElement element = (OMElement) aList; OMText text = (OMText) element.getFirstOMChild(); text.setOptimize(true); } } } catch (JaxenException e) { throw new RampartException("Error in XPath ", e); } }
t.setOptimize(use_mtom); OMElement document = MetadataSupport.om_factory.createOMElement("Document", MetadataSupport.xdsB); document.addAttribute("id", id, null);