简体   繁体   中英

How does Liferay login work?

Just as the user jack wants to do in this post, I need to do a portlet that uses login through token authentication.
As is stated there, portal-impl.jar is unavailable for me to use, so LoginUtil.login is unaccessible.
Additionally, adding functionality to the existing ext plugin is almost out of the question because he's waaaay to 'dense', and creating another one is a bad practice.
So i chose to create my own login function based on the login() logic in LoginUtil . It's basically the same code but with the required portal-impl.jar 's properties stored locally (upgrade to a newer Liferay version is out of the question so I think it's ok to do that).
Everything seems to work fine, however I am not logged in and no error apperas in Tomcat.

Now, my problem is that I can't realise what piece of the code actually logs the user in.
I assume it's this

        session.setAttribute("j_username", userIdString);
        session.setAttribute("j_password", user.getPassword());
        session.setAttribute("j_remoteuser", userIdString);

        session.setAttribute(WebKeys.USER_PASSWORD, password);

PS : After my custom login method (which I repeat, it has the same code as LoginUtil's login method), if I put the following code :

ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
User uu = td.getUser();
System.out.println("user = " + uu.getEmailAddress());

it will output user = default@liferay.com , so the login is unsuccessful.
Where is the user logged in in that code?!

PPS: in my portal-ext.properties, here are the following add-ons:

auth.pipeline.enable.liferay.check=false
session.enable.persistent.cookies=true
session.enable.phishing.protection=false
session.disabled=false
session.test.cookie.support=true

My version of Liferay is 5.2.3.

Sorry, but my opinion, the better and simplest way is to create a new hook with AutoLogin funktion: How do I use autologin in liferay?

ps: and then you are upgrade stable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM