获取UT005023,UT010019响应已经在Wildfly,Struts2和常规插件的安全页面上提交

时间:2016-04-09 01:01:08

标签: security servlets java-ee

这是我第一个使用Struts2的项目。我正在使用常规插件并在Wildfly上运行整个事情。我已经创建了一些操作,比如user-registration.action,它们运行正常。但是,一旦我添加了安全性,我就开始在标题中得到错误。当我尝试登录时会发生这种情况。登录页面永远不会出现,而是我收到错误。

这是我的web.xml的相关部分

<welcome-file-list>
  <welcome-file>/index.action</welcome-file>
</welcome-file-list>

<security-constraint>
  <web-resource-collection>
    <web-resource-name>SecurePages</web-resource-name>
    <description>All secure pages</description>
    <url-pattern>/secure/*</url-pattern>
    <http-method>POST</http-method>
    <http-method>GET</http-method>
  </web-resource-collection>
  <auth-constraint>
    <role-name>Security Admin</role-name>
  </auth-constraint>
  <user-data-constraint>
    <description>SSL not required</description>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>
<security-constraint>
  <display-name>No direct JSP access</display-name>
  <web-resource-collection>
      <web-resource-name>No-JSP</web-resource-name>
      <url-pattern>*.jsp</url-pattern>
  </web-resource-collection>
  <auth-constraint>
      <role-name>no-users</role-name>
  </auth-constraint>
</security-constraint>

<login-config>
  <auth-method>FORM</auth-method>
  <form-login-config>
    <form-login-page>/login.action</form-login-page>
    <form-error-page>/login-failed.action</form-error-page>
  </form-login-config>
</login-config>

这是Struts2显示主页的操作。有用。它映射到/context/index.action,它位于web.xml中的欢迎文件列表中

@Result(name = "success", type = "tiles", location = "index")
public class IndexAction extends ActionSupport
{
  public String execute() throws Exception
  {
    return SUCCESS;
  }
}

这是显示登录页面的代码。如果我直接访问它,比如/context/login.action,它会成功显示登录页面。但是,如果我真的尝试登录,则不会显示。

@Result(name = "success", type = "tiles", location = "login")
public class LoginAction extends ActionSupport
{
  public String execute()
  {
    return SUCCESS;
  }
}

这是在登录后要执行的Struts2操作。这映射到/context/secure/secure-index.action。这是&#34;登录&#34;主页菜单栏上的菜单项。

@Result(name = "success", type = "tiles", location = "secure_index")
public class SecureIndexAction extends ActionSupport
{
  public String execute() throws Exception
  {
    return SUCCESS;
  }
}

这是堆栈跟踪:

ERROR [io.undertow.request] (default task-5) UT005023: Exception handling request to /campaigner-security/login.action: java.lang.IllegalStateException: UT010019: Response already commited
at io.undertow.servlet.spec.HttpServletResponseImpl.sendError(HttpServletResponseImpl.java:124) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.HttpServletResponseImpl.sendError(HttpServletResponseImpl.java:167) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]

如果直接使用,login.action和login-failed.action可以正常工作。

我需要做些什么来解决这个问题?

1 个答案:

答案 0 :(得分:0)

  1. 您可以对欢迎文件和登录后要访问的目标页面(例如secure / index.action)使用Struts2操作,并使用Tiles完成。
  2. 您不能对表单登录页面或表单错误页面使用Struts2操作。它们必须是JSP
  3. 这些JSP不能包含Tiles,因为它使用Struts2
  4. 这些JSP不能在WEB-INF / content中,因为它再次使用Struts2。