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 karthik Guru <ka...@yahoo.com> on 2003/08/01 15:10:48 UTC
Regarding BUG: 17933 (FormAuthentication assumes "localhost" when adding cookies )
Hi,
This is regarding the bug listed here.
http://issues.apache.org/bugzilla/show_bug.cgi?id=17933
I was trying to fix it .
File: FormAuthentication.java
Method:
public void configure(WebRequest theRequest,
Configuration theConfiguration);
I guess i can get the context URL set in the
cactus.properties file this way
String contextURL = theConfiguration.getContextURL();
Now can i do a substring operation to extract the
domain name from the context URL and call
theRequest.addCookie(domainName,this.sessionIdCookieName,
this.sessionId);
I mean does cactus have some utility methods /
something that knows how to extract the domain name
properly from the contextURL?
I just want to make sure that i'm doing the right
thing in a right way.
I guess we can also do
webRequest.setURL() when using FormAuthentication;
if that is the case, i guess , I can extract the
domain/host name using ServletURL.getHost()
So what s'd i be doing in the implementation
FormAuthentication::configure()?
1. Do substring on contextURL OR
2. ServletURL.getHost()
OR try doing 1) and if it fails do 2)
Hope am not bugging the cactus commiters too much
here.
thanks,
karthik
--- Sachin <cs...@pisoftek.com> wrote:
> Hi All,
> I am trying to write TestCase of example
> Specified in StrutsTestCase
> which says that we can use both CactusStrutsTestCase
> or MockStrutsTestCase..
>
> But when i am trying to run it it is giving error
> like this..
>
>
> [main] INFO util.PropertyMessageResources -
> Initializing,
> config='org.apache.struts.util.LocalStrings',
> returnNull=true
> [main] INFO util.PropertyMessageResources -
> Initializing,
> config='org.apache.struts.action.ActionResources',
> returnNull=true
>
> Time: 0.625
> There was 1 failure:
> 1)
>
testAction(logic.struts.actions.TestFirstAction)junit.framework.AssertionFai
> ledError: Error running action.perform(): class
> java.lang.NullPointerException - null
> at
>
servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:
> 339)
> at
>
logic.struts.actions.TestFirstAction.testAction(TestFirstAction.java:47)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
> at
>
com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
>
> FAILURES!!!
> Tests run: 1, Failures: 1, Errors: 0
>
> Process terminated with exit code -1
>
>
>
>
> My Code is
>
>
> package logic.struts.actions;
>
> import servletunit.struts.MockStrutsTestCase;
> import servletunit.struts.CactusStrutsTestCase;
>
> import javax.servlet.ServletException;
>
> public class TestFirstAction extends
> MockStrutsTestCase{
>
> public TestFirstAction(String testName) {
> super(testName); }
>
> public void testAction() {
> setRequestPathInfo("/firstAction");
> actionPerform();
> verifyForward("second");
> }
>
> public void setUp() throws Exception {
> super.setUp();
> }
>
> protected void tearDown() throws Exception {
> super.tearDown();
> }
>
> }
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
RE: Regarding BUG: 17933 (FormAuthentication assumes "localhost" when adding cookies )
Posted by Vincent Massol <vm...@pivolis.com>.
Hi Karthik,
Thanks for helping us. You shouldn't use the setURL() method as it is
used to set a simulation URL (not a real one). The Configuration
interface only provides a getContextURL() method that will return
something of the form:
http://servername:port/contextname
What is the domain name? Is it the servername:port part? In any case,
one good option to extract it is to use the URL class. Something like:
URL url = new URL(theConfiguration.getContextURL());
String domainname = url.getHost();
Thanks
-Vincent
> -----Original Message-----
> From: karthik Guru [mailto:karthik_guru2000@yahoo.com]
> Sent: 01 August 2003 15:11
> To: Cactus Users List
> Subject: Regarding BUG: 17933 (FormAuthentication assumes "localhost"
when
> adding cookies )
>
>
> Hi,
>
> This is regarding the bug listed here.
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=17933
>
> I was trying to fix it .
>
> File: FormAuthentication.java
> Method:
>
> public void configure(WebRequest theRequest,
> Configuration theConfiguration);
>
>
> I guess i can get the context URL set in the
> cactus.properties file this way
> String contextURL = theConfiguration.getContextURL();
>
> Now can i do a substring operation to extract the
> domain name from the context URL and call
>
> theRequest.addCookie(domainName,this.sessionIdCookieName,
> this.sessionId);
>
> I mean does cactus have some utility methods /
> something that knows how to extract the domain name
> properly from the contextURL?
>
> I just want to make sure that i'm doing the right
> thing in a right way.
>
> I guess we can also do
>
> webRequest.setURL() when using FormAuthentication;
>
> if that is the case, i guess , I can extract the
> domain/host name using ServletURL.getHost()
>
> So what s'd i be doing in the implementation
> FormAuthentication::configure()?
>
> 1. Do substring on contextURL OR
> 2. ServletURL.getHost()
>
> OR try doing 1) and if it fails do 2)
>
> Hope am not bugging the cactus commiters too much
> here.
>
> thanks,
> karthik
>
> --- Sachin <cs...@pisoftek.com> wrote:
> > Hi All,
> > I am trying to write TestCase of example
> > Specified in StrutsTestCase
> > which says that we can use both CactusStrutsTestCase
> > or MockStrutsTestCase..
> >
> > But when i am trying to run it it is giving error
> > like this..
> >
> >
> > [main] INFO util.PropertyMessageResources -
> > Initializing,
> > config='org.apache.struts.util.LocalStrings',
> > returnNull=true
> > [main] INFO util.PropertyMessageResources -
> > Initializing,
> > config='org.apache.struts.action.ActionResources',
> > returnNull=true
> >
> > Time: 0.625
> > There was 1 failure:
> > 1)
> >
>
testAction(logic.struts.actions.TestFirstAction)junit.framework.Assertio
nF
> ai
> > ledError: Error running action.perform(): class
> > java.lang.NullPointerException - null
> > at
> >
>
servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.j
av
> a:
> > 339)
> > at
> >
>
logic.struts.actions.TestFirstAction.testAction(TestFirstAction.java:47)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > at
> >
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:
> 39
> > )
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Im
> pl
> > .java:25)
> > at
> >
>
com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:
12
> )
> >
> > FAILURES!!!
> > Tests run: 1, Failures: 1, Errors: 0
> >
> > Process terminated with exit code -1
> >
> >
> >
> >
> > My Code is
> >
> >
> > package logic.struts.actions;
> >
> > import servletunit.struts.MockStrutsTestCase;
> > import servletunit.struts.CactusStrutsTestCase;
> >
> > import javax.servlet.ServletException;
> >
> > public class TestFirstAction extends
> > MockStrutsTestCase{
> >
> > public TestFirstAction(String testName) {
> > super(testName); }
> >
> > public void testAction() {
> > setRequestPathInfo("/firstAction");
> > actionPerform();
> > verifyForward("second");
> > }
> >
> > public void setUp() throws Exception {
> > super.setUp();
> > }
> >
> > protected void tearDown() throws Exception {
> > super.tearDown();
> > }
> >
> > }
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > cactus-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org