【问题标题】:Websphere: security-constraint in web.xml doesn't workWebsphere:web.xml 中的安全约束不起作用
【发布时间】:2011-02-23 04:48:52
【问题描述】:

我想保护单个 .jsp 页面免受匿名访问。我正在尝试通过以下方式做到这一点:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
t-webapp</display-name>
<servlet>
<servlet>
    <description>
    </description>
    <display-name>
    ZServlet</display-name>
    <servlet-name>ZServlet</servlet-name>
    <servlet-class>
    a.b.c.d.application.t.ZServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ZServlet</servlet-name>
    <url-pattern>/ZServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
    <display-name>
    TTests</display-name>
    <web-resource-collection>
        <web-resource-name>TTests</web-resource-name>
        <url-pattern>/ttests.jsp</url-pattern>
        <http-method>GET</http-method>
        <http-method>PUT</http-method>
        <http-method>HEAD</http-method>
        <http-method>TRACE</http-method>
        <http-method>POST</http-method>
        <http-method>DELETE</http-method>
        <http-method>OPTIONS</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description>
        TServletRoles</description>
        <role-name>role_admin1</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login.html</form-login-page>
        <form-error-page>/error.html</form-error-page>
    </form-login-config>
</login-config>
<security-role>
    <description>
    role_admin1</description>
    <role-name>role_admin1</role-name>
</security-role>

但每当我访问 ttests.jsp 时,我都会立即获得访问权限 - 无需填写用户名/密码……我错过了什么?

非常感谢!

【问题讨论】:

  • 您的 was 配置文件是否启用了安全性?
  • 我只是想写下答案:在管理控制台中启用全局安全...哇...就是这样...感谢您的回复(如果您写的是“官方”答案,我将接受它作为解决方案)

标签: websphere web.xml


【解决方案1】:

第一步是确保在您的 websphere 配置文件上启用全局安全性,并选中启用应用程序安全性复选框。

【讨论】:

    猜你喜欢
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多