登录Liferay的用户没有密码 [英] Logging in Liferay user without password

查看:1088
本文介绍了登录Liferay的用户没有密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要进行身份验证的外部系统登录在Liferay的用户。但是,我仍然需要有一个有效的Liferay会话。所以,我需要通过

I need to login the user in Liferay by authenticating against an external system. However, I still need to have a valid Liferay session. So, I need to login to Liferay by


  1. 从用户询问用户名/密码

  2. 使用它们来对外部系统进行身份验证。

  3. 使用刚才的用户名(不是密码),以对Liferay的登录验证。

  4. 在登录用户,如果外部系统登录成功。

我做了几件事情:


  1. 自动登录

  2. 挂钩UserLocalService.authenticateByScreenName控

  3. auth.pipeline pre和检查= FALSE

  4. LoginFilter。

这些没有工作。这里是这些方法的说明。我们的想法是,以包括
//调用外部系统进行身份验证将包括,如果这些方法的工作。
请更正在那里我米做的错误,如果某些方法是好于其他。

These did not work. Here is an explanation of these approaches. The idea is to include //Call external system to authenticate will be included if these methods work. Please correct where I m making the mistake and if some approach is better compared to other.

1。自动登录:

一个。设置portal-ext.properties

a. Set portal-ext.properties

 auto.login.hooks=com.poc.AutoLoginFil

乙。创建一个类

public class AutoLoginFilter implements AutoLogin {

    public AutoLoginFilter() {
        super();
    }

    @Override
    public String[] login(HttpServletRequest req, HttpServletResponse arg1) throws AutoLoginException {

//Call external system to authenticate 
        User user =  UserLocalServiceUtil.getUserByScreenName(company.getCompanyId(), login);
         credentials[0] = String.valueOf(user.getUserId());

        credentials[1] = "undefined";
        credentials[2] = Boolean.TRUE.toString();

            return credentials;
    }
}

℃。部署插件项目,重新启动服务器并访问http://本地主机:8080 /网络/间/家。这应该登录为joebloggs

c. Deploy the plugin project, restart the server and go to http: //localhost:8080/web/guest/home . This should log in as joebloggs

这不工作

2。钩UserLocalService.authenticateByScreenName控

一个。在Liferay中-hook.xml

a. In liferay-hook.xml

<service>
        <service-type>
            com.liferay.portal.service.UserLocalService
        </service-type>
        <service-impl>
            com.test.UserService
        </service-impl>
    </service>

乙。扩展UserLocalServiceWrapper并使用自定义类。

b. Extend UserLocalServiceWrapper and use the custom class.

public class UserService  extends  UserLocalServiceWrapper
{

@Override
    public int authenticateByScreenName(long companyId, String screenName, String password, Map headerMap, Map parameterMap, Map resultsMap)
    {
//Call external system to authenticate 
        String name = "";
        log.info(screenName);
        return SUCCESS;
    }

}

当我登录时,应该用任何密码工作。它不是。

When I login, it should work with any password. It does not.

3。 auth.pipeline pre和检查= FALSE

一个。在portal-ext.properties

a. In portal-ext.properties

auth.pipeline.enable.liferay.check=false
auth.pipeline.pre=com.test.AutoLoginCustom

乙。然后,在

public class AutoLoginCustom implements AutoLogin
{

@Override
public String[] login(HttpServletRequest arg0, HttpServletResponse arg1)
            throws AutoLoginException {

@Override
    public String[] login(HttpServletRequest arg0, HttpServletResponse arg1)
{
//Call external system to authenticate 
  credentials[0] = "joebloggs";

        credentials[1] = "undefined";
        credentials[2] = Boolean.TRUE.toString();

            return credentials;
}

℃。部署该项目,并重新启动服务器。转到的http://本地主机:8080 /网络/间/家。登录使用用户名和不同的密码。它不登录。它甚至没有打在AutoLoginCustom的Java调试点。

c. Deploy the project and restart the server. Go to http://localhost:8080/web/guest/home. Login using username and different password. It does not login. It does not even hit the debug point in the AutoLoginCustom java.

4。 LoginFilter
在Liferay的-hook.xml,

4. LoginFilter In the liferay-hook.xml,

<servlet-filter>
        <servlet-filter-name>Login</servlet-filter-name>
        <servlet-filter-impl>com.test.AutoLoginFilter</servlet-filter-impl>
    </servlet-filter>

在AutoLoginFilter

In AutoLoginFilter

public class AutoLoginFil implements Filter
{

    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain arg2) throws IOException, ServletException {

//Call external system to authenticate 
        log.debug("doFilter");

    }
}

调试过滤器不叫。

The debug filter is not called.

有失误的这些方法,如果是,它是什么,是有不同的方法来做到这一点?
我已经看着下面引用。

Is there mistakes in any of these approaches and if yes, what is it and is there a different approach to do this? I had already looked at the following references.

我如何在Liferay中使用自动登录?

<一个href=\"http://stackoverflow.com/questions/10687562/liferay-autologin-authenticator-get-credentials-from-request-header\">Liferay - 自动登录+身份验证 - 获取证书从请求头

推荐答案

我也多一些玩耍,我能想出办法来解决这个问题。

I did some more playing around and i was able to figure out way to solve this.

有关结果答案
2.挂钩UserLocalService.authenticateByScreenName控

The answer for
2. Hooks to UserLocalService.authenticateByScreenName override

第1步:

<service>
        <service-type>
            com.liferay.portal.service.UserLocalService
        </service-type>
        <service-impl>
            com.test.UserService
        </service-impl>
    </service>

第二步:

扩展UserLocalServiceWrapper并使用自定义类。

Extend UserLocalServiceWrapper and use the custom class.

public class UserService  extends  UserLocalServiceWrapper
{

@Override
    public int authenticateByScreenName(long companyId, String screenName, String password, Map headerMap, Map parameterMap, Map resultsMap)
    {
//Call external system to authenticate 

        if(externalAuthenticationSuccess)
        {
          return Authenticator.SUCCESS;
       }
       else
       {
         return Authenticator.FAILURE; 
       } 

}

这工作,部署了的时候。

This works, when deployed.

这是不工作的时候我张贴的问题,因为:

This was not working when I posted the question because:


  1. 我的服务器有Tomcat的。我做这个改变之前部署该项目。

  2. 一旦我做了更新,我用Liferay的插件,并使用右键单击项目部署 - > Liferay->部署。

  3. 我是用在code中的断点,看它是否会在登录时抓住它。

  4. 这是不是因为Eclipse IDE中我使用需要通过重新部署在服务器部署的项目,而不是Liferay的插件命令捕获。

当我部署使用Eclipse Tomcat服务器以及,它抓住了断点。

When I deployed using the Eclipse Tomcat Server as well, it caught the breakpoint.

答案

auth.pipeline pre和检查= FALSE

  1. auth.pipeline pre and check = false

在portal-ext.properties

In portal-ext.properties

auth.pipeline.enable.liferay.check = FALSE
auth.pipeline。pre = com.test.CustomAuthenticator

auth.pipeline.enable.liferay.check=false auth.pipeline.pre=com.test.CustomAuthenticator

public class CustomAuthenticator implements Authenticator
{
    @Override
    public int authenticateByScreenName(long companyId, String screenName, String password,
            Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {



    //Call external system to authenticate 
    if(externalAuthenticationSuccess)
    {
        return Authenticator.SUCCESS;
    }
    else
    {
        return Authenticator.FAILURE; 
    } 


    }
}


这也正常运行,但它只是在JBoss中,而不是在Tomcat的工作。我部署了portal-ext.properties在

This works too, but it worked only in JBoss, not in Tomcat. I deployed the portal-ext.properties in

TOMCAT_HOME \\的webapps \\ ROOT \\ WEB-INF \\班

TOMCAT_HOME\webapps\ROOT\WEB-INF\classes

在JBoss的EAP,这是LIFERAY_HOME下。它可能没有拿起Tomcat中的财产,但在JBoss中一样。

In JBoss EAP, it is under Liferay_Home. It might not have picked up the property in Tomcat, but did in JBoss.

张贴在问题的另一个可能的解决方法可能会奏效过,但我没有的一切探索找到的配置错误。

The other possible solutions posted in the question might work too, but I did not explore everything to find the mistakes in the configuration.

如果有关于这些解决方案的任何意见或问题,请后,我会很乐意提供进一步的步骤。谢谢。

If there is any comment or question about these solutions, please post and I ll be happy to provide further step. Thank you.

这篇关于登录Liferay的用户没有密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆