Repository: cxf Updated Branches: refs/heads/master eb184f4cd -> 919d0b843
[CXF-6110] - AbstractSTSClient MEX: download XML schema from Location. Thanks to Frank Cornelis for the patch. Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/919d0b84 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/919d0b84 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/919d0b84 Branch: refs/heads/master Commit: 919d0b843917cc2e190a0c6be10b5ffc6914ad56 Parents: eb184f4 Author: Colm O hEigeartaigh <[email protected]> Authored: Mon Nov 24 11:52:15 2014 +0000 Committer: Colm O hEigeartaigh <[email protected]> Committed: Mon Nov 24 11:52:15 2014 +0000 ---------------------------------------------------------------------- .../ws/security/trust/AbstractSTSClient.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/919d0b84/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java ---------------------------------------------------------------------- diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java index 5e0ea25..9dd2262 100755 --- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java +++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java @@ -40,7 +40,10 @@ import javax.wsdl.Definition; import javax.wsdl.Types; import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.schema.Schema; +import javax.xml.XMLConstants; import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import javax.xml.transform.dom.DOMSource; @@ -525,6 +528,11 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv bus.getExtension(WSDLManager.class).getDefinition((Element)s.getAny()); } else if ("http://www.w3.org/2001/XMLSchema".equals(s.getDialect())) { Element schemaElement = (Element)s.getAny(); + if (schemaElement == null) { + String schemaLocation = s.getLocation(); + LOG.info("XSD schema location: " + schemaLocation); + schemaElement = downloadSchema(schemaLocation); + } QName schemaName = new QName(schemaElement.getNamespaceURI(), schemaElement.getLocalName()); WSDLManager wsdlManager = bus.getExtension(WSDLManager.class); @@ -590,6 +598,18 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv } } } + + private Element downloadSchema(String schemaLocation) throws Exception { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); + dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + + DocumentBuilder documentBuilder = dbf.newDocumentBuilder(); + Document document = documentBuilder.parse(schemaLocation); + return document.getDocumentElement(); + } + protected String findMEXLocation(EndpointReferenceType ref, boolean useEPRWSAAddrAsMEXLocation) { if (ref.getMetadata() != null && ref.getMetadata().getAny() != null) { for (Object any : ref.getMetadata().getAny()) {
