本文整理汇总了Java中org.apache.cxf.message.Attachment类的典型用法代码示例。如果您正苦于以下问题:Java Attachment类的具体用法?Java Attachment怎么用?Java Attachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attachment类属于org.apache.cxf.message包,在下文中一共展示了Attachment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDataWriter
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
protected <T> DataWriter<T> getDataWriter(Message message, Service service, Class<T> output) {
DataWriter<T> writer = service.getDataBinding().createWriter(output);
Collection<Attachment> atts = message.getAttachments();
if (MessageUtils.isTrue(message.getContextualProperty(Message.MTOM_ENABLED))
&& atts == null) {
atts = new ArrayList<Attachment>();
message.setAttachments(atts);
}
writer.setAttachments(atts);
writer.setProperty(DataWriter.ENDPOINT, message.getExchange().getEndpoint());
writer.setProperty(Message.class.getName(), message);
setDataWriterValidation(service, message, writer);
return writer;
}
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:18,代码来源:AbstractOutDatabindingInterceptor.java
示例2: readInclude
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
private Object readInclude(String type, MessageReader reader,
Context context) throws DatabindingException {
String href = reader.getAttributeReader(XOP_HREF).getValue().trim();
Attachment att = org.jrubycxf.aegis.type.mtom.AttachmentUtil.getAttachment(href, context.getAttachments());
if (att == null) {
throw new DatabindingException("Could not find the attachment " + href);
}
try {
return readAttachment(att, context);
} catch (IOException e) {
throw new DatabindingException("Could not read attachment", e);
}
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:17,代码来源:AbstractXOPType.java
示例3: getAttachment
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
private Attachment getAttachment(String id) {
// this method is based off org.apache.cxf.aegis.type.mtom.AttachmentUtil implementation
if (id == null) {
log.debug("Null attachment ID.");
return null;
}
try {
id = URLDecoder.decode(id, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.info("Unable to decode attachment ID " + id, e);
return null;
}
Collection<Attachment> attachments = AttachmentCachingInterceptor.getAttachments();
for(Attachment a : attachments) {
if (id.contains(a.getId())) {
if (log.isInfoEnabled()) {
log.info("Id: " + id + " matches " + a.getId());
}
return a;
}
}
if (log.isInfoEnabled()) {
log.info("Unable to find attachment matching id: " + id);
}
return null;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:30,代码来源:XMLCipher.java
示例4: testPopulateCxfRequestFromExchange
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Test
public void testPopulateCxfRequestFromExchange() {
DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
Exchange exchange = new DefaultExchange(context);
org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
Map<String, Object> requestContext = new HashMap<String, Object>();
exchange.getIn().setHeader("soapAction", "urn:hello:world");
exchange.getIn().setHeader("MyFruitHeader", "peach");
exchange.getIn().setHeader("MyBrewHeader", Arrays.asList("cappuccino", "espresso"));
exchange.getIn().addAttachment("att-1", new DataHandler(new FileDataSource("pom.xml")));
cxfBinding.populateCxfRequestFromExchange(cxfExchange, exchange, requestContext);
// check the protocol headers
Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)requestContext.get(Message.PROTOCOL_HEADERS));
assertNotNull(headers);
assertEquals(3, headers.size());
verifyHeader(headers, "soapaction", "urn:hello:world");
verifyHeader(headers, "SoapAction", "urn:hello:world");
verifyHeader(headers, "SOAPAction", "urn:hello:world");
verifyHeader(headers, "myfruitheader", "peach");
verifyHeader(headers, "myFruitHeader", "peach");
verifyHeader(headers, "MYFRUITHEADER", "peach");
verifyHeader(headers, "MyBrewHeader", Arrays.asList("cappuccino", "espresso"));
Set<Attachment> attachments
= CastUtils.cast((Set<?>)requestContext.get(CxfConstants.CAMEL_CXF_ATTACHMENTS));
assertNotNull(attachments);
assertNotNull(attachments.size() == 1);
Attachment att = attachments.iterator().next();
assertEquals("att-1", att.getId());
}
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:DefaultCxfBindingTest.java
示例5: testPopupalteExchangeFromCxfResponse
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Test
public void testPopupalteExchangeFromCxfResponse() {
DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
Exchange exchange = new DefaultExchange(context);
org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
Map<String, Object> responseContext = new HashMap<String, Object>();
responseContext.put(org.apache.cxf.message.Message.RESPONSE_CODE, Integer.valueOf(200));
Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
headers.put("content-type", Arrays.asList("text/xml;charset=UTF-8"));
headers.put("Content-Length", Arrays.asList("241"));
responseContext.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
cxfExchange.setInMessage(cxfMessage);
Set<Attachment> attachments = new HashSet<Attachment>();
attachments.add(new AttachmentImpl("att-1", new DataHandler(new FileDataSource("pom.xml"))));
cxfMessage.setAttachments(attachments);
cxfBinding.populateExchangeFromCxfResponse(exchange, cxfExchange, responseContext);
Map<String, Object> camelHeaders = exchange.getOut().getHeaders();
assertNotNull(camelHeaders);
assertEquals(responseContext, camelHeaders.get(Client.RESPONSE_CONTEXT));
Map<String, DataHandler> camelAttachments = exchange.getOut().getAttachments();
assertNotNull(camelAttachments);
assertNotNull(camelAttachments.get("att-1"));
}
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:DefaultCxfBindingTest.java
示例6: testPopupalteExchangeFromCxfRequest
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Test
public void testPopupalteExchangeFromCxfRequest() {
DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
Exchange exchange = new DefaultExchange(context);
org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
headers.put("content-type", Arrays.asList("text/xml;charset=UTF-8"));
headers.put("Content-Length", Arrays.asList("241"));
headers.put("soapAction", Arrays.asList("urn:hello:world"));
headers.put("myfruitheader", Arrays.asList("peach"));
headers.put("mybrewheader", Arrays.asList("cappuccino", "espresso"));
cxfMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
Set<Attachment> attachments = new HashSet<Attachment>();
attachments.add(new AttachmentImpl("att-1", new DataHandler(new FileDataSource("pom.xml"))));
cxfMessage.setAttachments(attachments);
cxfExchange.setInMessage(cxfMessage);
cxfBinding.populateExchangeFromCxfRequest(cxfExchange, exchange);
Map<String, Object> camelHeaders = exchange.getIn().getHeaders();
assertNotNull(camelHeaders);
assertEquals("urn:hello:world", camelHeaders.get("soapaction"));
assertEquals("urn:hello:world", camelHeaders.get("SoapAction"));
assertEquals("text/xml;charset=UTF-8", camelHeaders.get("content-type"));
assertEquals("241", camelHeaders.get("content-length"));
assertEquals("peach", camelHeaders.get("MyFruitHeader"));
assertEquals(Arrays.asList("cappuccino", "espresso"), camelHeaders.get("MyBrewHeader"));
Map<String, DataHandler> camelAttachments = exchange.getIn().getAttachments();
assertNotNull(camelAttachments);
assertNotNull(camelAttachments.get("att-1"));
}
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:DefaultCxfBindingTest.java
示例7: message
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void message(MessageHeader messageHeader, SyncReply syncReply, MessageOrder messageOrder, AckRequested ackRequested, Manifest manifest)
{
Collection<Attachment> attachments = AttachmentManager.get();
List<DataSource> dataSources = new ArrayList<DataSource>();
for (Attachment attachment : attachments)
dataSources.add(new EbMSDataSource(attachment.getDataHandler().getDataSource(),attachment.getId(),attachment.getDataHandler().getName()));
messageProcessor.process(new EbMSMessage(MessageManager.get(),SignatureManager.get() == null ? null : SignatureManager.get().getSignature(),messageHeader,syncReply,messageOrder,ackRequested,manifest,dataSources),SignatureManager.get());
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:10,代码来源:EbMSPortTypeImpl.java
示例8: handleMessage
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
Collection<Attachment> attachments = message.getAttachments();
if (attachments != null)
AttachmentManager.set(attachments);
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:8,代码来源:AttachmentInInterceptor.java
示例9: handleMessage
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
try
{
KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
if (message.getAttachments() != null)
for (Attachment attachment : message.getAttachments())
{
DataSource ds = attachment.getDataHandler().getDataSource();
dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
}
sign(keyStore,keyPair,keyAlias,document,dataSources);
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:38,代码来源:XMLSecSignatureOutInterceptor.java
示例10: handleMessage
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
try
{
KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
if (isSigned(document))
{
List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
if (message.getAttachments() != null)
for (Attachment attachment : message.getAttachments())
{
DataSource ds = attachment.getDataHandler().getDataSource();
dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
}
sign(keyStore,keyPair,keyAlias,document,dataSources);
}
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:41,代码来源:EbMSSecSignatureOutInterceptor.java
示例11: handleMessage
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
try
{
KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
StringBuilder sb = new StringBuilder();
os.writeCacheTo(sb);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
if (message.getAttachments() != null)
for (Attachment attachment : message.getAttachments())
{
DataSource ds = attachment.getDataHandler().getDataSource();
dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
}
sign(keyStore,keyPair,keyAlias,document,dataSources);
OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document),new StreamResult(originalOs));
message.setContent(OutputStream.class,originalOs);
}
catch (Exception e)
{
throw new Fault(e);
}
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:38,代码来源:XMLDSignatureOutInterceptor.java
示例12: transform
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public Object transform(MuleMessage message, String outputEncoding) throws TransformerException
{
EbMSMessage msg = (EbMSMessage)message.getPayload();
message.setPayload(new Object[]{msg.getMessageHeader(),null,null,msg.getAckRequested(),msg.getManifest()});
Collection<Attachment> attachments = new ArrayList<Attachment>();
for (int i = 0; i < msg.getAttachments().size(); i++)
attachments.add(new nl.clockwork.common.cxf.Attachment("" + (i + 1),msg.getAttachments().get(i)));
AttachmentManager.set(attachments);
return message;
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:14,代码来源:EbMSMessageToCXFMessage.java
示例13: handleMessage
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
Collection<Attachment> attachments = AttachmentManager.get();
if (attachments != null)
message.setAttachments(attachments);
}
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:8,代码来源:AttachmentOutInterceptor.java
示例14: getAttachment
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
public static Attachment getAttachment(String id, Collection<Attachment> attachments) {
if (id == null) {
throw new DatabindingException("Cannot get attachment: null id");
}
int i = id.indexOf("cid:");
if (i != -1) {
id = id.substring(4).trim();
}
if (attachments == null) {
return null;
}
for (Iterator<Attachment> iter = attachments.iterator(); iter.hasNext();) {
Attachment a = iter.next();
if (a.getId().equals(id)) {
return a;
}
}
// Try loading the URL remotely
try {
URLDataSource source = new URLDataSource(new URL(id));
return new AttachmentImpl(id, new DataHandler(source));
} catch (MalformedURLException e) {
return null;
}
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:29,代码来源:AttachmentUtil.java
示例15: createAttachment
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
protected Attachment createAttachment(Object object, String id) {
DataSource source = (DataSource)object;
DataHandler handler = new DataHandler(source);
AttachmentImpl att = new AttachmentImpl(id, handler);
att.setXOP(true);
return att;
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:10,代码来源:DataSourceType.java
示例16: createAttachment
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
protected Attachment createAttachment(Object object, String id) {
DataHandler handler = (DataHandler)object;
AttachmentImpl att = new AttachmentImpl(id, handler);
att.setXOP(true);
return att;
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:10,代码来源:DataHandlerType.java
示例17: writeObject
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
public void writeObject(Object object, MessageWriter writer,
Context context) throws DatabindingException {
// add the content type attribute even if we are going to fall back.
String contentType = getContentType(object, context);
if (contentType != null && useXmimeBinaryType) {
MessageWriter ctWriter = writer.getAttributeWriter(XML_MIME_CONTENT_TYPE);
ctWriter.writeValue(contentType);
}
if (!context.isMtomEnabled()) {
fallbackDelegate.writeObject(getBytes(object), writer, context);
return;
}
Collection<Attachment> attachments = context.getAttachments();
if (attachments == null) {
attachments = new ArrayList<Attachment>();
context.setAttachments(attachments);
}
String id = org.jrubycxf.aegis.type.mtom.AttachmentUtil.createContentID(getSchemaType().getNamespaceURI());
Attachment att = createAttachment(object, id);
attachments.add(att);
MessageWriter include = writer.getElementWriter(XOP_INCLUDE);
MessageWriter href = include.getAttributeWriter(XOP_HREF);
href.writeValue("cid:" + id);
include.close();
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:34,代码来源:AbstractXOPType.java
示例18: readAttachment
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
protected Object readAttachment(Attachment att, Context context) throws IOException {
DataHandler handler = att.getDataHandler();
InputStream is = handler.getInputStream();
// try
// {
ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(is, out);
is.close();
return out.toByteArray();
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:13,代码来源:ByteArrayType.java
示例19: createAttachment
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
@Override
protected Attachment createAttachment(Object object, String id) {
byte[] data = (byte[])object;
ByteDataSource source = new ByteDataSource(data);
source.setContentType(getContentType(object, null));
AttachmentImpl att = new AttachmentImpl(id, new DataHandler(source));
att.setXOP(true);
return att;
}
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:12,代码来源:ByteArrayType.java
示例20: decryptElement
import org.apache.cxf.message.Attachment; //导入依赖的package包/类
/**
* Decrypts <code>EncryptedData</code> in a single-part operation.
*
* @param element the <code>EncryptedData</code> to decrypt.
* @return the <code>Node</code> as a result of the decrypt operation.
* @throws XMLEncryptionException
*/
private Document decryptElement(Element element) throws XMLEncryptionException {
if (log.isDebugEnabled()) {
log.debug("Decrypting element...");
}
if (serializer instanceof AbstractSerializer) {
((AbstractSerializer)serializer).setSecureValidation(secureValidation);
}
if (cipherMode != DECRYPT_MODE) {
log.error("XMLCipher unexpectedly not in DECRYPT_MODE...");
}
byte[] octets = decryptToByteArray(element);
if (log.isDebugEnabled()) {
log.debug("Decrypted octets:\n" + new String(octets));
}
Node sourceParent = element.getParentNode();
// MCEDT HACK START
// CXF 2.7.4 does not handle MTOM attachments properly. This is
// due to the design of the attachment processing in ReferenceListProcessor.
// The decrypted attachments are appended back to the Securty header
// while the original Attachment instances are not replaced.
// this hack fixes that by replacing the content of the Attachment
// instances
boolean isAttachmentOnly = isAttachmentOnly(element);
if (isAttachmentOnly) {
String id = element.getAttribute("Id");
Attachment attachment = getAttachment(id);
if (attachment != null) {
replaceAttachmentContent(octets, attachment);
}
}
// MCEDT HACK END
Node decryptedNode = serializer.deserialize(octets, sourceParent);
// The de-serialiser returns a node whose children we need to take on.
if (sourceParent != null && Node.DOCUMENT_NODE == sourceParent.getNodeType()) {
// If this is a content decryption, this may have problems
contextDocument.removeChild(contextDocument.getDocumentElement());
contextDocument.appendChild(decryptedNode);
} else if (sourceParent != null) {
sourceParent.replaceChild(decryptedNode, element);
}
return contextDocument;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:58,代码来源:XMLCipher.java
注:本文中的org.apache.cxf.message.Attachment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论