Liferay6.1.20 AutoLogin

When I tried to use autologin in Liferay6.1.20, I found something strange.

1. I create a hook to do autologin test.

In the portal.properties, I add the setting to my autologin filter: auto.login.hooks=com.rujuan.filter.MyAutoLogin

2. I create my class like this:

package com.rujuan.filter;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.User;
import com.liferay.portal.security.auth.AutoLogin;
import com.liferay.portal.security.auth.AutoLoginException;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyAutoLogin implements AutoLogin {
private static Log _log = LogFactoryUtil.getLog(MyAutoLogin.class);


@Override
public String[] login(HttpServletRequest req, HttpServletResponse response)
throws AutoLoginException {
System.out.println("*****************************");
String[] credentials = new String[3];
String userName = req.getParameter("userName");
long companyId = 0;


try {
companyId = PortalUtil.getCompany(req).getCompanyId();
User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, "test@liferay.com");
credentials[0] = String.valueOf(user.getUserId());
credentials[1] = userName;
credentials[2] = Boolean.FALSE.toString();
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
_log.error("why don't call?");
return credentials;
}
}

I don't know why the method isn't invoked. I also try to use portal-ext.properties in the first step. It also doesn't work.

************************************************************************************************************************************

Then I create a Ext plugins to do the same thing. It works.

1. Instead putting the setting in the portal.properties, this time we put it in portal-ext.properties.

2. In the WEB-INF/ext-impl/src folder, we create our own classes as before.

The login method is also called when we deploy the ext plugins. It's also called when I log out. It seems the method is called in different situations. Previously, when I did the same Ext plugins, it gives me an error when I deploy or restart server. This time it doesn't. All the things are strange.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值