liferay的com.liferay.portal.security.auth.Authenticator接口包含不同类型的身份验证的不同原型。为了理解各种身份验证的问题,我实现了一个包含这个类的测试钩子:
public class Test-hook implements Authenticator {
@Override
public int authenticateByEmailAddress(long arg0, String arg1, String arg2,Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {
System.out.println("successfull by email address authenticate ");
return SUCCESS;
}
@Override
public int authenticateByScreenName(long arg0, String arg1, String arg2,
Map<String, String[]> arg3, Map<String, String[]> arg4)
throws AuthException {
// TODO Auto-generated method stub
System.out.println("successfull by screen name authenticate");
}
@Override
public int authenticateByUserId(long arg0, long arg1, String arg2,
Map<String, String[]> arg3, Map<String, String[]> arg4)
throws AuthException {
// TODO Auto-generated method stub
System.out.println("successfull by user id authenticate");
return SUCCESS;
}
}
因此,如果我通过portlet登录正确登录,则会自动调用“authenticateByEmailAddress”函数,并在控制台中显示“通过电子邮件地址验证成功”。
我的问题是什么时候调用函数authenticateByScreenName和authenticateByUserId?这意味着我们如何通过Liferay中的屏幕名称和userId进行身份验证?
答案 0 :(得分:3)
我不确定这可能是解决方案还是它们是相关的。但是,
将company.security.auth.type
设置为portlet-ext.properties
中的屏幕名称可能会解决问题,
#
# The portal can authenticate users based on their email address, screen
# name, or user id.
#
#company.security.auth.type=emailAddress
company.security.auth.type=screenName
company.security.auth.type=userId