Search code examples
authenticationliferaypipelineauthenticator

how to override liferay authentication


I am desperately trying to reproduce the example here for my liferay tomcat bundle : http://liferay-blogging.blogspot.be/2011/08/how-to-change-liferay-login-module.html

I have recreated the author's package and class :

package de.test.auth;

import java.util.Map;
import com.liferay.portal.security.auth.AuthException;
import com.liferay.portal.security.auth.Authenticator;

public class RefuseAuthenticator implements Authenticator {

public int authenticateByEmailAddress(long arg0, String arg1, String arg2, Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {

    System.out.println("failed by mail");
    return FAILURE;
}

public int authenticateByScreenName(long arg0, String arg1, String arg2, Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {

    System.out.println("failed by screen name");
    return FAILURE;
}

public int authenticateByUserId(long arg0, long arg1, String arg2, Map<String, String[]> arg3, Map<String, String[]> arg4) throws AuthException {

    System.out.println("failed by user id");
    return FAILURE;
}

}

I exported the package as a jar file that I placed in LR-portal/TOMCAT/lib/ext folder

I added the 2 lines :

auth.pipeline.enable.liferay.check=false
auth.pipeline.pre=de.test.auth.RefuseAuthenticator

in standard portal.properties file located in LR-portal/TOMCAT/webapps/ROOT/WEB-INF/lib/portlet_impl.jar. I know it's supposed to be in a portal-ext.properties file but it didn't worked anyway so I eliminated all possible side effects.

Unfortunately Liferay keeps on logging my users normally. I read about hooks and ext methods of doing custom code in Liferay so I might be missing something. I read many forum posts before writing here.

I am using liferay-ce-portal-7.0-ga3 tomcat bundle.

Thanks.


Solution

  • thanks for your thoughts. I finally got around this using a hook. I based my self on Shibboleth authentication plugin for Liferay (see github). It is originally built in maven but I managed to convert it into ant to be able to use Liferay Plugin SDK environment.