From a7d99a31d09fa2c398e5d640291e817b45f3c23f Mon Sep 17 00:00:00 2001 From: sandesh Date: Fri, 15 Jun 2018 23:23:43 +0530 Subject: [PATCH] Committing changes to set GMT timezone on Expires header --- .../authenticator/AuthenticatorBase.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java b/java/org/apache/catalina/authenticator/AuthenticatorBase.java index 360b964d6bd9..39ec7baa5575 100644 --- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java +++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java @@ -19,12 +19,14 @@ import java.io.IOException; import java.security.Principal; import java.security.cert.X509Certificate; +import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.TimeZone; import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; @@ -91,12 +93,25 @@ public abstract class AuthenticatorBase extends ValveBase implements Authenticator, RegistrationListener { private final Log log = LogFactory.getLog(AuthenticatorBase.class); // must not be static - + + /** + * Date format object for setting Expires header + */ + private static final DateFormat RFC1123_FORMAT; + + /** + * Pattern following the RFC1123 + */ + private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; + + static { + RFC1123_FORMAT = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); + RFC1123_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); + } /** * "Expires" header always set to Date(1), so generate once only */ - private static final String DATE_ONE = - (new SimpleDateFormat(FastHttpDateFormat.RFC1123_DATE, Locale.US)).format(new Date(1)); + private static final String DATE_ONE = RFC1123_FORMAT.format(new Date(1)); /** * The string manager for this package.