0
votes

I am implementing Liferay 6.2 AuthVerifier. I developed it but it does not get called that is, TestAuthVerifier.verify() method.

I referred https://docs.liferay.com/portal/6.2/propertiesdoc/portal.properties.html the link to develop tthe est AuthVerifer. Here is what I do below

I make entries in portal-ext.properties file as below and develop the class further.

auth.verifier.pipeline=com.test.TestAuthVerifier
auth.verifier.TestAuthVerifier.version.supported=1.0

my code is as below just for reference.

package comt.test;

import com.liferay.portal.security.auth.*;

public class TestAuthVerifier implements AuthVerifier {

@Override
public String getAuthType() {
    return PhAuthVerifier.class.getSimpleName();
}

@Override
public AuthVerifierResult verify(
        AccessControlContext accessControlContext, Properties properties)
        throws AuthException {

    System.out.println("MyAuthVerifier.verify() invoked..")
    try {

    .....

        return authVerifierResult;
    } catch (AutoLoginException e) {
        throw new AuthException(e);
    }

}

On debugging from Liferay 6.2.3 source code I see the point when

  1. the flow is broken is AuthVerifierPipeline._mergeAuthVerifierConfiguration() method. the statement : Map settings = accessControlContext.getSettings(); returns zero size map.

  2. Finally the actual place where the Verifier is called : AuthVerifierPipeline._verifyRequest() does not run as List authVerifierConfigurations is ZERO size.

  3. I looked in AccessControlContext class and other classes, I could not see any setter method to set _settings or any references which set this var.

any help around this is much appreciated.

note : I verified that LifeRay does recognize my TestAuthVerifier impl.

1
i think you have to put the properties overriding the portal.properties in a hook and put the class in the same projectRomeo Sheshi
can you please explain in little more details and put in answer sectionspectre007

1 Answers

0
votes

to make it work you have to work with the hook plugin. First create a file liferay-hook.xml in WEB-INF folder to override the portal.properties

<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">

<hook>
    <portal-properties>portal.properties</portal-properties>
</hook>

In the src folder put the file portal.properties or if you are using maven in the resource folder with the properties of the AuthVerifier in your case

auth.verifier.pipeline=com.test.TestAuthVerifier
auth.verifier.TestAuthVerifier.version.supported=1.0

This is a link of a sample in liferay git for more detail sample-authverifier-hook