我正在開發一個帶有Apache Tomcat和Java EE的簡單Web應用程序。停止Tomcat以保存用戶憑據
即時通訊使用我自己的JDBC域領域來保護和驗證用戶,我正在使用j_security_check的基本身份驗證方法。
我已經實現了一個註銷Servlet,一切工作正常。但是當我註銷時,我嘗試再次登錄時,應用程序或瀏覽器正在使用先前的憑據,它甚至不要求我輸入另一個憑證。它只是使用最新的憑證自動登錄。只有當我重置服務器並關閉我的瀏覽器(Chrome)時,tomcat再次詢問憑據。
我的目標是防止這種自動登錄過程。難道我做錯了什麼?
更新:我註銷Servlet是執行以下操作:
response.setHeader("Cache-Control", "no-cache, no-store");
response.setHeader("Pragma", "no-cache");
request.getSession().removeAttribute("logonSessData");
request.getSession().invalidate();
response.sendRedirect(request.getContextPath() + "/index.jsp");
我登錄的web.xml看起來就像這樣:
<security-constraint>
<display-name>userConstraint</display-name>
<web-resource-collection>
<web-resource-name>User pages</web-resource-name>
<description/>
<url-pattern>/users/*</url-pattern>
<url-pattern>/retos/misiones/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>user</role-name>
</auth-constraint>
<user-data-constraint>
<description/>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>SPERO</realm-name>
</login-config>
<security-role>
<description>Usuario registrado de SPERO</description>
<role-name>user</role-name>
</security-role>
<resource-ref>
<description>Spero DataBase Connection Pool</description>
<res-ref-name>jdbc/spero</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
您的註銷servlet在做什麼?它是否正確地使會話無效? – 2014-09-10 19:49:06
是的,我檢查過,當我發送錯誤的憑據數據時,容器拒絕訪問。所以我相信這不是一個身份驗證問題 – chntgomez 2014-09-11 01:27:06