【问题标题】:Websphere j_security_check struts2 issueWebsphere j_security_check struts2 问题
【发布时间】:2012-06-26 10:42:51
【问题描述】:

我有一个使用基于表单的身份验证在 JBOSS 中运行良好的 Web 项目。但是当我在 websphere 7 中部署相同的内容时,我收到了 HTTP 500 错误。

我的web.xml

<display-name>Test</display-name>
<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
    <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
</listener>
<context-param>
    <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
    <param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>test_actions</web-resource-name>
        <description></description>
        <url-pattern>*.action</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description></description>
        <role-name>testuser</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <security-role>
    <description></description>
    <role-name>testuser</role-name>
  </security-role>

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Default</realm-name>
    <form-login-config>
        <form-login-page>/login_form.jsp</form-login-page>
        <form-error-page>/login_error.jsp</form-error-page>
    </form-login-config>
</login-config>

index.html

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>TEST</title>
</head>
<body onload="document.MainForm.submit();">
    <form action="welcomeAction.action" method="post" id="MainForm" name="MainForm">
</form>
</body>
</html>

我有一个拦截器AuthorizationInterceptor,它扩展了RolesInterceptor,这个拦截器实际上检查用户是否存在于我们的数据库中request.getUserPrincipal().getName() 用于获取用户 ID。所以当 welcomeAction.action 被调用时,它应该已经到了 AuthorizationInterceptor,但请求永远不会到达这里。

在 websphere 中,我启用了全局安全性。 Websphere LoginForm 示例工作正常。我是否必须自己纠正 j_security_check 过滤器?或 websphere webcontainer 处理这个。 (在 LoginForm 中我看到了 LoginFilter 代码)。但我相信 websphere webcontainer 应该处理 j_security_check 之类的东西,比如 jboss 或 tomcat..

【问题讨论】:

    标签: java struts2 websphere-7 j-security-check


    【解决方案1】:

    您必须创建一个自定义表单并提交给 j_security_check。默认情况下,WebSphere 不处理此问题。 参考:http://www.redbooks.ibm.com/abstracts/tips0220.html?Open

    【讨论】:

      猜你喜欢
      • 2011-03-28
      • 2011-04-01
      • 2012-04-24
      • 2012-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-03
      • 1970-01-01
      相关资源
      最近更新 更多