论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
William Gosse
6.05 AutoLogin not working in 6.1 GA2
2012年9月7日 下午2:07
答复

William Gosse

等级: Regular Member

帖子: 108

加入日期: 2010年7月4日

最近的帖子

I have a custom AutoLogin class that worked fine in 6.05 but not in 6.1 GA2. When I step through the code with a debugger everything seems to execute correctly and my credentials array gets built and returned. However, instead of going to my requested page I'm landing on the on the sign in page. Does anyone know of any changes that were made for autologins in 6.1? I should mention that I'm passing the encrypted liferay password in my request. Here's my code:

 1
 2public class SQAutoLogin implements AutoLogin {
 3    private static Log s_log = LogFactoryUtil.getLog(SQAutoLogin.class.getName());
 4    private static final String REQUESTURI = "/web/guest/pdf-reports";
 5    private static final String REQUESTPARM = "al";
 6
 7    public String[] login(HttpServletRequest request,
 8            HttpServletResponse response) throws AutoLoginException {
 9        String credentials[] = null;
10
11        try {
12            String requestURI = request.getRequestURI();
13            if (!requestURI.equals(REQUESTURI)) {
14                return null;
15            }
16
17            String paramValues = request.getParameter(REQUESTPARM);
18            if (paramValues == null) {
19                throw new Exception("Autologin request parameters are null.");
20            }
21
22            String s[] = paramValues.split(";");
23            Long userId = Long.valueOf(s[0]);
24            String password = s[1];
25            
26            boolean success = UserLocalServiceUtil.authenticateForJAAS(userId, password);
27            if(success) {
28                credentials = new String[3];
29                credentials[0] = String.valueOf(userId);
30                credentials[1] = password;
31                credentials[2] = Boolean.FALSE.toString();
32            }
33            else {
34                throw new Exception("Invalid credentials provided for user id : " + userId);
35            }   
36            
37        } catch (Exception e) {
38            s_log.error(e.getMessage());
39        }
40       
41        return credentials;
42    }
43}
William Gosse
SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月13日 上午6:09
答复

William Gosse

等级: Regular Member

帖子: 108

加入日期: 2010年7月4日

最近的帖子

I finally figured out what was breaking my autologin in 6.1.1. In the com.liferay.portal.servlet.filters.autologin.AutoLoginFilter the following code had been added to the to the getLoginRemoteUser method:
 1
 2            else if (PropsValues.LIVE_USERS_ENABLED) {
 3                    UserTracker userTracker =
 4                        UserTrackerLocalServiceUtil.fetchUserTracker(userId);
 5
 6                    if ((userTracker == null) &&
 7                        (session.getAttribute(WebKeys.USER) == null)) {
 8
 9                        session.invalidate();
10
11                        return null;
12                    }
13                }


I do have live users enabled so this new code inconveniently invalidated my user session. Commenting out this code and redeploying this class as part of my extension allowed my autologin to now work. I'm not sure why live users enabled is now being check in this method but this will probably break any autologin if live users are enabled. This was the only thing that seem to be different between the 6.0 version and the 6.1 version of the getLoginRemoteUser method in the com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.

One other thing I noticed is that this code passes the userId to the UserTrackerLocalServiceUtil.fetchUserTracker method. This doesn't seem to be correct because the javadocs says that the argument should be the userTrackerId, which is not the same as the userId. I think that passing the userId will always cause the method to return null. This new code just doesn't make any sense to me.
Adrián Rodrigo
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月13日 上午2:48
答复

Adrián Rodrigo

等级: New Member

帖子: 16

加入日期: 2009年2月3日

最近的帖子

Thanks for posting the issue, we had the same problem and we couldn't explain what was going on... We have Liferay 6.1.20 GA2 EE.
For now, we solved the problem disabling live users feature in portal-ext.properties.

Liferay's team should test better the new features or the modifications in the code that could affect other features, in this case, autologin. Clients could now be upset because an EE is supposed to have a quality control and exhaustive tests that CE does not have at that level.

So, ¿could you add this issue to JIRA (http://issues.liferay.com) with the research you did about it for Liferay's team could release a fix for this issue?

Thanks for the research and the post again!

We'll wait for the fix.
William Gosse
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月13日 上午6:12
答复

William Gosse

等级: Regular Member

帖子: 108

加入日期: 2010年7月4日

最近的帖子

Thanks for your reply. It's nice to know that others are reading my posts and find them useful. I'll get the issue into jira.
William Gosse
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月13日 上午6:41
答复

William Gosse

等级: Regular Member

帖子: 108

加入日期: 2010年7月4日

最近的帖子

Here's the jira issue I created fro this problem: http://issues.liferay.com/browse/LPS-29871
Shinn Lok
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月13日 上午11:46
答复

Shinn Lok

LIFERAY STAFF

等级: Junior Member

帖子: 63

加入日期: 2011年1月14日

最近的帖子

The issue was already addressed in this ticket:

http://issues.liferay.com/browse/LPS-29218

Thanks!
William Gosse
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月17日 上午4:01
答复

William Gosse

等级: Regular Member

帖子: 108

加入日期: 2010年7月4日

最近的帖子

Actually people are already working on the ticket I submitted, so it would seem the the ticket you referred to didn't fully address the issue.
Shinn Lok
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2012年9月17日 上午11:05
答复

Shinn Lok

LIFERAY STAFF

等级: Junior Member

帖子: 63

加入日期: 2011年1月14日

最近的帖子

The recent activity on the ticket is only for housekeeping. No code changes are going to be done.
Gordon Augat
RE: SOLVED 6.05 AutoLogin not working in 6.1 GA2
2013年4月22日 下午1:26
答复

Gordon Augat

等级: Junior Member

帖子: 91

加入日期: 2006年8月16日

最近的帖子

Thanks! Just what I needed!