use of org.apache.ws.commons.util.NamespaceContextImpl in project verify-hub by alphagov.
the class MatchingServiceHealthCheckIntegrationTests method namespaceContextForSaml.
private NamespaceContext namespaceContextForSaml() {
NamespaceContextImpl context = new NamespaceContextImpl();
context.startPrefixMapping("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
context.startPrefixMapping("saml2p", "urn:oasis:names:tc:SAML:2.0:protocol");
context.startPrefixMapping("saml2", "urn:oasis:names:tc:SAML:2.0:assertion");
context.startPrefixMapping("ds", "http://www.w3.org/2000/09/xmldsig#");
return context;
}
use of org.apache.ws.commons.util.NamespaceContextImpl in project verify-hub by alphagov.
the class SoapMessageManager method unwrapSoapMessage.
public Element unwrapSoapMessage(Element soapElement) {
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 {
final String expression = "/soapenv:Envelope/soapenv:Body/samlp:Response";
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, writeToString(soapElement), expression);
LOG.error(errorMessage);
throw new IllegalArgumentException(errorMessage);
}
return element;
} catch (XPathExpressionException e) {
throw propagate(e);
}
}
use of org.apache.ws.commons.util.NamespaceContextImpl in project verify-hub by alphagov.
the class SoapMessageManagerTest method getAttributeQuery.
private Element getAttributeQuery(Document document) throws XPathExpressionException {
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");
xpath.setNamespaceContext(context);
return (Element) xpath.evaluate("//samlp:Response", document, XPathConstants.NODE);
}
Aggregations