Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ricky Bobby
How to get HttpServletRequest object from within Authenticator class?
June 11, 2009 3:07 PM
Answer

Ricky Bobby

Rank: Junior Member

Posts: 32

Join Date: July 31, 2006

Recent Posts

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
Ricky Bobby
RE: How to get HttpServletRequest object from within Authenticator class?
June 12, 2009 7:29 AM
Answer

Ricky Bobby

Rank: Junior Member

Posts: 32

Join Date: July 31, 2006

Recent Posts

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
RE: How to get HttpServletRequest object from within Authenticator class?
June 13, 2009 4:45 AM
Answer

Khaja Shaik

Rank: New Member

Posts: 23

Join Date: June 8, 2009

Recent Posts

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
Ricky Bobby
RE: How to get HttpServletRequest object from within Authenticator class?
June 15, 2009 1:13 PM
Answer

Ricky Bobby

Rank: Junior Member

Posts: 32

Join Date: July 31, 2006

Recent Posts

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.
Brian Kim
RE: How to get HttpServletRequest object from within Authenticator class?
June 15, 2009 5:24 PM
Answer

Brian Kim

LIFERAY STAFF

Rank: Expert

Posts: 319

Join Date: August 16, 2004

Recent Posts

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
RE: How to get HttpServletRequest object from within Authenticator class?
July 19, 2010 6:27 AM
Answer

Dave Godbey

Rank: New Member

Posts: 9

Join Date: June 28, 2010

Recent Posts

This isn't going to work, is it? The renderRequest is not present in the authenticator.
Dave Godbey
RE: How to get HttpServletRequest object from within Authenticator class?
July 19, 2010 6:28 AM
Answer

Dave Godbey

Rank: New Member

Posts: 9

Join Date: June 28, 2010

Recent Posts

If you look at this the other way around, is there a utility that returns the session authenticator object?
Hir O
RE: How to get HttpServletRequest object from within Authenticator class?
March 15, 2012 2:31 AM
Answer

Hir O

Rank: Junior Member

Posts: 30

Join Date: March 14, 2012

Recent Posts

have you solved this problem??
ALex joubert
RE: How to get HttpServletRequest object from within Authenticator class?
April 22, 2014 7:30 AM
Answer

ALex joubert

Rank: Junior Member

Posts: 25

Join Date: March 19, 2010

Recent Posts

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"
Krzysztof Gołębiowski
RE: How to get HttpServletRequest object from within Authenticator class?
April 22, 2014 2:03 PM
Answer

Krzysztof Gołębiowski

Rank: Expert

Posts: 335

Join Date: June 25, 2011

Recent Posts

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