# This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -33,11 +33,14 @@ */ package info.magnolia.cms.security.auth.callback; +import info.magnolia.context.MgnlContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.text.MessageFormat; +import java.util.Set; +import org.apache.commons.lang.StringUtils; /** * An HttpClientCallback implementation which redirects to a configured path or URL. @@ -83,7 +86,27 @@ try { // formats the target location with the request url, to allow passing it has a parameter, for instance. - final String encodedUrl = URLEncoder.encode(request.getRequestURL().toString(), "UTF-8"); + String url = request.getRequestURL().toString(); + if (MgnlContext.getParameters() != null && !MgnlContext.getParameters().isEmpty()) { + Set keys = MgnlContext.getParameters().keySet(); + String parameterString = ""; + String[] values; + for (String key : keys) { + // we don't want to pass along the mgnlLogut parameter on a + // login action + if (!key.equals("mgnlLogout")) { + values = MgnlContext.getParameterValues(key); + for (int i = 0; i < values.length; i++) { + parameterString += key + "=" + values[i] + "&"; + } + } + } + if (StringUtils.isNotBlank(parameterString)) { + // cut off trailing "&" + url += "?" + StringUtils.substringBeforeLast(parameterString, "&"); + } + } + final String encodedUrl = URLEncoder.encode(url, "UTF-8"); final String formattedTarget = MessageFormat.format(target, encodedUrl); response.sendRedirect(formattedTarget); } catch (IOException e) {