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 "Mahfouz, Ayman" <ay...@citigroup.com> on 2004/05/18 21:33:29 UTC

BasicAuthentication fails with struts app

I have been successful developing a couple of cactus tests for the
HelloWorldServlet that ships with weblogic 8. I also SUCCEEDED in
running the basic authentication example after securing the
ServletRedirectorSecure and using a weblogic admin user that is mapped
to the role "Admin". When I try to run the same example on a
STRUTS-based web application it fails with the given trace:

 

org.apache.cactus.util.ChainedRuntimeException: Failed to get the test
results at [http://localhost:7001/citialert_web/ServletRedirectorSecure]

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
t_aroundBody0(DefaultHttpClient.java:92)

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
t_aroundBody1$advice(DefaultHttpClient.java:206)

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
t(DefaultHttpClient.java)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
WebTest(HttpProtocolHandler.java:159)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
Test_aroundBody0(HttpProtocolHandler.java:80)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
Test_aroundBody1$advice(HttpProtocolHandler.java:206)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
Test(HttpProtocolHandler.java)

            at
org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTes
tCaseCaller.java:144)

            at
org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(Abstract
CactusTestCase.java:215)

            at
org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactus
TestCase.java:133)

            at junit.framework.TestResult$1.protect(TestResult.java:106)

            at
junit.framework.TestResult.runProtected(TestResult.java:124)

            at junit.framework.TestResult.run(TestResult.java:109)

            at junit.framework.TestCase.run(TestCase.java:118)

            at junit.framework.TestSuite.runTest(TestSuite.java:208)

            at junit.framework.TestSuite.run(TestSuite.java:203)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:392)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:276)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:167)

org.apache.cactus.internal.client.ParsingException: Not a valid response
[401 Unauthorized xxx]

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callG
etResult(DefaultHttpClient.java:211)

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
t_aroundBody0(DefaultHttpClient.java:87)

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
t_aroundBody1$advice(DefaultHttpClient.java:206)

            at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
t(DefaultHttpClient.java)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
WebTest(HttpProtocolHandler.java:159)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
Test_aroundBody0(HttpProtocolHandler.java:80)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
Test_aroundBody1$advice(HttpProtocolHandler.java:206)

            at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
Test(HttpProtocolHandler.java)

            at
org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTes
tCaseCaller.java:144)

            at
org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(Abstract
CactusTestCase.java:215)

            at
org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactus
TestCase.java:133)

            at junit.framework.TestResult$1.protect(TestResult.java:106)

            at
junit.framework.TestResult.runProtected(TestResult.java:124)

            at junit.framework.TestResult.run(TestResult.java:109)

            at junit.framework.TestCase.run(TestCase.java:118)

            at junit.framework.TestSuite.runTest(TestSuite.java:208)

            at junit.framework.TestSuite.run(TestSuite.java:203)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:392)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:276)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:167)

 

 

I debugged a little bit and it seems that the resultConnection in the
DefaultHttpClient is returning a responseCode = -1.

Please help. 

A fragment of web.xml is below

<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>

      <description>Authorized Users Group</description>

      <role-name>Admin</role-name>

    </auth-constraint>

    <user-data-constraint>

      <transport-guarantee>NONE</transport-guarantee>

    </user-data-constraint>

  </security-constraint>

 

  <login-config>

    <auth-method>BASIC</auth-method>

    <realm-name>myrealm</realm-name>    

  </login-config> 

  <security-role>

    <description>The admin role</description>

    <role-name>Admin</role-name>

  </security-role>


RE: BasicAuthentication fails with struts app

Posted by Vincent Massol <vm...@pivolis.com>.
Hi,

Could you turn logging on the server side? You'll find the reason for
the error in there.
 
Thanks
-Vincent

> -----Original Message-----
> From: Mahfouz, Ayman [mailto:ayman.mahfouz@citigroup.com]
> Sent: 18 May 2004 21:33
> To: cactus-user@jakarta.apache.org
> Subject: BasicAuthentication fails with struts app
> 
> I have been successful developing a couple of cactus tests for the
> HelloWorldServlet that ships with weblogic 8. I also SUCCEEDED in
> running the basic authentication example after securing the
> ServletRedirectorSecure and using a weblogic admin user that is mapped
> to the role "Admin". When I try to run the same example on a
> STRUTS-based web application it fails with the given trace:
> 
> 
> 
> org.apache.cactus.util.ChainedRuntimeException: Failed to get the test
> results at
[http://localhost:7001/citialert_web/ServletRedirectorSecure]
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
> t_aroundBody0(DefaultHttpClient.java:92)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
> t_aroundBody1$advice(DefaultHttpClient.java:206)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
> t(DefaultHttpClient.java)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> WebTest(HttpProtocolHandler.java:159)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> Test_aroundBody0(HttpProtocolHandler.java:80)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> Test_aroundBody1$advice(HttpProtocolHandler.java:206)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> Test(HttpProtocolHandler.java)
> 
>             at
>
org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTes
> tCaseCaller.java:144)
> 
>             at
>
org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(Abstract
> CactusTestCase.java:215)
> 
>             at
>
org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactus
> TestCase.java:133)
> 
>             at
junit.framework.TestResult$1.protect(TestResult.java:106)
> 
>             at
> junit.framework.TestResult.runProtected(TestResult.java:124)
> 
>             at junit.framework.TestResult.run(TestResult.java:109)
> 
>             at junit.framework.TestCase.run(TestCase.java:118)
> 
>             at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 
>             at junit.framework.TestSuite.run(TestSuite.java:203)
> 
>             at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:392)
> 
>             at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:276)
> 
>             at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> nner.java:167)
> 
> org.apache.cactus.internal.client.ParsingException: Not a valid
response
> [401 Unauthorized xxx]
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callG
> etResult(DefaultHttpClient.java:211)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
> t_aroundBody0(DefaultHttpClient.java:87)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
> t_aroundBody1$advice(DefaultHttpClient.java:206)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTes
> t(DefaultHttpClient.java)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> WebTest(HttpProtocolHandler.java:159)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> Test_aroundBody0(HttpProtocolHandler.java:80)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> Test_aroundBody1$advice(HttpProtocolHandler.java:206)
> 
>             at
>
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.run
> Test(HttpProtocolHandler.java)
> 
>             at
>
org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTes
> tCaseCaller.java:144)
> 
>             at
>
org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(Abstract
> CactusTestCase.java:215)
> 
>             at
>
org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactus
> TestCase.java:133)
> 
>             at
junit.framework.TestResult$1.protect(TestResult.java:106)
> 
>             at
> junit.framework.TestResult.runProtected(TestResult.java:124)
> 
>             at junit.framework.TestResult.run(TestResult.java:109)
> 
>             at junit.framework.TestCase.run(TestCase.java:118)
> 
>             at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 
>             at junit.framework.TestSuite.run(TestSuite.java:203)
> 
>             at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:392)
> 
>             at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:276)
> 
>             at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> nner.java:167)
> 
> 
> 
> 
> 
> I debugged a little bit and it seems that the resultConnection in the
> DefaultHttpClient is returning a responseCode = -1.
> 
> Please help.
> 
> A fragment of web.xml is below
> 
> <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>
> 
>       <description>Authorized Users Group</description>
> 
>       <role-name>Admin</role-name>
> 
>     </auth-constraint>
> 
>     <user-data-constraint>
> 
>       <transport-guarantee>NONE</transport-guarantee>
> 
>     </user-data-constraint>
> 
>   </security-constraint>
> 
> 
> 
>   <login-config>
> 
>     <auth-method>BASIC</auth-method>
> 
>     <realm-name>myrealm</realm-name>
> 
>   </login-config>
> 
>   <security-role>
> 
>     <description>The admin role</description>
> 
>     <role-name>Admin</role-name>
> 
>   </security-role>