Пример #1
0
  /**
   * Description of the Method
   *
   * @param s Description of the Parameter
   * @return Description of the Return Value
   */
  protected Element createContent(WebSession s) {
    boolean logout = s.getParser().getBooleanParameter(LOGOUT, false);

    if (logout) {
      s.setMessage("Goodbye!  Your password has been forgotten");
      s.eatCookies();

      return (makeLogin(s));
    }

    try {
      String user = checkCookie(s);

      if ((user != null) && (user.length() > 0)) {
        return (makeUser(s, user, "COOKIE"));
      }

      user = checkParams(s);

      if ((user != null) && (user.length() > 0)) {
        return (makeUser(s, user, "PARAMETERS"));
      }
    } catch (Exception e) {
      s.setMessage("Error generating " + this.getClass().getName());
      e.printStackTrace();
    }

    return (makeLogin(s));
  }
Пример #2
0
  /**
   * Description of the Method
   *
   * @param s Description of the Parameter
   * @return Description of the Return Value
   * @exception Exception Description of the Exception
   */
  protected String checkCookie(WebSession s) throws Exception {
    String cookie = getCookie(s);

    if (cookie != null) {
      if (cookie.equals(encode("webgoat12345"))) {
        return ("webgoat");
      }

      if (cookie.equals(encode("aspect12345"))) {
        return ("aspect");
      }

      if (cookie.equals(encode("alice12345"))) {
        makeSuccess(s);
        return ("alice");
      } else {
        s.setMessage("Invalid cookie");
        s.eatCookies();
      }
    }

    return (null);
  }