diff options
-rw-r--r-- | id.server/src/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/id.server/src/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java b/id.server/src/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java index 78d0a0db0..18fc0587e 100644 --- a/id.server/src/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java +++ b/id.server/src/at/gv/egovernment/moa/id/util/InOrderServletRequestWrapper.java @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequestWrapper; +import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.URLDecoder; /** @@ -91,7 +92,7 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { //Insert code for Query string parsing String rawQuery = req.getQueryString(); - queryParameters = tokenize(queryParameters, queryParamOrder, rawQuery, DEFAULT_CHARACTER_ENCODING); + queryParameters = tokenize(queryParameters, queryParamOrder, rawQuery, DEFAULT_CHARACTER_ENCODING, true); //analyze HTTP Post body parameters if (req.getMethod().equalsIgnoreCase("POST")) @@ -171,7 +172,7 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { } postedBody = new String(postedBytes); - Hashtable ht2 = tokenize(ht, bodyParamOrder, postedBody, encoding); + Hashtable ht2 = tokenize(ht, bodyParamOrder, postedBody, encoding, false); return ht2; } @@ -186,7 +187,7 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { * * @return the Hashtable with the parsed data */ - private Hashtable tokenize(Hashtable ht, Vector order, final String parameterString, final String encoding) + private Hashtable tokenize(Hashtable ht, Vector order, final String parameterString, final String encoding, boolean decode) { String[] valArray = null; @@ -207,8 +208,15 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { } try { - key = URLDecoder.decode(pair.substring(0, pos), encoding); - val = URLDecoder.decode(pair.substring(pos + 1, pair.length()), encoding); + if (decode) { + key = URLDecoder.decode(pair.substring(0, pos), encoding); + val = URLDecoder.decode(pair.substring(pos + 1, pair.length()), encoding); + } else { + key = pair.substring(0, pos); + val = pair.substring(pos + 1, pair.length()); + } + //Logger.debug("(" + Integer.toString(key.length()) + "=" + Integer.toString(pair.substring(0, pos).length()) + ")"+key+"|--|"+pair.substring(0, pos)); + //Logger.debug("(" + Integer.toString(val.length()) + "=" + Integer.toString(pair.substring(pos + 1, pair.length()).length()) + ")"+val+"|--|"+pair.substring(pos + 1, pair.length())); } catch (Exception e) { @@ -324,11 +332,32 @@ public class InOrderServletRequestWrapper extends HttpServletRequestWrapper { /** * * Returns an <code>Enumeration</code> of <code>String</code> objects containing the names of the + * parameters. If there are no parameters, the method returns an empty + * <code>Enumeration</code>. + * + * @return an <code>Enumeration</code> of <code>String</code> objects, each <code>String</code> + * containing the name of a request parameter; or an empty <code>Enumeration</code> if the + * request has no parameters + * + */ + public final Enumeration getParameterNames() + { + Vector FullParamOrder = new Vector(); + for (Enumeration enu = queryParamOrder.elements(); enu.hasMoreElements();) { + FullParamOrder.addElement(enu.nextElement()); + } + for (Enumeration enu = bodyParamOrder.elements(); enu.hasMoreElements();) { + FullParamOrder.addElement(enu.nextElement()); + } + return FullParamOrder.elements(); + } + + /** + * + * Returns an <code>Enumeration</code> of <code>String</code> objects containing the names of the * parameters contained in this request. If the request has no parameters, the method returns an empty * <code>Enumeration</code>. * @param parameterType type of parameter - * @see at.gv.egovernment.moa.id.util.ParametersInOrderServlet#QUERY_PARAM - * and @see at.gv.egovernment.moa.id.util.ParametersInOrderServlet#BODY_PARAM * * @return an <code>Enumeration</code> of <code>String</code> objects, each <code>String</code> * containing the name of a request parameter; or an empty <code>Enumeration</code> if the |