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


Java StaxUtils.read方法代码示例

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


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

示例1: invokeStream

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
public SOAPMessage invokeStream(InputStream in) {
    SOAPMessage response = null;
    try {
        Document doc = StaxUtils.read(in);
        if (doc.getElementsByTagNameNS(greetMe.getNamespaceURI(), 
                                       sayHi.getLocalPart()).getLength() == 1) {
            response = sayHiResponse;
        } else if (doc.getElementsByTagNameNS(greetMe.getNamespaceURI(), 
                                              greetMe.getLocalPart()).getLength() == 1) {
            response = greetMeResponse;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return response;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:SoapTargetBean.java

示例2: getNode

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
public synchronized Node getNode() {
	Node nd = super.getNode();
	if (nd == null) {
		try {
			InputSource src = new InputSource(resource.openStream());
			src.setSystemId(this.getSystemId());
			src.setPublicId(publicId);
			Document doc = StaxUtils.read(src);
			setNode(doc);
			nd = super.getNode();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}
	return nd;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:17,代码来源:JAXBDataBinding.java

示例3: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault {
    DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
    try {
        // put the payload source as a document
        Document doc = StaxUtils.read(xmlReader);
        message.setContent(Source.class, new DOMSource(doc));
    } catch (XMLStreamException e) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:DataInInterceptor.java

示例4: spMetadata

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Test
public void spMetadata() {
    assumeTrue(SAML2SPDetector.isSAML2SPAvailable());

    try {
        SAML2SPService service = anonymous.getService(SAML2SPService.class);
        WebClient.client(service).accept(MediaType.APPLICATION_XML_TYPE);
        Response response = service.getMetadata(ADDRESS, "saml2sp");
        assertNotNull(response);

        Document responseDoc = StaxUtils.read(
                new InputStreamReader((InputStream) response.getEntity(), StandardCharsets.UTF_8));
        assertEquals("EntityDescriptor", responseDoc.getDocumentElement().getLocalName());
        assertEquals("urn:oasis:names:tc:SAML:2.0:metadata", responseDoc.getDocumentElement().getNamespaceURI());

        // Get the signature
        QName signatureQName = new QName(SignatureConstants.XMLSIG_NS, "Signature");
        Element signatureElement =
                DOMUtils.getFirstChildWithName(responseDoc.getDocumentElement(), signatureQName);
        assertNotNull(signatureElement);

        // Validate the signature
        XMLSignature signature = new XMLSignature(signatureElement, null);
        KeyStore keystore = KeyStore.getInstance("JKS");
        keystore.load(Loader.getResourceAsStream("keystore"), "changeit".toCharArray());
        assertTrue(signature.checkSignatureValue((X509Certificate) keystore.getCertificate("sp")));
    } catch (Exception e) {
        LOG.error("During SAML 2.0 SP metadata parsing", e);
        fail(e.getMessage());
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:32,代码来源:SAML2ITCase.java

示例5: read

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
public XMLObject read(final boolean useDeflateEncoding, final String response)
        throws DataFormatException, UnsupportedEncodingException, XMLStreamException, WSSecurityException {

    InputStream tokenStream;
    byte[] deflatedToken = Base64.getDecoder().decode(response);
    tokenStream = useDeflateEncoding
            ? new DeflateEncoderDecoder().inflateToken(deflatedToken)
            : new ByteArrayInputStream(deflatedToken);

    // parse the provided SAML response
    Document responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, StandardCharsets.UTF_8));
    XMLObject responseObject = OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());

    if (LOG.isDebugEnabled()) {
        try {
            StringWriter writer = new StringWriter();
            write(writer, responseObject, false);
            writer.close();

            LOG.debug("Parsed SAML response: {}", writer.toString());
        } catch (Exception e) {
            LOG.error("Could not log the received SAML response", e);
        }
    }

    return responseObject;
}
 
开发者ID:apache,项目名称:syncope,代码行数:28,代码来源:SAML2ReaderWriter.java

示例6: readObject

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Override
public Object readObject(MessageReader mreader, Context context) throws DatabindingException {
    try {
        XMLStreamReader reader = ((ElementReader)mreader).getXMLStreamReader();
        // we need to eat the surrounding element.
        reader.nextTag();
        Object tree = StaxUtils.read(null, new FragmentStreamReader(reader), true);
        reader.nextTag(); // eat the end tag.
        return tree;
    } catch (XMLStreamException e) {
        throw new DatabindingException("Could not parse xml.", e);
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:14,代码来源:DocumentType.java

示例7: testGetCxfInMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Test
public void testGetCxfInMessage() throws Exception {
    HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
    org.apache.camel.Exchange exchange = new DefaultExchange(context);
    // String
    exchange.getIn().setBody("hello world");
    org.apache.cxf.message.Message message = CxfMessageHelper.getCxfInMessage(
            headerFilterStrategy, exchange, false);
    // test message
    InputStream is = message.getContent(InputStream.class);
    assertNotNull("The input stream should not be null", is);
    assertEquals("Don't get the right message", toString(is), "hello world");

    // DOMSource
    URL request = this.getClass().getResource("RequestBody.xml");
    File requestFile = new File(request.toURI());
    FileInputStream inputStream = new FileInputStream(requestFile);
    XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(inputStream);
    DOMSource source = new DOMSource(StaxUtils.read(xmlReader));
    exchange.getIn().setBody(source);
    message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
    is = message.getContent(InputStream.class);
    assertNotNull("The input stream should not be null", is);
    assertEquals("Don't get the right message", toString(is), REQUEST_STRING);

    // File
    exchange.getIn().setBody(requestFile);
    message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
    is = message.getContent(InputStream.class);
    assertNotNull("The input stream should not be null", is);
    assertEquals("Don't get the right message", toString(is), REQUEST_STRING);

    // transport header's case insensitiveness
    // String
    exchange.getIn().setBody("hello world");
    exchange.getIn().setHeader("soapAction", "urn:hello:world");
    message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
    // test message
    Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
    
    // verify there is no duplicate
    assertNotNull("The headers must be present", headers);
    assertTrue("There must be one header entry", headers.size() == 1);
    
    // verify the soapaction can be retrieved in case-insensitive ways
    verifyHeader(headers, "soapaction", "urn:hello:world");
    verifyHeader(headers, "SoapAction", "urn:hello:world");
    verifyHeader(headers, "SOAPAction", "urn:hello:world");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:50,代码来源:CxfMessageHelperTest.java

示例8: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的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.staxutils.StaxUtils.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。