Fórum

How to get HttpServletRequest object from within Authenticator class?

thumbnail
Ricky Bobby, modificado 14 Anos atrás.

How to get HttpServletRequest object from within Authenticator class?

Junior Member Postagens: 32 Data de Entrada: 31/07/06 Postagens Recentes
Hi,

I'm implementing custom Authenticator class and am wondering if it is possible to get the HttpServletRequest and HttpServletResponse objects. How do one go about doing this?


Thanks
thumbnail
Ricky Bobby, modificado 14 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

Junior Member Postagens: 32 Data de Entrada: 31/07/06 Postagens Recentes
The class that I'm implementing is com.liferay.portal.security.auth.Authenticator

Again, is it possible to get the HttpServletRequest or PortletRequest from within the implemented class?
Khaja Shaik, modificado 14 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

New Member Postagens: 23 Data de Entrada: 09/06/09 Postagens Recentes
Hi Rick,

Try the following code in your Autherntication class.

HttpServletRequest origrequest = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));

and origrequest object will have all your request parameters.




Thanks,
KK
Dave Godbey, modificado 13 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

New Member Postagens: 9 Data de Entrada: 28/06/10 Postagens Recentes
This isn't going to work, is it? The renderRequest is not present in the authenticator.
thumbnail
Hir O, modificado 12 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

Junior Member Postagens: 30 Data de Entrada: 14/03/12 Postagens Recentes
have you solved this problem??
thumbnail
Ricky Bobby, modificado 14 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

Junior Member Postagens: 32 Data de Entrada: 31/07/06 Postagens Recentes
I solved my problem with ThreadLocal approach. I save the request and the response objects into the ThreadLocal variables from within the filter, then I can have access these 2 objects from anywhere within my application providing that your thread is still running/valid.

Google with HttpServletRequest and ThreadLocal as keywords for samples.
thumbnail
Brian Kim, modificado 14 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

Expert Postagens: 311 Data de Entrada: 17/08/04 Postagens Recentes
Rather than saving the entire request and response objects to the ThreadLocal, it would seem better to just save the attributes that you need.
Dave Godbey, modificado 13 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

New Member Postagens: 9 Data de Entrada: 28/06/10 Postagens Recentes
If you look at this the other way around, is there a utility that returns the session authenticator object?
thumbnail
ALex joubert, modificado 10 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

Junior Member Postagens: 27 Data de Entrada: 19/03/10 Postagens Recentes
HI

How Can I Use : SessionErrors.add (request, "Exception");

I can not retrieve request in a class that inherits from Authenticator

I want to display a custom message with "liferay-ui:error"
thumbnail
Krzysztof Gołębiowski, modificado 10 Anos atrás.

RE: How to get HttpServletRequest object from within Authenticator class?

Liferay Master Postagens: 549 Data de Entrada: 25/06/11 Postagens Recentes
Hello Alex,
I've done once custom message from authenticator (but that was long time ago so I don't remember exactly how it was done). I think I had to throw some specific custom exception from Authenticator and then display proper message in JSP.

I will try to find some code tomorrow.

Regards,
KG