/* (non-Javadoc)
   * @see org.springframework.security.ui.rememberme.PersistentTokenRepository#createNewToken(org.springframework.security.ui.rememberme.PersistentRememberMeToken)
   */
  public void createNewToken(PersistentRememberMeToken token) {
    Cookie cookie = new Cookie();

    Calendar calendar = GregorianCalendar.getInstance();
    calendar.setTime(token.getDate());

    cookie.setLastUse(calendar);
    cookie.setIdentifier(token.getSeries());
    cookie.setUserName(token.getUsername());
    cookie.setValue(token.getTokenValue());

    try {
      create(cookie);
    } catch (BusinessException e) {
      e.printStackTrace();
    }
  }
  /* (non-Javadoc)
   * @see org.springframework.security.ui.rememberme.PersistentTokenRepository#updateToken(java.lang.String, java.lang.String, java.util.Date)
   */
  public void updateToken(String series, String tokenValue, Date lastUsed) {
    Cookie cookie = findById(series);

    if (cookie != null) {
      cookie.setValue(tokenValue);

      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(lastUsed);
      cookie.setLastUse(calendar);

      try {
        update(cookie);
      } catch (BusinessException e) {
        e.printStackTrace();
      }
    }
  }