How to force Liferay 7.2.1Ga2 to use my Custom Implementation

Axel LEFEVRE, modified 5 Years ago. Junior Member Posts: 25 Join Date: 2/18/20 Recent Posts
Hello,

I'm want to override OpenIdConnectUserInfoProcessorImpl. So I created my custom implementation like this (for testing) :

    @Component(immediate = true,
        property = {
            "service.ranking:Integer=100"
        },
        service = OpenIdConnectUserInfoProcessor.class)
public class CustomOpenIdConnectUserInfoProcessorImpl
        implements OpenIdConnectUserInfoProcessor {

    private static Log log = LogFactoryUtil.getLog(CustomOpenIdConnectUserInfoProcessorImpl.class);

    public CustomOpenIdConnectUserInfoProcessorImpl() {
        log.info("My custom is constructed ");
    }

    @Override
    public long processUserInfo(UserInfo userInfo, long companyId)
            throws PortalException {
        log.info("User connected : " + userInfo.getPreferredUsername());
        String emailAddress = userInfo.getEmailAddress();
        String preferredUsername = userInfo.getPreferredUsername();
        return 0L;
    }


And I added a .config file in osgi/configs named "com.liferay.portal.security.sso.openid.connect.internal.OpenIdConnectServiceHandlerImpl.config" and containing this :

    _openIdConnectUserInfoProcessor.target="(component.name=com.mycustom.sso.CustomOpenIdConnectUserInfoProcessorImpl)"


But when I restart Liferay, this error appears :
[main][OpenIdConnectServiceHandlerImpl:93] bundle com.liferay.portal.security.sso.openid.connect.impl:4.0.17 (1812)[com.liferay.portal.security.sso.openid.connect.internal.OpenIdConnectServiceHandlerImpl(3376)] : The _openIdConnectUserInfoProcessor field has thrown an exception


And It seems that Liferay doesn't use my custom class

Can someone help me to understand what I'm doing wrong ?
thumbnail
Dominik Marks, modified 5 Years ago. Regular Member Posts: 149 Join Date: 8/29/12 Recent Posts
I did a custom implementation of a OpenIdConnectUserInfoProcessor for Liferay 7.1.3 GA 4 once. There I found that the package of OpenIdConnectUserInfoProcessor (com.liferay.portal.security.sso.openid.connect.internal) was not exported by the MANIFEST.MF, so without any further customization I was not able to use that package.

Maybe the same or a similar issue is the reason for your problem?

Here is a link to a blog post which contains the above issue as a part of the post, including a link to the source code I used. Maybe it helps.

​​​​​​​https://liferay.dev/blogs/-/blogs/integrating-verimi-with-liferay
Axel LEFEVRE, modified 5 Years ago. Junior Member Posts: 25 Join Date: 2/18/20 Recent Posts
Hi Dominik,

Thanks a lot, it works like a charm !!

Did you by anychance also change the Liferay flow for the connexion ?
I need to have only a "Sign In" button that will go to my keycloak login page.

My question is similar to the one in the Thread : https://liferay.dev/forums/-/message_boards/message/110950730
thumbnail
Dominik Marks, modified 5 Years ago. Regular Member Posts: 149 Join Date: 8/29/12 Recent Posts
You can at least skip the first step you mention in the thread above.

Just copy the query paramters from the URL when you click on the "OpenID Connect" button in your login page. Paste the query parameters (without the leading question mark) into the "query parameters" field in the page configuration.