You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by icaro <ic...@rededc.com.br> on 2004/01/28 19:23:55 UTC

FormAuthentication error

According to document "http://jakarta.apache.org/cactus/writing/howto_security.html", i've tried to do my application
works with cactus + security. But i always catch the same error:

    [junit] Testcase: testFormAuthentication took 3,803 sec
    [junit]     Caused an ERROR
    [junit] Failed to get the test results at [http://felicia:7080/icaro/ServletRedirectorSecure]
    [junit] org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results at [http:
//felicia:7080/icaro/ServletRedirectorSecure]
    [junit]     at org.apache.cactus.client.connector.http.DefaultHttpClient.doTest_aroundBody0(Defa
ultHttpClient.java:131)
...
..
.
    [junit] org.apache.cactus.client.ParsingException: Not a valid response [302 Moved Temporarily]
...
..
.
    [junit] Testcase: testFormAuthentication
    [junit] TEST com.da.motion.infoAdmUserAdm.web.teste.TestLogin FAILED
 

Some help ?

++++++++++++++++++++++++++++++++++++++++++++++++++

My files and configurations are :

++++++++++++++++++++++++++++++++++++++++++++++++++

My class :

public class TestLogin extends TesteWebRoot
{
    public TestLogin(String name) 
    {
 super(name);
    }

    public void beginFormAuthentication(WebRequest theRequest) throws Exception 
    {
     theRequest.setRedirectorName("ServletRedirectorSecure");
 theRequest.setAuthentication(new FormAuthentication("root", "senha"));
    }
 
    public void testFormAuthentication() throws Exception 
    {
 // not reach
 System.out.println("Milagre !!!");
    }
}

++++++++++++++++++++++++++++++++++++++++++++++++++

My web.xml file :

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>

  <filter>
    <filter-name>Seguranca</filter-name>
    <filter-class>com.da.motion.geralComum.web.filter.WLSecurityFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>Seguranca</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

    <listener>
      <listener-class>com.da.motion.geralComum.web.classe.MotionWebListener</listener-class>
    </listener>

  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>MotionWebResources</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>useTokenByPass</param-name>
      <param-value>true</param-value>
    </init-param>
        <load-on-startup>2</load-on-startup>
  </servlet>


 <servlet>
     <servlet-name>ServletRedirector</servlet-name>
     <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
 </servlet>

 <servlet>
     <servlet-name>ServletRedirectorSecure</servlet-name>
     <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
 </servlet>

 <servlet>
     <servlet-name>ServletTestRunner</servlet-name>
     <servlet-class>org.apache.cactus.server.runner.ServletTestRunner</servlet-class>
 </servlet>


  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>


  <servlet-mapping>
         <servlet-name>ServletRedirector</servlet-name>
         <url-pattern>/ServletRedirector</url-pattern>
  </servlet-mapping>

    <servlet-mapping>
        <servlet-name>ServletRedirectorSecure</servlet-name>
        <url-pattern>/ServletRedirectorSecure</url-pattern>
    </servlet-mapping>


  <servlet-mapping>
         <servlet-name>ServletTestRunner</servlet-name>
         <url-pattern>/ServletTestRunner</url-pattern>
  </servlet-mapping>

  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <error-page>
    <error-code>500</error-code>
    <location>/com/da/motion/geralComum/web/jsp/erro.jsp</location>
  </error-page>

        <error-page>
                <!-- 400 code is from trying to go directly to login.jsp -->
                <error-code>400</error-code>
                <location>/login.do</location>
        </error-page>

  <!-- Restrições de acesso -->

  <!-- Forçando login no sistema -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>MotionLogin</web-resource-name>
      <description>Página de Login</description>
      <url-pattern>/login.do</url-pattern>
    </web-resource-collection>

    <auth-constraint>
        <role-name>logado</role-name>
    </auth-constraint>

    <user-data-constraint>
      <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>

  <security-constraint>
        <web-resource-collection>
                <web-resource-name>SecurityRestriction</web-resource-name>
                <description>Protect the Cactus redirector servlet.</description>
                <url-pattern>/ServletRedirectorSecure</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
        </web-resource-collection>

        <auth-constraint>
                <role-name>logado</role-name>
        </auth-constraint>

        <user-data-constraint>
                <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
  </security-constraint>


  <!-- Regras para Autenticação dos usuários -->
  <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>MotionSecurityRealm</realm-name>
    <form-login-config>
        <form-login-page>/logon.jsp</form-login-page>
        <form-error-page>/logon.jsp</form-error-page>
    </form-login-config>
  </login-config>


  <!-- Regras para Autenticação na parte de testes -->
  <!--
  <login-config>
      <auth-method>BASIC</auth-method>
  </login-config>
  -->

  <!-- Grupos de usuários -->
  <security-role>
    <description>
       Todos os usuários logados do sistema
    </description>
    <role-name>
       logado
    </role-name>
  </security-role>

</web-app>

++++++++++++++++++++++++++++++++++++++++++++++++++

My tomcat-users.xml file :

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <role rolename="logado"/>
  <user username="tomcat" password="senha" roles="admin,manager,tomcat,logado"/>
  <user username="both" password="senha" roles="tomcat,role1"/>
  <user username="role1" password="senha" roles="role1"/>
  <user username="root" password="senha" roles="logado"/>
</tomcat-users>

Thanks,

Icaro Tuicci

"Aprenda a viver contente em toda e qualquer situação" Filipenses 4:11