Shiro
  1. Shiro
  2. SHIRO-179

Invalid expires date format with non english default locale

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: 1.1.0
    • Component/s: Web
    • Labels:
      None
    • Environment:
      I'm on a french locale java system

      Description

      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);

        Issue Links

          Activity

          Nicolas ANTONIAZZI created issue -
          Kalle Korhonen made changes -
          Field Original Value New Value
          Link This issue duplicates SHIRO-177 [ SHIRO-177 ]
          Kalle Korhonen made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Kalle Korhonen [ kaosko ]
          Fix Version/s 1.0.1 [ 12314741 ]
          Resolution Duplicate [ 3 ]
          Les Hazlewood made changes -
          Fix Version/s 1.1.0 [ 12314742 ]
          Fix Version/s 1.0.1 [ 12314741 ]
          Les Hazlewood made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Kalle Korhonen
              Reporter:
              Nicolas ANTONIAZZI
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development