当前位置: 首页>>代码示例>>Java>>正文


Java SoapMessage.getAttachments方法代码示例

本文整理汇总了Java中org.apache.cxf.binding.soap.SoapMessage.getAttachments方法的典型用法代码示例。如果您正苦于以下问题:Java SoapMessage.getAttachments方法的具体用法?Java SoapMessage.getAttachments怎么用?Java SoapMessage.getAttachments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cxf.binding.soap.SoapMessage的用法示例。


在下文中一共展示了SoapMessage.getAttachments方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMessage

import org.apache.cxf.binding.soap.SoapMessage; //导入方法依赖的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

示例2: handleMessage

import org.apache.cxf.binding.soap.SoapMessage; //导入方法依赖的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

示例3: handleMessage

import org.apache.cxf.binding.soap.SoapMessage; //导入方法依赖的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

示例4: handleMessage

import org.apache.cxf.binding.soap.SoapMessage; //导入方法依赖的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

示例5: handleMessage

import org.apache.cxf.binding.soap.SoapMessage; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
	try
	{
		KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);

		XMLStreamReader reader = message.getContent(XMLStreamReader.class);
		Document document = StaxUtils.read(reader);
		XMLStreamReader copy = StaxUtils.createXMLStreamReader(document);
		message.setContent(XMLStreamReader.class,copy);

		List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
		if (message.getAttachments() != null)
			for (Attachment attachment : message.getAttachments())
				dataSources.add(new EbMSDataSource(attachment.getDataHandler().getDataSource(),attachment.getId(),attachment.getDataHandler().getName()));

		NodeList signatureNodeList = document.getElementsByTagNameNS(org.apache.xml.security.utils.Constants.SignatureSpecNS,org.apache.xml.security.utils.Constants._TAG_SIGNATURE);
		if (signatureNodeList.getLength() > 0)
		{
			boolean isValid = false;
			X509Certificate certificate = getCertificate(document);
			if (certificate != null)
			{
				isValid = validateCertificate(keyStore,certificate,new Date()/*TODO get date from message???*/);
				if (!isValid)
					logger.info("Certificate invalid.");
				else
				{
					isValid = verify(certificate,signatureNodeList,dataSources);
					logger.info("Signature" + (isValid ? " " : " in") + "valid.");
				}
			}
			SignatureManager.set(new Signature(certificate,XMLMessageBuilder.getInstance(SignatureType.class).handle(signatureNodeList.item(0)),isValid));
		}
		else
			SignatureManager.set(null);
	}
	catch (Exception e)
	{
		throw new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:44,代码来源:EbMSSecSignatureInInterceptor.java


注:本文中的org.apache.cxf.binding.soap.SoapMessage.getAttachments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。