You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Raj Kaushik <ra...@route1.com> on 2010/01/29 17:46:41 UTC

Trying to pass object to server side

Hi I am trying to manually pass certifcate to the server before authentication. But so far I am not successful.

// -- In the test client  --

//WebApplication  object is given
wicketTester = new WicketTester(webApp);
wicketTester.getApplication().getResourceSettings().setResourceStreamLocator(new CustomResourceStreamLocator());
//An attribute is set to the request
MockHttpServletRequest request = wicketTester.getServletRequest();
request.setAttribute("javax.servlet.request.X509Certificate", readCertificate());

wicketTester.startPage(SignIn.class);

// -- In the Server side
// During DEBUG I trace the call to the following 2 times
// One: when new Wicket Tester is created
// Two: after startPage

WebRequest webRequest = (WebRequest)request;
HttpServletRequest servletRequest = webRequest.getHttpServletRequest();
                X509Certificate certs[] = (X509Certificate[])servletRequest.getAttribute("javax.servlet.request.X509Certificate");

if(certs != null){
        setClientCertificate(certs[0]);
}

The problem is that the certificates are always null. How is it possible to pass on the object to the server side at the right time of the life cycle.

Any help or suggestions are highly appreciated.


Raj Kaushik
rajvkau@yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Trying to pass object to server side

Posted by rajkaushik <ra...@yahoo.com>.
Thanks Thomas. I agree Session should be the place for storing such objects.
But in the application as it is working. The Tomcat is passing information
via Servlet requests. I want to test the application as it is - without
changing the logic of the application.

Raj



Thomas Kappler-3 wrote:
> 
> On 01/29/10 17:46, Raj Kaushik wrote:
>> Hi I am trying to manually pass certifcate to the server before
>> authentication. But so far I am not successful.
> 
> The standard way to store things that must survive a request/response 
> cycle is in the Session. See the java doc for Session and Application:
> 
> "Session Properties - Arbitrary objects can be attached to a Session by 
> installing a session factory on your Application class which creates 
> custom Session subclasses that have typesafe properties specific to the 
> application (see Application for details). [...]"
> 
> -- Thomas
> 
> 
>>
>> // -- In the test client  --
>>
>> //WebApplication  object is given wicketTester = new
>> WicketTester(webApp);
>> wicketTester.getApplication().getResourceSettings().setResourceStreamLocator(new
>> CustomResourceStreamLocator()); //An attribute is set to the request
>> MockHttpServletRequest request = wicketTester.getServletRequest();
>> request.setAttribute("javax.servlet.request.X509Certificate",
>> readCertificate());
>>
>> wicketTester.startPage(SignIn.class);
>>
>> // -- In the Server side // During DEBUG I trace the call to the
>> following 2 times // One: when new Wicket Tester is created // Two:
>> after startPage
>>
>> WebRequest webRequest = (WebRequest)request; HttpServletRequest
>> servletRequest = webRequest.getHttpServletRequest(); X509Certificate
>> certs[] =
>> (X509Certificate[])servletRequest.getAttribute("javax.servlet.request.X509Certificate");
>>
>>  if(certs != null){ setClientCertificate(certs[0]); }
>>
>> The problem is that the certificates are always null. How is it
>> possible to pass on the object to the server side at the right time
>> of the life cycle.
>>
>> Any help or suggestions are highly appreciated.
>>
>>
>> Raj Kaushik rajvkau@yahoo.com
>>
>> ---------------------------------------------------------------------
>>
>>
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
> 
> 
> -- 
> -------------------------------------------------------------------
>    Thomas Kappler                        thomas.kappler@isb-sib.ch
>    Swiss Institute of Bioinformatics         Tel: +41 22 379 51 89
>    CMU, rue Michel Servet 1
>    1211 Geneve 4
>    Switzerland                              http://www.uniprot.org
> -------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Trying-to-pass-object-to-server-side-tp27374764p27376967.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Trying to pass object to server side

Posted by Thomas Kappler <th...@isb-sib.ch>.
On 01/29/10 17:46, Raj Kaushik wrote:
> Hi I am trying to manually pass certifcate to the server before
> authentication. But so far I am not successful.

The standard way to store things that must survive a request/response 
cycle is in the Session. See the java doc for Session and Application:

"Session Properties - Arbitrary objects can be attached to a Session by 
installing a session factory on your Application class which creates 
custom Session subclasses that have typesafe properties specific to the 
application (see Application for details). [...]"

-- Thomas


>
> // -- In the test client  --
>
> //WebApplication  object is given wicketTester = new
> WicketTester(webApp);
> wicketTester.getApplication().getResourceSettings().setResourceStreamLocator(new
> CustomResourceStreamLocator()); //An attribute is set to the request
> MockHttpServletRequest request = wicketTester.getServletRequest();
> request.setAttribute("javax.servlet.request.X509Certificate",
> readCertificate());
>
> wicketTester.startPage(SignIn.class);
>
> // -- In the Server side // During DEBUG I trace the call to the
> following 2 times // One: when new Wicket Tester is created // Two:
> after startPage
>
> WebRequest webRequest = (WebRequest)request; HttpServletRequest
> servletRequest = webRequest.getHttpServletRequest(); X509Certificate
> certs[] =
> (X509Certificate[])servletRequest.getAttribute("javax.servlet.request.X509Certificate");
>
>  if(certs != null){ setClientCertificate(certs[0]); }
>
> The problem is that the certificates are always null. How is it
> possible to pass on the object to the server side at the right time
> of the life cycle.
>
> Any help or suggestions are highly appreciated.
>
>
> Raj Kaushik rajvkau@yahoo.com
>
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


-- 
-------------------------------------------------------------------
   Thomas Kappler                        thomas.kappler@isb-sib.ch
   Swiss Institute of Bioinformatics         Tel: +41 22 379 51 89
   CMU, rue Michel Servet 1
   1211 Geneve 4
   Switzerland                              http://www.uniprot.org
-------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org