SoapMessageManager.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:verify-matching-service-adapter 作者:
private Element unwrapSoapMessage(Element soapElement, SamlElementType samlElementType) {
    XPath xpath = XPathFactory.newInstance().newXPath();
    NamespaceContextImpl context = new NamespaceContextImpl();
    context.startPrefixMapping("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
    context.startPrefixMapping("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");
    context.startPrefixMapping("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
    context.startPrefixMapping("ds", "http://www.w3.org/2000/09/xmldsig#");
    xpath.setNamespaceContext(context);
    try {
        String expression = "//samlp:" + samlElementType.getElementName();
        Element element = (Element) xpath.evaluate(expression, soapElement, XPathConstants.NODE);

        if (element == null) {
            String errorMessage = format("Document{0}{1}{0}does not have element {2} inside it.", NEW_LINE,
                    XmlUtils.writeToString(soapElement), expression);
            LOG.error(errorMessage);
            throw new SoapUnwrappingException(errorMessage);
        }

        return element;
    } catch (XPathExpressionException e) {
        throw propagate(e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号