コード例 #1
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 checkParams(WebSession s) throws Exception {
    String username = s.getParser().getStringParameter(USERNAME, "");
    String password = s.getParser().getStringParameter(PASSWORD, "");

    if ((username.length() > 0) && (password.length() > 0)) {
      String loginID = "";

      if (username.equals("webgoat") && password.equals("webgoat")) {
        loginID = encode("webgoat12345");
      } else if (username.equals("aspect") && password.equals("aspect")) {
        loginID = encode("aspect12345");
      }

      if (loginID != "") {
        Cookie newCookie = new Cookie(AUTHCOOKIE, loginID);
        s.setMessage("Your identity has been remembered");
        s.getResponse().addCookie(newCookie);

        return (username);
      } else {
        s.setMessage("Invalid username and password entered.");
      }
    }

    return (null);
  }