From: chris_schultz Date: Fri, 18 Apr 2008 13:08:03 +0000 (+0000) Subject: Added configuration parameter to set the encoding used for forwarded parameters. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;p=securityfilter.git Added configuration parameter to set the encoding used for forwarded parameters. --- diff --git a/src/share/org/securityfilter/authenticator/FormAuthenticator.java b/src/share/org/securityfilter/authenticator/FormAuthenticator.java index 55ad1a8..b9cb627 100644 --- a/src/share/org/securityfilter/authenticator/FormAuthenticator.java +++ b/src/share/org/securityfilter/authenticator/FormAuthenticator.java @@ -1,7 +1,7 @@ /* - * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/authenticator/FormAuthenticator.java,v 1.12 2007/11/02 16:31:24 chris_schultz Exp $ - * $Revision: 1.12 $ - * $Date: 2007/11/02 16:31:24 $ + * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/authenticator/FormAuthenticator.java,v 1.13 2008/04/18 13:08:03 chris_schultz Exp $ + * $Revision: 1.13 $ + * $Date: 2008/04/18 13:08:03 $ * * ==================================================================== * The SecurityFilter Software License, Version 1.1 @@ -75,7 +75,7 @@ import java.io.UnsupportedEncodingException; * * @author Max Cooper (max@maxcooper.com) * @author Chris Schultz (chris@christopherschultz.net) - * @version $Revision: 1.12 $ $Date: 2007/11/02 16:31:24 $ + * @version $Revision: 1.13 $ $Date: 2008/04/18 13:08:03 $ */ public class FormAuthenticator implements Authenticator { @@ -127,6 +127,14 @@ public class FormAuthenticator implements Authenticator { */ public static final String FORWARD_PARAMETERS_PARAMETER_KEY = "forwardParametersParameter"; + + /** + * The key that will be used to look the filter init parameter + * that specifies the character encoding to be used for parameters + * forwarded from the login form. + */ + public static final String FORWARD_PARAMETERS_ENCODING_KEY = "forwardParametersEncoding"; + /** * The default value for {@link #forwardParameterName}. */ @@ -141,6 +149,11 @@ public class FormAuthenticator implements Authenticator { public static final String DEFAULT_FORWARD_PARAMETERS_PARAMETER_NAME = "forward-parameters"; /** + * The default encoding to be used for forwarded parameters. + */ + public static final String DEFAULT_FORWARD_PARAMETERS_ENCODING = "UTF-8"; + + /** * The name of the request parameter that will be recognized as a * post-login forward request. * @@ -172,6 +185,12 @@ public class FormAuthenticator implements Authenticator { */ protected String forwardParametersParameterName; + /** + * The character encoding that will be used to encode URL parameters + * forwarded through the login page. + */ + protected String forwardParametersEncoding; + /** * Initilize this Authenticator. * @@ -203,6 +222,11 @@ public class FormAuthenticator implements Authenticator { if(null == forwardParametersParameterName) forwardParametersParameterName = DEFAULT_FORWARD_PARAMETERS_PARAMETER_NAME; + // + forwardParametersEncoding = filterConfig.getInitParameter(FORWARD_PARAMETERS_ENCODING_KEY); + if(null == forwardParametersEncoding) + forwardParametersEncoding = DEFAULT_FORWARD_PARAMETERS_ENCODING; + // default page defaultPage = securityConfig.getDefaultPage(); @@ -547,9 +571,9 @@ public class FormAuthenticator implements Authenticator { queryString.append('&'); queryString - .append(URLEncoder.encode(name, "UTF-8")) + .append(URLEncoder.encode(name, forwardParametersEncoding)) .append('=') - .append(URLEncoder.encode(values[i], "UTF-8")); + .append(URLEncoder.encode(values[i], forwardParametersEncoding)); } } }