Abhishek Jain Abhishek Jain - 2 months ago 16
Java Question

How to get login credentials in liferay?

I made a hook by implementing

login.jsp
inside
/html/portlet/login
folder.
Now I tried to get the login credentials submitted through the default login form. The code which I tried is:-

request.getParameter("login")


but it could not retrieve login credential so I want to ask how to retrieve login credential.

Answer

You can get username and password by using following ways:

String username = themeDisplay.getUser().getScreenName();

String password = (String)request.getSession().getAttribute(WebKeys.USER_PASSWORD);

and write the below lines in portal-ext.properties:

session.store.password=true

session.shared.attributes.excludes=

But you need to take the precaution because when you use session.store.password=true then passwords will be stored n clear text and the same will be appear in dumps.

I hope this resolves your issue.

Comments