cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: [CXF-6110] - AbstractSTSClient MEX: download XML schema from Location. Thanks to Frank Cornelis for the patch.
Date Mon, 24 Nov 2014 12:00:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 75177fdcd -> 91be86d13


[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/91be86d1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/91be86d1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/91be86d1

Branch: refs/heads/3.0.x-fixes
Commit: 91be86d137e81eb83fd34d271c872b20d221f1d9
Parents: 75177fd
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Nov 24 11:52:15 2014 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Nov 24 11:53:12 2014 +0000

----------------------------------------------------------------------
 .../ws/security/trust/AbstractSTSClient.java    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/91be86d1/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()) {


Mime
View raw message