Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
William Gosse
6.05 AutoLogin not working in 6.1 GA2
September 7, 2012 2:07 PM
Answer

William Gosse

Rank: Regular Member

Posts: 108

Join Date: July 4, 2010

Recent Posts

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
September 13, 2012 6:09 AM
Answer

William Gosse

Rank: Regular Member

Posts: 108

Join Date: July 4, 2010

Recent Posts

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
September 13, 2012 2:48 AM
Answer

Adrián Rodrigo

Rank: New Member

Posts: 16

Join Date: February 3, 2009

Recent Posts

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
September 13, 2012 6:12 AM
Answer

William Gosse

Rank: Regular Member

Posts: 108

Join Date: July 4, 2010

Recent Posts

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
September 13, 2012 6:41 AM
Answer

William Gosse

Rank: Regular Member

Posts: 108

Join Date: July 4, 2010

Recent Posts

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
September 13, 2012 11:46 AM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 63

Join Date: January 14, 2011

Recent Posts

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
September 17, 2012 4:01 AM
Answer

William Gosse

Rank: Regular Member

Posts: 108

Join Date: July 4, 2010

Recent Posts

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
September 17, 2012 11:05 AM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 63

Join Date: January 14, 2011

Recent Posts

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
April 22, 2013 1:26 PM
Answer

Gordon Augat

Rank: Junior Member

Posts: 91

Join Date: August 16, 2006

Recent Posts

Thanks! Just what I needed!