我已经通过在 web.xml 中粘贴下面的代码,为特定地址的基本身份验证配置了 apache tomcat web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>
Protected Site
</web-resource-name>
<!-- This would protect the entire site -->
<url-pattern> /Documents/* </url-pattern>
<!-- If you list http methods,
only those methods are protected -->
<http-method> DELETE </http-method>
<http-method> GET </http-method>
<http-method> POST </http-method>
<http-method> PUT </http-method>
</web-resource-collection>
<auth-constraint>
<!-- Roles that have access -->
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<!-- BASIC authentication -->
<login-config>
<auth-method> BASIC </auth-method>
<realm-name>Authentication </realm-name>
</login-config>
<!-- Define security roles -->
<security-role>
<description> Test role </description>
<role-name>role1</role-name>
</security-role>
我得到了用于获取用户名和密码的浏览器基本身份验证对话框。并且在正确的用户名和密码之后,我获得了身份验证并且能够查看文档,否则无法查看。
现在一切正常,但是“我想使用 Adobe flex 编程绕过此身份验证,即通过在 flex 代码中提供用户名 N 密码,我希望此对话框不应该出现,并且用户通过代码进行身份验证。”