diff --git a/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/MockRewriteMatch.java b/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/MockRewriteMatch.java index cf40d5f6..843cb84b 100644 --- a/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/MockRewriteMatch.java +++ b/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/MockRewriteMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/TestRunObj.java b/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/TestRunObj.java index 5325c6e5..095df750 100644 --- a/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/TestRunObj.java +++ b/container-test/example-webapp/src/main/java/org/tuckey/web/filters/urlrewriteviacontainer/TestRunObj.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java b/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java index c6a512aa..14466c5a 100644 --- a/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java +++ b/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/CatchElem.java b/src/main/java/org/tuckey/web/filters/urlrewrite/CatchElem.java index 512718e9..3bba790d 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/CatchElem.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/CatchElem.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/ClassRule.java b/src/main/java/org/tuckey/web/filters/urlrewrite/ClassRule.java index 42af9269..cbd15efa 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/ClassRule.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/ClassRule.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/Condition.java b/src/main/java/org/tuckey/web/filters/urlrewrite/Condition.java index 27a64256..45d72c2f 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/Condition.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/Condition.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/ConditionMatch.java b/src/main/java/org/tuckey/web/filters/urlrewrite/ConditionMatch.java index e2b79c82..9fe18096 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/ConditionMatch.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/ConditionMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/Conf.java b/src/main/java/org/tuckey/web/filters/urlrewrite/Conf.java index 7b8068b3..f2852609 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/Conf.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/Conf.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/ConfHandler.java b/src/main/java/org/tuckey/web/filters/urlrewrite/ConfHandler.java index 81a3e29c..f9065a72 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/ConfHandler.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/ConfHandler.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRewrittenUrl.java b/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRewrittenUrl.java index b47492f4..884e0db6 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRewrittenUrl.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRewrittenUrl.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRule.java b/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRule.java index ff8891d4..fdc4c0c2 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRule.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/NormalRule.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/OutboundRule.java b/src/main/java/org/tuckey/web/filters/urlrewrite/OutboundRule.java index 98da38d7..9ca44845 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/OutboundRule.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/OutboundRule.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RequestProxy.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RequestProxy.java index 663c5408..9ef65d94 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RequestProxy.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RequestProxy.java @@ -1,337 +1,337 @@ -/** - * Copyright (c) 2008, Paul Tuckey - * All rights reserved. - * ==================================================================== - * Licensed under the BSD License. Text as follows. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - Neither the name tuckey.org nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - */ -package org.tuckey.web.filters.urlrewrite; - -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.HostConfiguration; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.ProxyHost; -import org.apache.commons.httpclient.SimpleHttpConnectionManager; -import org.apache.commons.httpclient.methods.*; -import org.tuckey.web.filters.urlrewrite.utils.Log; -import org.tuckey.web.filters.urlrewrite.utils.StringUtils; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; - -/** - * This class is responsible for a proxy http request. - * It takes the incoming request and then it creates a new request to the target address and copies the response of that proxy request - * to the response of the original request. - *
- * This class uses the commons-httpclient classes from Apache. - * - * User: Joachim Ansorg, jansorg AT ksi.gr - * Date: 19.06.2008 - * Time: 16:02:54 - */ -public class RequestProxy { - private static final Log log = Log.getLog(RequestProxy.class); - - /** - * This method performs the proxying of the request to the target address. - * - * Cookies will not be forwarded to client. - * - * @param target The target address. Has to be a fully qualified address. The request is send as-is to this address. - * @param hsRequest The request data which should be send to the - * @param hsResponse The response data which will contain the data returned by the proxied request to target. - * @throws java.io.IOException Passed on from the connection logic. - */ - public static void execute(final String target, final HttpServletRequest hsRequest, final HttpServletResponse hsResponse) throws IOException { - execute(target, hsRequest, hsResponse, true); - } - - /** - * This method performs the proxying of the request to the target address. - * - * @param target The target address. Has to be a fully qualified address. The request is send as-is to this address. - * @param hsRequest The request data which should be send to the - * @param hsResponse The response data which will contain the data returned by the proxied request to target. - * @throws java.io.IOException Passed on from the connection logic. - * @Param dropCookies Determinate whether cookies should be dropped (when {@code true}) or forwarded to client. - */ - public static void execute(final String target, final HttpServletRequest hsRequest, final HttpServletResponse hsResponse, boolean dropCookies) throws IOException { - if (log.isInfoEnabled()) { - log.info("execute, target is " + target); - log.info("response commit state: " + hsResponse.isCommitted()); - } - - if (StringUtils.isBlank(target)) { - log.error("The target address is not given. Please provide a target address."); - return; - } - - log.info("checking url"); - final URL url; - try { - url = new URL(target); - } catch (MalformedURLException e) { - log.error("The provided target url is not valid.", e); - return; - } - - log.info("seting up the host configuration"); - - final HostConfiguration config = new HostConfiguration(); - - ProxyHost proxyHost = getUseProxyServer((String) hsRequest.getAttribute("use-proxy")); - if (proxyHost != null) config.setProxyHost(proxyHost); - - final int port = url.getPort() != -1 ? url.getPort() : url.getDefaultPort(); - config.setHost(url.getHost(), port, url.getProtocol()); - - if ( log.isInfoEnabled() ) log.info("config is " + config.toString()); - - final HttpMethod targetRequest = setupProxyRequest(hsRequest, url, dropCookies); - if (targetRequest == null) { - log.error("Unsupported request method found: " + hsRequest.getMethod()); - return; - } - - //perform the reqeust to the target server - final HttpClient client = new HttpClient(new SimpleHttpConnectionManager()); - if (log.isInfoEnabled()) { - log.info("client state" + client.getState()); - log.info("client params" + client.getParams().toString()); - log.info("executeMethod / fetching data ..."); - } - - final int result; - if (targetRequest instanceof EntityEnclosingMethod) { - final RequestProxyCustomRequestEntity requestEntity = new RequestProxyCustomRequestEntity( - hsRequest.getInputStream(), hsRequest.getContentLength(), hsRequest.getContentType()); - final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) targetRequest; - entityEnclosingMethod.setRequestEntity(requestEntity); - result = client.executeMethod(config, entityEnclosingMethod); - - } else { - result = client.executeMethod(config, targetRequest); - } - - //copy the target response headers to our response - setupResponseHeaders(targetRequest, hsResponse, dropCookies); - - InputStream originalResponseStream = targetRequest.getResponseBodyAsStream(); - //the body might be null, i.e. for responses with cache-headers which leave out the body - if (originalResponseStream != null) { - OutputStream responseStream = hsResponse.getOutputStream(); - copyStream(originalResponseStream, responseStream); - } - - log.info("set up response, result code was " + result); - } - - public static void copyStream(InputStream in, OutputStream out) throws IOException { - byte[] buf = new byte[65536]; - int count; - while ((count = in.read(buf)) != -1) { - out.write(buf, 0, count); - } - } - - - public static ProxyHost getUseProxyServer(String useProxyServer) { - ProxyHost proxyHost = null; - if (useProxyServer != null) { - String proxyHostStr = useProxyServer; - int colonIdx = proxyHostStr.indexOf(':'); - if (colonIdx != -1) { - proxyHostStr = proxyHostStr.substring(0, colonIdx); - String proxyPortStr = useProxyServer.substring(colonIdx + 1); - if (proxyPortStr != null && proxyPortStr.length() > 0 && proxyPortStr.matches("[0-9]+")) { - int proxyPort = Integer.parseInt(proxyPortStr); - proxyHost = new ProxyHost(proxyHostStr, proxyPort); - } else { - proxyHost = new ProxyHost(proxyHostStr); - } - } else { - proxyHost = new ProxyHost(proxyHostStr); - } - } - return proxyHost; - } - - private static HttpMethod setupProxyRequest(final HttpServletRequest hsRequest, final URL targetUrl, boolean dropCookies) throws IOException { - final String methodName = hsRequest.getMethod(); - final HttpMethod method; - if ("POST".equalsIgnoreCase(methodName)) { - PostMethod postMethod = new PostMethod(); - InputStreamRequestEntity inputStreamRequestEntity = new InputStreamRequestEntity(hsRequest.getInputStream()); - postMethod.setRequestEntity(inputStreamRequestEntity); - method = postMethod; - } else if ("GET".equalsIgnoreCase(methodName)) { - method = new GetMethod(); - } else if ("PUT".equalsIgnoreCase(methodName)) { - PutMethod putMethod = new PutMethod(); - InputStreamRequestEntity inputStreamRequestEntity = new InputStreamRequestEntity(hsRequest.getInputStream()); - putMethod.setRequestEntity(inputStreamRequestEntity); - method = putMethod; - } else if ("DELETE".equalsIgnoreCase(methodName)) { - method = new DeleteMethod(); - } else { - log.warn("Unsupported HTTP method requested: " + hsRequest.getMethod()); - return null; - } - - Enumeration+ * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *
+ * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * - Neither the name tuckey.org nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + */ +package org.tuckey.web.filters.urlrewrite; + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HostConfiguration; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.ProxyHost; +import org.apache.commons.httpclient.SimpleHttpConnectionManager; +import org.apache.commons.httpclient.methods.*; +import org.tuckey.web.filters.urlrewrite.utils.Log; +import org.tuckey.web.filters.urlrewrite.utils.StringUtils; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; + +/** + * This class is responsible for a proxy http request. + * It takes the incoming request and then it creates a new request to the target address and copies the response of that proxy request + * to the response of the original request. + *
+ * This class uses the commons-httpclient classes from Apache. + * + * User: Joachim Ansorg, jansorg AT ksi.gr + * Date: 19.06.2008 + * Time: 16:02:54 + */ +public class RequestProxy { + private static final Log log = Log.getLog(RequestProxy.class); + + /** + * This method performs the proxying of the request to the target address. + * + * Cookies will not be forwarded to client. + * + * @param target The target address. Has to be a fully qualified address. The request is send as-is to this address. + * @param hsRequest The request data which should be send to the + * @param hsResponse The response data which will contain the data returned by the proxied request to target. + * @throws java.io.IOException Passed on from the connection logic. + */ + public static void execute(final String target, final HttpServletRequest hsRequest, final HttpServletResponse hsResponse) throws IOException { + execute(target, hsRequest, hsResponse, true); + } + + /** + * This method performs the proxying of the request to the target address. + * + * @param target The target address. Has to be a fully qualified address. The request is send as-is to this address. + * @param hsRequest The request data which should be send to the + * @param hsResponse The response data which will contain the data returned by the proxied request to target. + * @throws java.io.IOException Passed on from the connection logic. + * @Param dropCookies Determinate whether cookies should be dropped (when {@code true}) or forwarded to client. + */ + public static void execute(final String target, final HttpServletRequest hsRequest, final HttpServletResponse hsResponse, boolean dropCookies) throws IOException { + if (log.isInfoEnabled()) { + log.info("execute, target is " + target); + log.info("response commit state: " + hsResponse.isCommitted()); + } + + if (StringUtils.isBlank(target)) { + log.error("The target address is not given. Please provide a target address."); + return; + } + + log.info("checking url"); + final URL url; + try { + url = new URL(target); + } catch (MalformedURLException e) { + log.error("The provided target url is not valid.", e); + return; + } + + log.info("seting up the host configuration"); + + final HostConfiguration config = new HostConfiguration(); + + ProxyHost proxyHost = getUseProxyServer((String) hsRequest.getAttribute("use-proxy")); + if (proxyHost != null) config.setProxyHost(proxyHost); + + final int port = url.getPort() != -1 ? url.getPort() : url.getDefaultPort(); + config.setHost(url.getHost(), port, url.getProtocol()); + + if ( log.isInfoEnabled() ) log.info("config is " + config.toString()); + + final HttpMethod targetRequest = setupProxyRequest(hsRequest, url, dropCookies); + if (targetRequest == null) { + log.error("Unsupported request method found: " + hsRequest.getMethod()); + return; + } + + //perform the reqeust to the target server + final HttpClient client = new HttpClient(new SimpleHttpConnectionManager()); + if (log.isInfoEnabled()) { + log.info("client state" + client.getState()); + log.info("client params" + client.getParams().toString()); + log.info("executeMethod / fetching data ..."); + } + + final int result; + if (targetRequest instanceof EntityEnclosingMethod) { + final RequestProxyCustomRequestEntity requestEntity = new RequestProxyCustomRequestEntity( + hsRequest.getInputStream(), hsRequest.getContentLength(), hsRequest.getContentType()); + final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) targetRequest; + entityEnclosingMethod.setRequestEntity(requestEntity); + result = client.executeMethod(config, entityEnclosingMethod); + + } else { + result = client.executeMethod(config, targetRequest); + } + + //copy the target response headers to our response + setupResponseHeaders(targetRequest, hsResponse, dropCookies); + + InputStream originalResponseStream = targetRequest.getResponseBodyAsStream(); + //the body might be null, i.e. for responses with cache-headers which leave out the body + if (originalResponseStream != null) { + OutputStream responseStream = hsResponse.getOutputStream(); + copyStream(originalResponseStream, responseStream); + } + + log.info("set up response, result code was " + result); + } + + public static void copyStream(InputStream in, OutputStream out) throws IOException { + byte[] buf = new byte[65536]; + int count; + while ((count = in.read(buf)) != -1) { + out.write(buf, 0, count); + } + } + + + public static ProxyHost getUseProxyServer(String useProxyServer) { + ProxyHost proxyHost = null; + if (useProxyServer != null) { + String proxyHostStr = useProxyServer; + int colonIdx = proxyHostStr.indexOf(':'); + if (colonIdx != -1) { + proxyHostStr = proxyHostStr.substring(0, colonIdx); + String proxyPortStr = useProxyServer.substring(colonIdx + 1); + if (proxyPortStr != null && proxyPortStr.length() > 0 && proxyPortStr.matches("[0-9]+")) { + int proxyPort = Integer.parseInt(proxyPortStr); + proxyHost = new ProxyHost(proxyHostStr, proxyPort); + } else { + proxyHost = new ProxyHost(proxyHostStr); + } + } else { + proxyHost = new ProxyHost(proxyHostStr); + } + } + return proxyHost; + } + + private static HttpMethod setupProxyRequest(final HttpServletRequest hsRequest, final URL targetUrl, boolean dropCookies) throws IOException { + final String methodName = hsRequest.getMethod(); + final HttpMethod method; + if ("POST".equalsIgnoreCase(methodName)) { + PostMethod postMethod = new PostMethod(); + InputStreamRequestEntity inputStreamRequestEntity = new InputStreamRequestEntity(hsRequest.getInputStream()); + postMethod.setRequestEntity(inputStreamRequestEntity); + method = postMethod; + } else if ("GET".equalsIgnoreCase(methodName)) { + method = new GetMethod(); + } else if ("PUT".equalsIgnoreCase(methodName)) { + PutMethod putMethod = new PutMethod(); + InputStreamRequestEntity inputStreamRequestEntity = new InputStreamRequestEntity(hsRequest.getInputStream()); + putMethod.setRequestEntity(inputStreamRequestEntity); + method = putMethod; + } else if ("DELETE".equalsIgnoreCase(methodName)) { + method = new DeleteMethod(); + } else { + log.warn("Unsupported HTTP method requested: " + hsRequest.getMethod()); + return null; + } + + Enumeration* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrl.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrl.java index f58d7b98..53b471a4 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrl.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrl.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlClass.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlClass.java index 06d589ec..556833e9 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlClass.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlClass.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/Rule.java b/src/main/java/org/tuckey/web/filters/urlrewrite/Rule.java index ed086b44..98641b10 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/Rule.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/Rule.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RuleBase.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RuleBase.java index 2cc1f0f7..c063cec6 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RuleBase.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RuleBase.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RuleChain.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RuleChain.java index 0010cd8c..bdadf6a2 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RuleChain.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RuleChain.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RuleExecutionOutput.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RuleExecutionOutput.java index 9e2e5f7c..78419902 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RuleExecutionOutput.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RuleExecutionOutput.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/Run.java b/src/main/java/org/tuckey/web/filters/urlrewrite/Run.java index 1c74647f..aeb8e298 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/Run.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/Run.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/RunConfig.java b/src/main/java/org/tuckey/web/filters/urlrewrite/RunConfig.java index 5b070185..62dad115 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/RunConfig.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/RunConfig.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/Runnable.java b/src/main/java/org/tuckey/web/filters/urlrewrite/Runnable.java index c8bdf9b8..51b539a6 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/Runnable.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/Runnable.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/SetAttribute.java b/src/main/java/org/tuckey/web/filters/urlrewrite/SetAttribute.java index c0676353..186c54c7 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/SetAttribute.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/SetAttribute.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -309,16 +309,16 @@ public boolean initialise() { /** * takes a string a number expression and converts it to a long. * syntax: number type - * + *
* Valid examples: "1 day", "2 days", "1 hour", "1 hour 2 minutes", "34 months" - * + *
* Any positive number is valid - * + *
* Valid types are: years, months, weeks, days, hours, minutes, seconds - * + *
* note, this syntax is a direct copy of mod_expires syntax * http://httpd.apache.org/docs/2.0/mod/mod_expires.html - * + *
* note, a year is calculated as 365.25 days and a month as 365.25 days divided by 12. */ protected long parseTimeValue(String parsingValue) { diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/Status.java b/src/main/java/org/tuckey/web/filters/urlrewrite/Status.java index 83478566..5ce354a1 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/Status.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/Status.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/TypeConverter.java b/src/main/java/org/tuckey/web/filters/urlrewrite/TypeConverter.java index 9502064e..2449f193 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/TypeConverter.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/TypeConverter.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteDocTask.java b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteDocTask.java index 5394e4a3..9a995e99 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteDocTask.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteDocTask.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilter.java b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilter.java index cb90909b..1a4de935 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilter.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilter.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteServlet.java b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteServlet.java index 3b11327f..8cf40b80 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteServlet.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteServlet.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -52,7 +52,7 @@ * Servlet for use if you cannot load filters in your environment for some strange reason. This will * work very differently from the filter (obviously), but it can be used for "run" items where there * is no "to". - * + *
* This servlet just loads an instance of the filter and calls it as if it were the container. */ public class UrlRewriteServlet extends HttpServlet { diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedRequest.java b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedRequest.java index 0d38481d..8ea8edce 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedRequest.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedRequest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponse.java b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponse.java index 33629c7d..4a99a2d0 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponse.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponse.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriter.java b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriter.java index 2aa878cb..6d93aa07 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriter.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/UrlRewriter.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteMatch.java b/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteMatch.java index 211b0aa5..1873be10 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteMatch.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -56,7 +56,7 @@ public String getMatchingUrl() { /** * If this rule has been matched and has not been "stolen" by another rule then process the request. - * + *
* If you return true then the filter chain will NOT continue. * * @return boolean true if the request was rewritten, false if not. diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteRule.java b/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteRule.java index ee0a0142..9e02cde3 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteRule.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/extend/RewriteRule.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/FilterServletOutputStream.java b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/FilterServletOutputStream.java index a7bcfa75..cafd2170 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/FilterServletOutputStream.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/FilterServletOutputStream.java @@ -3,16 +3,16 @@ /** * Modified version of: * http://svn.terracotta.org/svn/ehcache/trunk/web/web/src/main/java/net/sf/ehcache/constructs/web/filter/FilterServletOutputStream.java - * + *
* * Copyright 2003-2009 Terracotta, Inc. - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GenericResponseWrapper.java b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GenericResponseWrapper.java index 9cb11ccc..90b03a34 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GenericResponseWrapper.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GenericResponseWrapper.java @@ -3,16 +3,16 @@ /** * Modified version of: * http://svn.terracotta.org/svn/ehcache/trunk/web/web/src/main/java/net/sf/ehcache/constructs/web/GenericResponseWrapper.java - * + *
* * Copyright 2003-2009 Terracotta, Inc. - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GzipFilter.java b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GzipFilter.java index 3ead9fc0..18c594cf 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GzipFilter.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/GzipFilter.java @@ -3,15 +3,15 @@ /** * Modified version of: * http://svn.terracotta.org/svn/ehcache/trunk/web/web/src/main/java/net/sf/ehcache/constructs/web/filter/GzipFilter.java - * + *
* Copyright 2003-2009 Terracotta, Inc. - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/ResponseUtil.java b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/ResponseUtil.java index a128e241..eb562beb 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/ResponseUtil.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/gzip/ResponseUtil.java @@ -3,16 +3,16 @@ /** * Modified version of: * http://svn.terracotta.org/svn/ehcache/trunk/web/web/src/main/java/net/sf/ehcache/constructs/web/ResponseUtil.java - * + *
* * Copyright 2003-2009 Terracotta, Inc. - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatch.java b/src/main/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatch.java index 051f65d1..73595016 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatch.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteMatch.java b/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteMatch.java index 7be22824..8fb8ccc6 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteMatch.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteRule.java b/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteRule.java index 9de0a9d7..c5496c05 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteRule.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/sample/SampleRewriteRule.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/BackReferenceReplacer.java b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/BackReferenceReplacer.java index f875bf81..094eeb7a 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/BackReferenceReplacer.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/BackReferenceReplacer.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/FunctionReplacer.java b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/FunctionReplacer.java index 3688af69..519d2dc2 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/FunctionReplacer.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/FunctionReplacer.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/MatcherReplacer.java b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/MatcherReplacer.java index d5bdfde7..8e763d8a 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/MatcherReplacer.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/MatcherReplacer.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/PatternReplacer.java b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/PatternReplacer.java index e35a7f6d..8fe0ad26 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/PatternReplacer.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/PatternReplacer.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/UnescapeReplacer.java b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/UnescapeReplacer.java index 45130ffa..f3eb94b3 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/UnescapeReplacer.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/UnescapeReplacer.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/VariableReplacer.java b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/VariableReplacer.java index ab6eda6c..fa0b1dc3 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/VariableReplacer.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/substitution/VariableReplacer.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/Log.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/Log.java index 7cf9230a..31227a6a 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/Log.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/Log.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/NumberUtils.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/NumberUtils.java index ea31957b..ed6e7b92 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/NumberUtils.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/NumberUtils.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexMatcher.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexMatcher.java index 5925991c..78db6a22 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexMatcher.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexMatcher.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexPattern.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexPattern.java index dae84de4..25743744 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexPattern.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/RegexPattern.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/ServerNameMatcher.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/ServerNameMatcher.java index 795f68e5..b1b53510 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/ServerNameMatcher.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/ServerNameMatcher.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcher.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcher.java index 11497f13..aac0e6bf 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcher.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcher.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPattern.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPattern.java index 54af487f..4346a333 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPattern.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPattern.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPatternSyntaxException.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPatternSyntaxException.java index f20c7db0..90164acc 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPatternSyntaxException.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingPatternSyntaxException.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringUtils.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringUtils.java index 1035adea..1bc2b981 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringUtils.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/StringUtils.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/URLEncoder.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/URLEncoder.java index c9a20dd7..173c413f 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/URLEncoder.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/URLEncoder.java @@ -182,7 +182,7 @@ public class URLEncoder { /** * pchar = unreserved | escaped | ":" | "@" | "&" | "=" | "+" | "$" | "," - * + *
* Note: we don't allow escaped here since we will escape it ourselves, so we don't want to allow them in the
* unescaped sequences
*/
diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardHelper.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardHelper.java
index 66366a04..86c7e83b 100644
--- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardHelper.java
+++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardHelper.java
@@ -1,422 +1,422 @@
-/**
- * This class is a modified version of one found in Apache Cocoon.
- *
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.tuckey.web.filters.urlrewrite.utils;
-
-
-import java.util.Map;
-
-/**
- * This class is an utility class that perform wilcard-patterns matching and
- * isolation taken from Apache Cocoon.
- *
- * @version $Revision: 1 $ $Date: 2006-08-01 21:40:28 +1200 (Tue, 01 Aug 2006) $
- */
-public class WildcardHelper {
-
- /**
- * The int representing '*' in the pattern int []
.
- */
- protected static final int MATCH_FILE = -1;
-
- /**
- * The int representing '**' in the pattern int []
.
- */
- protected static final int MATCH_PATH = -2;
-
- /**
- * The int representing begin in the pattern int []
.
- */
- protected static final int MATCH_BEGIN = -4;
-
- /**
- * The int representing end in pattern int []
.
- */
- protected static final int MATCH_THEEND = -5;
-
- /**
- * The int value that terminates the pattern int []
.
- */
- protected static final int MATCH_END = -3;
-
-
- /**
- * Translate the given String
into a int []
- * representing the pattern matchable by this class.
- *
- * This function translates a String
into an int array
- * converting the special '*' and '\' characters.
- *
- * Here is how the conversion algorithm works:
- *
Stack
.
- *
- * @param map The map to store matched values
- * @param data The string to match
- * @param expr The compiled wildcard expression
- * @return True if a match
- * @throws NullPointerException If any parameters are null
- */
- public boolean match(Map map, String data, int[] expr) {
- if (map == null) {
- throw new NullPointerException("No map provided");
- }
- if (data == null) {
- throw new NullPointerException("No data provided");
- }
- if (expr == null) {
- throw new NullPointerException("No pattern expression provided");
- }
-
-
- char buff[] = data.toCharArray();
- // Allocate the result buffer
- char rslt[] = new char[expr.length + buff.length];
-
- // The previous and current position of the expression character
- // (MATCH_*)
- int charpos = 0;
-
- // The position in the expression, input, translation and result arrays
- int exprpos = 0;
- int buffpos = 0;
- int rsltpos = 0;
- int offset;
-
- // The matching count
- int mcount = 0;
-
- // We want the complete data be in {0}
- map.put(Integer.toString(mcount), data);
-
- // First check for MATCH_BEGIN
- boolean matchBegin = false;
- if (expr[charpos] == MATCH_BEGIN) {
- matchBegin = true;
- exprpos = ++charpos;
- }
-
- // Search the fist expression character (except MATCH_BEGIN - already
- // skipped)
- while (expr[charpos] >= 0) {
- charpos++;
- }
-
- // The expression charater (MATCH_*)
- int exprchr = expr[charpos];
-
- while (true) {
- // Check if the data in the expression array before the current
- // expression character matches the data in the input buffer
- if (matchBegin) {
- if (!matchArray(expr, exprpos, charpos, buff, buffpos)) {
- return (false);
- }
- matchBegin = false;
- } else {
- offset = indexOfArray(expr, exprpos, charpos, buff,
- buffpos);
- if (offset < 0) {
- return (false);
- }
- }
-
- // Advance buffpos
- buffpos += (charpos - exprpos);
-
- // Check for END's
- if (exprchr == MATCH_END) {
- if (rsltpos > 0) {
- map.put(Integer.toString(++mcount),
- new String(rslt, 0, rsltpos));
- }
- // Don't care about rest of input buffer
- return (true);
- } else if (exprchr == MATCH_THEEND) {
- if (rsltpos > 0) {
- map.put(Integer.toString(++mcount),
- new String(rslt, 0, rsltpos));
- }
- // Check that we reach buffer's end
- return (buffpos == buff.length);
- }
-
- // Search the next expression character
- exprpos = ++charpos;
- while (expr[charpos] >= 0) {
- charpos++;
- }
- int prevchr = exprchr;
- exprchr = expr[charpos];
-
- // We have here prevchr == * or **.
- offset = (prevchr == MATCH_FILE)
- ? indexOfArray(expr, exprpos, charpos, buff, buffpos)
- : lastIndexOfArray(expr, exprpos, charpos, buff,
- buffpos);
-
- if (offset < 0) {
- return (false);
- }
-
- // Copy the data from the source buffer into the result buffer
- // to substitute the expression character
- if (prevchr == MATCH_PATH) {
- while (buffpos < offset) {
- rslt[rsltpos++] = buff[buffpos++];
- }
- } else {
- // Matching file, don't copy '/'
- while (buffpos < offset) {
- if (buff[buffpos] == '/') {
- return (false);
- }
- rslt[rsltpos++] = buff[buffpos++];
- }
- }
-
- map.put(Integer.toString(++mcount), new String(rslt, 0, rsltpos));
- rsltpos = 0;
- }
- }
-
- /**
- * Get the offset of a part of an int array within a char array.
- * + * Copyright 2003-2004 The Apache Software Foundation. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.tuckey.web.filters.urlrewrite.utils;
+
+
+import java.util.Map;
+
+/**
+ * This class is an utility class that perform wilcard-patterns matching and
+ * isolation taken from Apache Cocoon.
+ *
+ * @version $Revision: 1 $ $Date: 2006-08-01 21:40:28 +1200 (Tue, 01 Aug 2006) $
+ */
+public class WildcardHelper {
+
+ /**
+ * The int representing '*' in the pattern int []
.
+ */
+ protected static final int MATCH_FILE = -1;
+
+ /**
+ * The int representing '**' in the pattern int []
.
+ */
+ protected static final int MATCH_PATH = -2;
+
+ /**
+ * The int representing begin in the pattern int []
.
+ */
+ protected static final int MATCH_BEGIN = -4;
+
+ /**
+ * The int representing end in pattern int []
.
+ */
+ protected static final int MATCH_THEEND = -5;
+
+ /**
+ * The int value that terminates the pattern int []
.
+ */
+ protected static final int MATCH_END = -3;
+
+
+ /**
+ * Translate the given String
into a int []
+ * representing the pattern matchable by this class.
+ *
+ * This function translates a String
into an int array
+ * converting the special '*' and '\' characters.
+ *
+ * Here is how the conversion algorithm works:
+ *
Stack
.
+ *
+ * @param map The map to store matched values
+ * @param data The string to match
+ * @param expr The compiled wildcard expression
+ * @return True if a match
+ * @throws NullPointerException If any parameters are null
+ */
+ public boolean match(Map map, String data, int[] expr) {
+ if (map == null) {
+ throw new NullPointerException("No map provided");
+ }
+ if (data == null) {
+ throw new NullPointerException("No data provided");
+ }
+ if (expr == null) {
+ throw new NullPointerException("No pattern expression provided");
+ }
+
+
+ char buff[] = data.toCharArray();
+ // Allocate the result buffer
+ char rslt[] = new char[expr.length + buff.length];
+
+ // The previous and current position of the expression character
+ // (MATCH_*)
+ int charpos = 0;
+
+ // The position in the expression, input, translation and result arrays
+ int exprpos = 0;
+ int buffpos = 0;
+ int rsltpos = 0;
+ int offset;
+
+ // The matching count
+ int mcount = 0;
+
+ // We want the complete data be in {0}
+ map.put(Integer.toString(mcount), data);
+
+ // First check for MATCH_BEGIN
+ boolean matchBegin = false;
+ if (expr[charpos] == MATCH_BEGIN) {
+ matchBegin = true;
+ exprpos = ++charpos;
+ }
+
+ // Search the fist expression character (except MATCH_BEGIN - already
+ // skipped)
+ while (expr[charpos] >= 0) {
+ charpos++;
+ }
+
+ // The expression charater (MATCH_*)
+ int exprchr = expr[charpos];
+
+ while (true) {
+ // Check if the data in the expression array before the current
+ // expression character matches the data in the input buffer
+ if (matchBegin) {
+ if (!matchArray(expr, exprpos, charpos, buff, buffpos)) {
+ return (false);
+ }
+ matchBegin = false;
+ } else {
+ offset = indexOfArray(expr, exprpos, charpos, buff,
+ buffpos);
+ if (offset < 0) {
+ return (false);
+ }
+ }
+
+ // Advance buffpos
+ buffpos += (charpos - exprpos);
+
+ // Check for END's
+ if (exprchr == MATCH_END) {
+ if (rsltpos > 0) {
+ map.put(Integer.toString(++mcount),
+ new String(rslt, 0, rsltpos));
+ }
+ // Don't care about rest of input buffer
+ return (true);
+ } else if (exprchr == MATCH_THEEND) {
+ if (rsltpos > 0) {
+ map.put(Integer.toString(++mcount),
+ new String(rslt, 0, rsltpos));
+ }
+ // Check that we reach buffer's end
+ return (buffpos == buff.length);
+ }
+
+ // Search the next expression character
+ exprpos = ++charpos;
+ while (expr[charpos] >= 0) {
+ charpos++;
+ }
+ int prevchr = exprchr;
+ exprchr = expr[charpos];
+
+ // We have here prevchr == * or **.
+ offset = (prevchr == MATCH_FILE)
+ ? indexOfArray(expr, exprpos, charpos, buff, buffpos)
+ : lastIndexOfArray(expr, exprpos, charpos, buff,
+ buffpos);
+
+ if (offset < 0) {
+ return (false);
+ }
+
+ // Copy the data from the source buffer into the result buffer
+ // to substitute the expression character
+ if (prevchr == MATCH_PATH) {
+ while (buffpos < offset) {
+ rslt[rsltpos++] = buff[buffpos++];
+ }
+ } else {
+ // Matching file, don't copy '/'
+ while (buffpos < offset) {
+ if (buff[buffpos] == '/') {
+ return (false);
+ }
+ rslt[rsltpos++] = buff[buffpos++];
+ }
+ }
+
+ map.put(Integer.toString(++mcount), new String(rslt, 0, rsltpos));
+ rsltpos = 0;
+ }
+ }
+
+ /**
+ * Get the offset of a part of an int array within a char array.
+ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardPattern.java b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardPattern.java index 21c1e5c4..903fe20f 100644 --- a/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardPattern.java +++ b/src/main/java/org/tuckey/web/filters/urlrewrite/utils/WildcardPattern.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/ConfTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/ConfTest.java index 954183b2..297a6f90 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/ConfTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/ConfTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/OutboundRuleTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/OutboundRuleTest.java index c95e8eb4..f9c950e7 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/OutboundRuleTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/OutboundRuleTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlTest.java index 2ad2455d..ad59eb87 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/RewrittenUrlTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/RuleTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/RuleTest.java index 4aa47580..a0a69aa2 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/RuleTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/RuleTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/RunTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/RunTest.java index a7272fc1..b60c9e13 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/RunTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/RunTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/SetAttributeTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/SetAttributeTest.java index 6d79b71d..eb6bf2b0 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/SetAttributeTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/SetAttributeTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/StatusTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/StatusTest.java index 157a9c33..4649f6fd 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/StatusTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/StatusTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/TestRewriteMatch.java b/src/test/java/org/tuckey/web/filters/urlrewrite/TestRewriteMatch.java index 95255c79..01ecdd30 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/TestRewriteMatch.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/TestRewriteMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/TestRuleObj.java b/src/test/java/org/tuckey/web/filters/urlrewrite/TestRuleObj.java index aef0a02c..771e93da 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/TestRuleObj.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/TestRuleObj.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/TestServlet.java b/src/test/java/org/tuckey/web/filters/urlrewrite/TestServlet.java index 86462a58..f28be40c 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/TestServlet.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/TestServlet.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlDecoderTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlDecoderTest.java index 914a73db..e2b9faf8 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlDecoderTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlDecoderTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilterTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilterTest.java index 2262c130..645305bd 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilterTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteFilterTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteTestCaseTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteTestCaseTest.java index adede1f8..cc23f0b8 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteTestCaseTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteTestCaseTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponseTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponseTest.java index 28dcf3c4..caf27b81 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponseTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriteWrappedResponseTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriterTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriterTest.java index 83ad802b..45352f18 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriterTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/UrlRewriterTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatchTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatchTest.java index 304e0783..7892cc9e 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatchTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/json/JsonRewriteMatchTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRequestParser.java b/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRequestParser.java index 0d847af2..0d7d1b77 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRequestParser.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRequestParser.java @@ -1,128 +1,128 @@ -package org.tuckey.web.filters.urlrewrite.test; - -import org.tuckey.web.filters.urlrewrite.utils.Log; -import org.tuckey.web.filters.urlrewrite.utils.StringUtils; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * todo: IN PROGRESS - * - * Class to decode a request from one of three inputs. Literally: - * - * /blah.jsp - * - * or - * - * GET /blah.jsp HTTP/1.1 - * - * or - * - * GET /blah.jsp HTTP/1.1 - * user-agent: Mozilla 1.2.3 - * cookie: a:aaa - * - */ -public class MockRequestParser { - - private static Log log = Log.getLog(MockRequestParser.class); - - public MockRequest decodeRequest(String requestString) { - return decodeRequest(requestString.split("\n")); - } - - Pattern FIRST_LINE_PATTERN = Pattern.compile("^([A-Z]+) (.*) ([A-Z0-9/\\.]+)$"); - - public MockRequest decodeRequest(String[] requestLines) { - MockRequest request = new MockRequest(); - request.setRemoteAddr("127.0.0.1"); - request.setRemoteHost("localhost"); - - String line1 = requestLines[0]; - Matcher line1Matcher = FIRST_LINE_PATTERN.matcher(line1); - - String requestPart; - if (line1Matcher.matches()) { - request.setMethod(line1Matcher.group(1)); - requestPart = line1Matcher.group(2); - request.setScheme(line1Matcher.group(3)); - } else { - requestPart = line1; - } - - String requestUri = requestPart; - int questionMarkIdx = requestPart.indexOf('?'); - if (questionMarkIdx != -1) { - String queryString = requestPart.substring(questionMarkIdx + 1); - setParams(request, queryString); - requestUri = requestPart.substring(0, questionMarkIdx); - } - int semiColonIdx = requestUri.indexOf(';'); - if (semiColonIdx != -1) { - String sessionId = requestUri.substring(semiColonIdx + 1); - int equalsIdx = sessionId.indexOf('='); - if ( equalsIdx != -1 ) { - sessionId = sessionId.substring(equalsIdx+1); - } - request.setRequestedSessionId(sessionId); - requestUri = requestUri.substring(0, semiColonIdx); - } - request.setRequestURI(requestUri); - - if (requestLines.length > 1) { - boolean parsingBody = false; - for (int i = 0; i < requestLines.length; i++) { - if (i == 0) continue; - String line = requestLines[i]; - if (!parsingBody) { - if (line.length() == 0) { - parsingBody = true; - continue; - } - int colonIdx = line.indexOf(':'); - if (colonIdx < 1) { - log.debug("cannot parse line " + line); - continue; - } - String headerName = StringUtils.trimToNull(line.substring(0, colonIdx)); - String headerValue = StringUtils.trimToNull(line.substring(colonIdx + 1)); - if (headerName == null) { - log.debug("cannot parse line " + line); - continue; - } - request.setHeader(headerName, headerValue); - if ("host".equals(headerName.toLowerCase())) { - request.setServerName(headerValue); - } - } else { - setParams(request, line); - } - } - } - return request; - } - - private void setParams(MockRequest request, String queryString) { - request.setQueryString(queryString); - if (queryString.indexOf('&') != -1) { - String[] paramSets = queryString.split("&"); - for (int i = 0; i < paramSets.length; i++) { - addParamSet(request, paramSets[i]); - } - } else { - addParamSet(request, queryString); - } - } - - private void addParamSet(MockRequest request, String paramSet) { - if (paramSet.indexOf("=") != -1) { - String[] nameVal = paramSet.split("=", 2); - request.addParameter(nameVal[0], nameVal[1]); - } else { - log.info("cannot find value of request parameter " + paramSet); - } - } - - -} +package org.tuckey.web.filters.urlrewrite.test; + +import org.tuckey.web.filters.urlrewrite.utils.Log; +import org.tuckey.web.filters.urlrewrite.utils.StringUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * todo: IN PROGRESS + *
+ * Class to decode a request from one of three inputs. Literally: + *
+ * /blah.jsp + *
+ * or + *
+ * GET /blah.jsp HTTP/1.1 + *
+ * or + *
+ * GET /blah.jsp HTTP/1.1 + * user-agent: Mozilla 1.2.3 + * cookie: a:aaa + * + */ +public class MockRequestParser { + + private static Log log = Log.getLog(MockRequestParser.class); + + public MockRequest decodeRequest(String requestString) { + return decodeRequest(requestString.split("\n")); + } + + Pattern FIRST_LINE_PATTERN = Pattern.compile("^([A-Z]+) (.*) ([A-Z0-9/\\.]+)$"); + + public MockRequest decodeRequest(String[] requestLines) { + MockRequest request = new MockRequest(); + request.setRemoteAddr("127.0.0.1"); + request.setRemoteHost("localhost"); + + String line1 = requestLines[0]; + Matcher line1Matcher = FIRST_LINE_PATTERN.matcher(line1); + + String requestPart; + if (line1Matcher.matches()) { + request.setMethod(line1Matcher.group(1)); + requestPart = line1Matcher.group(2); + request.setScheme(line1Matcher.group(3)); + } else { + requestPart = line1; + } + + String requestUri = requestPart; + int questionMarkIdx = requestPart.indexOf('?'); + if (questionMarkIdx != -1) { + String queryString = requestPart.substring(questionMarkIdx + 1); + setParams(request, queryString); + requestUri = requestPart.substring(0, questionMarkIdx); + } + int semiColonIdx = requestUri.indexOf(';'); + if (semiColonIdx != -1) { + String sessionId = requestUri.substring(semiColonIdx + 1); + int equalsIdx = sessionId.indexOf('='); + if ( equalsIdx != -1 ) { + sessionId = sessionId.substring(equalsIdx+1); + } + request.setRequestedSessionId(sessionId); + requestUri = requestUri.substring(0, semiColonIdx); + } + request.setRequestURI(requestUri); + + if (requestLines.length > 1) { + boolean parsingBody = false; + for (int i = 0; i < requestLines.length; i++) { + if (i == 0) continue; + String line = requestLines[i]; + if (!parsingBody) { + if (line.length() == 0) { + parsingBody = true; + continue; + } + int colonIdx = line.indexOf(':'); + if (colonIdx < 1) { + log.debug("cannot parse line " + line); + continue; + } + String headerName = StringUtils.trimToNull(line.substring(0, colonIdx)); + String headerValue = StringUtils.trimToNull(line.substring(colonIdx + 1)); + if (headerName == null) { + log.debug("cannot parse line " + line); + continue; + } + request.setHeader(headerName, headerValue); + if ("host".equals(headerName.toLowerCase())) { + request.setServerName(headerValue); + } + } else { + setParams(request, line); + } + } + } + return request; + } + + private void setParams(MockRequest request, String queryString) { + request.setQueryString(queryString); + if (queryString.indexOf('&') != -1) { + String[] paramSets = queryString.split("&"); + for (int i = 0; i < paramSets.length; i++) { + addParamSet(request, paramSets[i]); + } + } else { + addParamSet(request, queryString); + } + } + + private void addParamSet(MockRequest request, String paramSet) { + if (paramSet.indexOf("=") != -1) { + String[] nameVal = paramSet.split("=", 2); + request.addParameter(nameVal[0], nameVal[1]); + } else { + log.info("cannot find value of request parameter " + paramSet); + } + } + + +} diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRewriteMatch.java b/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRewriteMatch.java index 6a69bc18..c37a642b 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRewriteMatch.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/test/MockRewriteMatch.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/test/TestRunObj.java b/src/test/java/org/tuckey/web/filters/urlrewrite/test/TestRunObj.java index c88864dd..0caa9e13 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/test/TestRunObj.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/test/TestRunObj.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/utils/LogTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/utils/LogTest.java index 6f2d250a..7a817a37 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/utils/LogTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/utils/LogTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcherTest.java b/src/test/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcherTest.java index 6983dfa4..7f2a520f 100644 --- a/src/test/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcherTest.java +++ b/src/test/java/org/tuckey/web/filters/urlrewrite/utils/StringMatchingMatcherTest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/testhelper/BenchmarkRunner.java b/src/test/java/org/tuckey/web/testhelper/BenchmarkRunner.java index a8b941ab..ca51e9ee 100644 --- a/src/test/java/org/tuckey/web/testhelper/BenchmarkRunner.java +++ b/src/test/java/org/tuckey/web/testhelper/BenchmarkRunner.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/testhelper/MockFilterChain.java b/src/test/java/org/tuckey/web/testhelper/MockFilterChain.java index 2866f303..58135e1f 100644 --- a/src/test/java/org/tuckey/web/testhelper/MockFilterChain.java +++ b/src/test/java/org/tuckey/web/testhelper/MockFilterChain.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/testhelper/MockFilterConfig.java b/src/test/java/org/tuckey/web/testhelper/MockFilterConfig.java index 776c993c..33cda02c 100644 --- a/src/test/java/org/tuckey/web/testhelper/MockFilterConfig.java +++ b/src/test/java/org/tuckey/web/testhelper/MockFilterConfig.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/testhelper/MockRequest.java b/src/test/java/org/tuckey/web/testhelper/MockRequest.java index e412abaf..c3e07bd2 100644 --- a/src/test/java/org/tuckey/web/testhelper/MockRequest.java +++ b/src/test/java/org/tuckey/web/testhelper/MockRequest.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/testhelper/MockRequestDispatcher.java b/src/test/java/org/tuckey/web/testhelper/MockRequestDispatcher.java index f0baba09..4281a3e4 100644 --- a/src/test/java/org/tuckey/web/testhelper/MockRequestDispatcher.java +++ b/src/test/java/org/tuckey/web/testhelper/MockRequestDispatcher.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/src/test/java/org/tuckey/web/testhelper/MockResponse.java b/src/test/java/org/tuckey/web/testhelper/MockResponse.java index 661e4ac0..d5e9b04b 100644 --- a/src/test/java/org/tuckey/web/testhelper/MockResponse.java +++ b/src/test/java/org/tuckey/web/testhelper/MockResponse.java @@ -3,11 +3,11 @@ * All rights reserved. * ==================================================================== * Licensed under the BSD License. Text as follows. - * + *
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS