You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2011/10/13 08:22:24 UTC
svn commit: r1182678 - in
/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http:
AxisServlet.java HTTPWorker.java ListingAgent.java server/HttpUtils.java
Author: sagara
Date: Thu Oct 13 06:22:23 2011
New Revision: 1182678
URL: http://svn.apache.org/viewvc?rev=1182678&view=rev
Log:
Applied patch for AXIS2-5157.
Modified:
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/ListingAgent.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/HttpUtils.java
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java?rev=1182678&r1=1182677&r2=1182678&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java Thu Oct 13 06:22:23 2011
@@ -46,6 +46,7 @@ import org.apache.axis2.engine.ListenerM
import org.apache.axis2.transport.RequestResponseTransport;
import org.apache.axis2.transport.TransportListener;
import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.transport.http.util.QueryStringParser;
import org.apache.axis2.transport.http.util.RESTUtil;
import org.apache.axis2.util.JavaUtils;
@@ -65,10 +66,10 @@ import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.HashSet;
+import java.util.Comparator;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
/**
@@ -91,9 +92,8 @@ public class AxisServlet extends HttpSer
public static final String CONFIGURATION_CONTEXT = "CONFIGURATION_CONTEXT";
public static final String SESSION_ID = "SessionId";
- private static final Set<String> metadataQueryParamNames = new HashSet<String>(
- Arrays.asList("wsdl2", "wsdl", "xsd", "policy"));
-
+ private static final Set<String> metadataQueryParamNames;
+
protected transient ConfigurationContext configContext;
protected transient AxisConfiguration axisConfiguration;
@@ -114,6 +114,23 @@ public class AxisServlet extends HttpSer
private transient AxisServletListener httpListener;
private transient AxisServletListener httpsListener;
+ static {
+ Comparator comparator = new Comparator(){
+ public int compare(Object o1, Object o2) {
+ String string1 = (String) o1;
+ String string2 = (String) o2;
+ return string1.compareToIgnoreCase(string2);
+ }
+ };
+
+ metadataQueryParamNames= new TreeSet(comparator);
+ metadataQueryParamNames.add("wsdl2");
+ metadataQueryParamNames.add("wsdl");
+ metadataQueryParamNames.add("xsd");
+ metadataQueryParamNames.add("policy");
+
+
+ }
/**
* Implementaion of POST interface
*
@@ -258,8 +275,8 @@ public class AxisServlet extends HttpSer
if ((query != null) && new QueryStringParser(query).search(metadataQueryParamNames)) {
// handling meta data exchange stuff
agent.processListService(request, response);
- } else if (requestURI.endsWith(".xsd") ||
- requestURI.endsWith(".wsdl")) {
+ } else if (HttpUtils.endsWithIgnoreCase(requestURI , ".xsd") ||
+ HttpUtils.endsWithIgnoreCase(requestURI, ".wsdl")) {
agent.processExplicitSchemaAndWSDL(request, response);
} else if (requestURI.endsWith(LIST_SERVICES_SUFFIX) ||
requestURI.endsWith(LIST_FAULTY_SERVICES_SUFFIX)) {
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=1182678&r1=1182677&r2=1182678&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java Thu Oct 13 06:22:23 2011
@@ -92,7 +92,7 @@ public class HTTPWorker implements Worke
}
if (uri.indexOf("?") < 0) {
if (!uri.endsWith(contextPath)) {
- if (uri.endsWith(".xsd") || uri.endsWith(".wsdl")) {
+ if (HttpUtils.endsWithIgnoreCase(uri , ".xsd") || HttpUtils.endsWithIgnoreCase(uri , ".wsdl")){
HashMap services = configurationContext.getAxisConfiguration().getServices();
String file = uri.substring(uri.lastIndexOf("/") + 1,
uri.length());
@@ -115,7 +115,7 @@ public class HTTPWorker implements Worke
}
}
}
- if (uri.endsWith("?wsdl2")) {
+ if (HttpUtils.endsWithIgnoreCase(uri , "?wsdl2")) {
String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 6);
HashMap services = configurationContext.getAxisConfiguration().getServices();
AxisService service = (AxisService) services.get(serviceName);
@@ -131,7 +131,7 @@ public class HTTPWorker implements Worke
return;
}
}
- if (uri.endsWith("?wsdl")) {
+ if (HttpUtils.endsWithIgnoreCase(uri , "?wsdl")) {
/**
* service name can be hierarchical (axis2/services/foo/1.0.0/Version?wsdl) or
* normal (axis2/services/Version?wsdl).
@@ -153,7 +153,7 @@ public class HTTPWorker implements Worke
return;
}
}
- if (uri.endsWith("?xsd")) {
+ if (HttpUtils.endsWithIgnoreCase(uri , "?xsd")) {
String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 4);
HashMap services = configurationContext.getAxisConfiguration().getServices();
AxisService service = (AxisService) services.get(serviceName);
@@ -170,7 +170,7 @@ public class HTTPWorker implements Worke
}
}
//cater for named xsds - check for the xsd name
- if (uri.indexOf("?xsd=") > 0) {
+ if (HttpUtils.indexOfIngnoreCase(uri , "?xsd=") > 0) {
// fix for imported schemas
String[] uriParts = uri.split("[?]xsd=");
String serviceName =
@@ -250,14 +250,14 @@ public class HTTPWorker implements Worke
}
}
}
- if (uri.indexOf("?wsdl2=") > 0) {
+ if (HttpUtils.indexOfIngnoreCase(uri , "?wsdl2=") > 0) {
String serviceName =
- uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?wsdl2="));
+ uri.substring(uri.lastIndexOf("/") + 1, HttpUtils.lastIndexOfIgnoreCase(uri , "?wsdl2="));
if (processInternalWSDL(uri, configurationContext, serviceName, response, getHost(request))) return;
}
- if (uri.indexOf("?wsdl=") > 0) {
+ if (HttpUtils.indexOfIngnoreCase(uri , "?wsdl=") > 0) {
String serviceName =
- uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?wsdl="));
+ uri.substring(uri.lastIndexOf("/") + 1, HttpUtils.lastIndexOfIgnoreCase(uri , "?wsdl="));
if (processInternalWSDL(uri, configurationContext, serviceName, response, getHost(request))) return;
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/ListingAgent.java?rev=1182678&r1=1182677&r2=1182678&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/ListingAgent.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/ListingAgent.java Thu Oct 13 06:22:23 2011
@@ -24,8 +24,9 @@ import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.PolicyInclude;
import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.util.ExternalPolicySerializer;
import org.apache.axis2.util.IOUtils;
import org.apache.axis2.util.JavaUtils;
@@ -43,6 +44,7 @@ import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -67,8 +69,8 @@ public class ListingAgent extends Abstra
String query = httpServletRequest.getQueryString();
if (query != null) {
- if (query.indexOf("wsdl2") > 0 || query.indexOf("wsdl") > 0 ||
- query.indexOf("xsd") > 0 || query.indexOf("policy") > 0) {
+ if (HttpUtils.indexOfIngnoreCase(query , "wsdl2") > 0 || HttpUtils.indexOfIngnoreCase(query, "wsdl") > 0 ||
+ HttpUtils.indexOfIngnoreCase(query, "xsd") > 0 || HttpUtils.indexOfIngnoreCase(query, "policy") > 0) {
processListService(httpServletRequest, httpServletResponse);
} else {
super.handle(httpServletRequest, httpServletResponse);
@@ -167,10 +169,10 @@ public class ListingAgent extends Abstra
String serviceName = extractServiceName(url);
HashMap services = configContext.getAxisConfiguration().getServices();
String query = req.getQueryString();
- int wsdl2 = query.indexOf("wsdl2");
- int wsdl = query.indexOf("wsdl");
- int xsd = query.indexOf("xsd");
- int policy = query.indexOf("policy");
+ int wsdl2 = HttpUtils.indexOfIngnoreCase(query, "wsdl2");
+ int wsdl = HttpUtils.indexOfIngnoreCase(query, "wsdl");
+ int xsd = HttpUtils.indexOfIngnoreCase(query, "xsd");
+ int policy = HttpUtils.indexOfIngnoreCase(query, "policy");
if ((services != null) && !services.isEmpty()) {
Object serviceObj = services.get(serviceName);
@@ -297,7 +299,7 @@ public class ListingAgent extends Abstra
return;
}
res.setContentType("text/xml");
- int ret = axisService.printXSD(res.getOutputStream(), req.getParameter("xsd"));
+ int ret = axisService.printXSD(res.getOutputStream(), getParamtereIgnoreCase(req ,"xsd"));
if (ret == 0) {
//multiple schemas are present and the user specified
//no name - in this case we cannot possibly pump a schema
@@ -319,7 +321,7 @@ public class ListingAgent extends Abstra
OutputStream out = res.getOutputStream();
res.setContentType("text/xml");
String ip = extractHost(url);
- String wsdlName = req.getParameter("wsdl");
+ String wsdlName = getParamtereIgnoreCase(req , "wsdl");
if (wsdlName != null && wsdlName.length()>0) {
axisService.printUserWSDL(out, wsdlName, ip);
@@ -338,7 +340,7 @@ public class ListingAgent extends Abstra
}
res.setContentType("text/xml");
String ip = extractHost(url);
- String wsdlName = req.getParameter("wsdl2");
+ String wsdlName = getParamtereIgnoreCase(req , "wsdl2");
int ret = axisService.printWSDL2(res.getOutputStream(), ip, wsdlName);
if (ret == 0) {
@@ -348,6 +350,19 @@ public class ListingAgent extends Abstra
}
}
+ public String getParamtereIgnoreCase(HttpServletRequest req ,String paraName){
+ Enumeration e = req.getParameterNames();
+ while (e.hasMoreElements()) {
+ String name = (String)e.nextElement();
+ if(name.equalsIgnoreCase(paraName)) {
+ String value = req.getParameter(name);
+ return value;
+ }
+
+ }
+ return null;
+ }
+
/**
* Checks whether exposing the WSDL & WSDL elements such as schema & policy have been allowed
*
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/HttpUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/HttpUtils.java?rev=1182678&r1=1182677&r2=1182678&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/HttpUtils.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/HttpUtils.java Thu Oct 13 06:22:23 2011
@@ -19,17 +19,9 @@
package org.apache.axis2.transport.http.server;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.TransportListener;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.http.Header;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-
public class HttpUtils {
private HttpUtils() {
@@ -47,4 +39,26 @@ public class HttpUtils {
}
}
+ public static int indexOfIngnoreCase(String str , String subStr){
+ String lowerStr = str.toLowerCase();
+ String lowerSubStr = subStr.toLowerCase();
+ return lowerStr.indexOf(lowerSubStr);
+ }
+
+ public static boolean endsWithIgnoreCase(String str, String suffix) {
+ if (str == null || suffix == null) {
+ return (str == null && suffix == null);
+ }
+ if (suffix.length() > str.length()) {
+ return false;
+ }
+ int strOffset = str.length() - suffix.length();
+ return str.regionMatches(true, strOffset, suffix, 0, suffix.length());
+ }
+
+ public static int lastIndexOfIgnoreCase(String str , String subStr){
+ String lowerStr = str.toLowerCase();
+ String lowerSubStr = subStr.toLowerCase();
+ return lowerStr.lastIndexOf(lowerSubStr);
+ }
}