liferay portlet: how to use autologin (alternatives also welcome)

倖福魔咒の 提交于 2019-12-06 06:14:34

What's this "external token service"? Is it an SSO (Single Sign On) system that Liferay happens to work with out of the box?

Take a look at liferay's web.xml - there's a lot of SSO filters in there - you'll find the implementation in liferay's source code. These filters are used for handling SSO systems and do everything that's necessary to log someone in without username/password validation in the portal itself. You might be able to find the variant that best suites your needs here.

F. Lancer

Create your own filter (implements com.liferay.portal.security.auth.AutoLogin):

public class YourAutoLogin implements AutoLogin {...}

and implement login method with code:

public String[] login(HttpServletRequest req, HttpServletResponse resp)
  throws AutoLoginException {
    ...
    req.getSession().setAttribute(WebKeys.USER_ID,
    Long.valueOf(authenticatedUserId));
    ...
}

where authenticatedUserId is equal to ID of the authenticated user in Liferay directory.

Add you filter as hook (file /WEB-INF/classes/portal.properties in your web app):

auto.login.hooks=com.company.filter.YourAutoLogin
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!