将表单登录到tomcat中的安全应用程序

时间:2010-01-25 15:20:10

标签: java security apache tomcat login

我在普通的Apache http服务器(http://yyy.yyy.yyy.yyy/index.html)中有一个普通的HTML页面,带有一个身份验证表单,我需要使用该表单访问位于具有不同IP的其他服务器中的应用程序的凭据,服务器有一个带有tomcat的安全应用程序:这是apache http server中的登录表单:

<form method="POST" id="theForm" 
      action="http://xxx.xxx.xxx.xxx:8080/securedapp/j_security_check">
  <input name="j_username" type="text" class="tx_form" id="j_username" size="20" />
  <input name="j_password" type="password" class="tx_form" id="textfield2" size="20" />
  <input name="btn" type="submit" value="login" />
</form>

提交仅在Chrome中随机工作,不在IE和FF中工作。我做错了什么?

2 个答案:

答案 0 :(得分:0)

您缺少提交按钮。 当您按Enter键时,Chrome即使没有提交按钮也会发送值。 Firefox和IE没有。

如果您不想使用sumbit按钮(不推荐),您可以尝试类似

的内容
<input type='text' name='bla' onKeyDown="if (window.event.keyCode==13) this.form.submit();">

答案 1 :(得分:0)

我建议在firefox中安装tamperdata,然后点击篡改数据窗口中的“启动篡改”按钮。点击论坛上的提交,然后“篡改”请求。这将允许您查看和修改http请求中的所有数据。

从远程服务器发送请求与本地发送请求时可能存在一些差异。对于一个,“referer”将是不同的,一些应用程序将其视为CSRF保护的一种形式。另一件需要注意的事情是缺少get / post变量,你可能已经忘记了某些东西,或者可能用javascript修改了它。 Finley确保请求的content-type是相同的。

这是您更改帖子请求的内容类型的方式:

<form action="http://xxx.xxx.xxx.xxx:8080/securedapp/j_security_check"
    enctype="multipart/form-data"
    method="post">

另一种选择是使用Wireshark来捕获chrome / ie / firefox生成的http reqeust。您可以使用Meld之类的差异工具来比较数据包。