Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
William Gosse
6.05 AutoLogin not working in 6.1 GA2
7 de Setembro de 2012 14:07
Resposta

William Gosse

Ranking: Regular Member

Mensagens: 202

Data de entrada: 4 de Julho de 2010

Mensagens recentes

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
13 de Setembro de 2012 06:09
Resposta

William Gosse

Ranking: Regular Member

Mensagens: 202

Data de entrada: 4 de Julho de 2010

Mensagens recentes

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
13 de Setembro de 2012 02:48
Resposta

Adrián Rodrigo

Ranking: New Member

Mensagens: 16

Data de entrada: 3 de Fevereiro de 2009

Mensagens recentes

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
13 de Setembro de 2012 06:12
Resposta

William Gosse

Ranking: Regular Member

Mensagens: 202

Data de entrada: 4 de Julho de 2010

Mensagens recentes

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
13 de Setembro de 2012 06:41
Resposta

William Gosse

Ranking: Regular Member

Mensagens: 202

Data de entrada: 4 de Julho de 2010

Mensagens recentes

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
13 de Setembro de 2012 11:46
Resposta

Shinn Lok

LIFERAY STAFF

Ranking: Junior Member

Mensagens: 76

Data de entrada: 14 de Janeiro de 2011

Mensagens recentes

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
17 de Setembro de 2012 04:01
Resposta

William Gosse

Ranking: Regular Member

Mensagens: 202

Data de entrada: 4 de Julho de 2010

Mensagens recentes

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
17 de Setembro de 2012 11:05
Resposta

Shinn Lok

LIFERAY STAFF

Ranking: Junior Member

Mensagens: 76

Data de entrada: 14 de Janeiro de 2011

Mensagens recentes

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
22 de Abril de 2013 13:26
Resposta

Gordon Augat

Ranking: Junior Member

Mensagens: 98

Data de entrada: 16 de Agosto de 2006

Mensagens recentes

Thanks! Just what I needed!