Reputation: 85
How can I get liferay logged-in user info in a portlet? I have the PortletRequest, but I don't know what can I get authenticated-info from request. getUser is not enough, I need to use again authentication.
Upvotes: 0
Views: 124
Reputation: 48057
If - by saying "authenticated-info" - you mean the username and password: Do not bother. They should never be kept in the session for security reasons (anybody could have access) and you should rather look up protocols like OAuth or use Single-Sign-On Tokens. In fact, if Liferay authentication is done through Single Sign On, Liferay will never even see the password.
If you mean extended information about the user, e.g. the full user object or the permission checker, you can get it from the themeDisplay
object, which you can obtain from portalRequest:
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
Look up the ThemeDisplay interface to get an idea what you can do with it. And don't get irritated by its name, take it as "current context".
Upvotes: 2