You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Nicolas ANTONIAZZI (JIRA)" <ji...@apache.org> on 2010/06/23 10:40:50 UTC

[jira] Created: (SHIRO-179) Invalid expires date format with non english default locale

Invalid expires date format with non english default locale
-----------------------------------------------------------

                 Key: SHIRO-179
                 URL: https://issues.apache.org/jira/browse/SHIRO-179
             Project: Shiro
          Issue Type: Bug
          Components: Web
         Environment: I'm on a french locale java system
            Reporter: Nicolas ANTONIAZZI


There is a problem with the "rememberMe" cookie feature.

A cookie is sent to the user to store the rememberMe data, but the expiration date used for the formating is the system default one.
In my case, expiration date are formated in french and the browser cannot correctly handle it (so rememberMe cookie will automatically be removed when the browser is closed)

A fix could be done in the class : org.apache.shiro.web.servlet.SimpleCookie

Around line 330 :

    private static String toCookieDate(Date date) {
        TimeZone tz = TimeZone.getTimeZone(GMT_TIME_ZONE_ID);
        DateFormat fmt = new SimpleDateFormat(COOKIE_DATE_FORMAT_STRING);  // Here, SimpleDateFormat use default Locale
        fmt.setTimeZone(tz);
        return fmt.format(date);
    }

replace with :

    private static String toCookieDate(Date date) {
        TimeZone tz = TimeZone.getTimeZone(GMT_TIME_ZONE_ID);
        DateFormat fmt = new SimpleDateFormat(COOKIE_DATE_FORMAT_STRING, Locale.ENGLISH); // Force english locale
        fmt.setTimeZone(tz);
        return fmt.format(date);
    }

---

A workaround is to replace the default local when calling the login() method :

	Locale systemLocale = Locale.getDefault();
	Locale.setDefault(Locale.ENGLISH);
	currentUser.login(token);
	Locale.setDefault(systemLocale);


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SHIRO-179) Invalid expires date format with non english default locale

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-179?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kalle Korhonen resolved SHIRO-179.
----------------------------------

         Assignee: Kalle Korhonen
    Fix Version/s: 1.0.1
       Resolution: Duplicate

> Invalid expires date format with non english default locale
> -----------------------------------------------------------
>
>                 Key: SHIRO-179
>                 URL: https://issues.apache.org/jira/browse/SHIRO-179
>             Project: Shiro
>          Issue Type: Bug
>          Components: Web
>         Environment: I'm on a french locale java system
>            Reporter: Nicolas ANTONIAZZI
>            Assignee: Kalle Korhonen
>             Fix For: 1.0.1
>
>
> There is a problem with the "rememberMe" cookie feature.
> A cookie is sent to the user to store the rememberMe data, but the expiration date used for the formating is the system default one.
> In my case, expiration date are formated in french and the browser cannot correctly handle it (so rememberMe cookie will automatically be removed when the browser is closed)
> A fix could be done in the class : org.apache.shiro.web.servlet.SimpleCookie
> Around line 330 :
>     private static String toCookieDate(Date date) {
>         TimeZone tz = TimeZone.getTimeZone(GMT_TIME_ZONE_ID);
>         DateFormat fmt = new SimpleDateFormat(COOKIE_DATE_FORMAT_STRING);  // Here, SimpleDateFormat use default Locale
>         fmt.setTimeZone(tz);
>         return fmt.format(date);
>     }
> replace with :
>     private static String toCookieDate(Date date) {
>         TimeZone tz = TimeZone.getTimeZone(GMT_TIME_ZONE_ID);
>         DateFormat fmt = new SimpleDateFormat(COOKIE_DATE_FORMAT_STRING, Locale.ENGLISH); // Force english locale
>         fmt.setTimeZone(tz);
>         return fmt.format(date);
>     }
> ---
> A workaround is to replace the default local when calling the login() method :
> 	Locale systemLocale = Locale.getDefault();
> 	Locale.setDefault(Locale.ENGLISH);
> 	currentUser.login(token);
> 	Locale.setDefault(systemLocale);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.