Author: hiranya
Date: Sat May 28 12:23:37 2011
New Revision: 1128622
URL: http://svn.apache.org/viewvc?rev=1128622&view=rev
Log:
Implementing some path validation in the callout mediator factory
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CalloutMediatorFactory.java
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CalloutMediatorSerializationTest.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CalloutMediatorFactory.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CalloutMediatorFactory.java?rev=1128622&r1=1128621&r2=1128622&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CalloutMediatorFactory.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CalloutMediatorFactory.java
Sat May 28 12:23:37 2011
@@ -26,6 +26,7 @@ import org.apache.synapse.mediators.buil
import org.jaxen.JaxenException;
import javax.xml.namespace.QName;
+import java.io.File;
import java.util.Properties;
/**
@@ -80,11 +81,21 @@ public class CalloutMediatorFactory exte
OMAttribute repoAttr = configElt.getAttribute(ATT_REPOSITORY);
if (axis2xmlAttr != null && axis2xmlAttr.getAttributeValue() !=
null) {
- callout.setAxis2xml(axis2xmlAttr.getAttributeValue());
+ File axis2xml = new File(axis2xmlAttr.getAttributeValue());
+ if (axis2xml.exists() && axis2xml.isFile()) {
+ callout.setAxis2xml(axis2xmlAttr.getAttributeValue());
+ } else {
+ handleException("Invalid axis2.xml path: " +
axis2xmlAttr.getAttributeValue());
+ }
}
if (repoAttr != null && repoAttr.getAttributeValue() != null) {
- callout.setClientRepository(repoAttr.getAttributeValue());
+ File repo = new File(repoAttr.getAttributeValue());
+ if (repo.exists() && repo.isDirectory()) {
+ callout.setClientRepository(repoAttr.getAttributeValue());
+ } else {
+ handleException("Invalid repository path: " +
repoAttr.getAttributeValue());
+ }
}
}
Modified:
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CalloutMediatorSerializationTest.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CalloutMediatorSerializationTest.java?rev=1128622&r1=1128621&r2=1128622&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CalloutMediatorSerializationTest.java
(original)
+++
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CalloutMediatorSerializationTest.java
Sat May 28 12:23:37 2011
@@ -19,6 +19,8 @@
package org.apache.synapse.config.xml;
+import java.io.File;
+
/**
* Factory and Serializer tests for the Callout Mediator
*/
@@ -46,11 +48,13 @@ public class CalloutMediatorSerializatio
assertTrue(serialization(inputXml, calloutMediatorSerializer));
}
- public void testCalloutMediatorSerializationScenarioTwo() {
+ public void testCalloutMediatorSerializationScenarioTwo() throws Exception
{
+ File axis2xml = new File("axis2.xml");
+ axis2xml.createNewFile();
String inputXml = "<callout xmlns=\"http://ws.apache.org/ns/synapse\"
" +
"serviceURL=\"http://localhost:9000/soap/SimpleStockQuoteService\" " +
- "action=\"urn:getQuote\"><configuration
axis2xml=\"axis2_custom.xml\" " +
- "repository=\"path_to_repo\"/><source
xmlns:s11=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
+ "action=\"urn:getQuote\"><configuration
axis2xml=\"axis2.xml\" " +
+ "repository=\".\"/><source
xmlns:s11=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:s12=\"http://www.w3.org/2003/05/soap-envelope\" key=\"key1\"/>" +
"<target
xmlns:s11=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:s12=\"http://www.w3.org/2003/05/soap-envelope\"
key=\"key2\"/></callout>";