cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with Alfresco 2.0 and Liferay 4.3.x

schoony99
Champ in-the-making
Champ in-the-making
I have previously created a similar post, but now have new information so I am re-posting.

My Setup:  We are currently running Liferay 4.2.1 + Alfresco 2.0 + CAS for Single Sign On + Fedora Directory Server. Everything works fine.

My Intention:  I need to upgrade Liferay to the new version, currently 4.3.4.  I am performing this upgrade in a test environment with a test LDAP server.

My Problem:  The upgrade to the new version of Liferay breaks the connection between Liferay and Alfresco as far as user accounts go. For instance, in the Liferay 4.2.1 database the "userid" field had a value like "smurray". My account in Alfresco also had the username "smurray", so when I logged into Liferay with the user "smurray" everything worked correctly in both Liferay and Alfresco.

After the upgrade, however, when I login with the username "smurray", Alfresco believes that I am user "187", so my Alfresco spaces, content, etc. is missing for user "187". If I query the Liferay database, I see that the "userid" field now has numerical values (example: 187), and that these values correspond to a "screenname" which contains the values I expected (example: smurray) in the userid field.  This is do to a change in Liferay's code in versions 4.3.x.

To Summarize: In Liferay 4.3.x, the values that were in the field "userid" have moved to the field "screenname". The field "userid" now contains automatically generated numerical values. Alfresco is still looking for it's credentials from the field "userid", but I need it to be looking at "screenname".  

What I believe the solution would be: I somehow need Alfresco to now grab the value of "screenname" instead of "userid".  Is this possible? And if so, is there anyone out there that can help me do it?

Thanks everyone for you help!
6 REPLIES 6

kevinr
Star Contributor
Star Contributor
I'm not sure how the CAS single-sign-on filter works, but I think the code will need to be changed to pickup the username from the new field in liferay. For our portlets we had to change to authenticator to get the username from the user.home-info.online.email field from the PortletRequest.USER_INFO object and strip off the @address part - pretty poor but we couldn't find another way to do it without using Liferay specific classes…

Thanks,

Kevin

schoony99
Champ in-the-making
Champ in-the-making
I'm not sure how the CAS single-sign-on filter works, but I think the code will need to be changed to pickup the username from the new field in liferay. For our portlets we had to change to authenticator to get the username from the user.home-info.online.email field from the PortletRequest.USER_INFO object and strip off the @address part - pretty poor but we couldn't find another way to do it without using Liferay specific classes…

Thanks,

Kevin

Thank you for the response Kevin.  I am not familiar much at all with the workings of CAS.  Would you happen to know of any documentation that would assist me in making such a change?

Is my situation very similar to the one you've mentioned of your portlets?  If so, could you instruct me at all on how you were able to make the change you have mentioned?

Thank you very much for you assistance!

kevinr
Star Contributor
Star Contributor
I am not familiar with CAS either so I cannot help you there.

We looked at this problem when writing the single-sign-on for the newer WebScript based portlets. One solution is to use the Liferay specific APIs by including the Liferay API Jar file and calling their classes directly to retrieve the user screen name. This is probably the preferred route if you are only going to use Liferay. I suggest looking at their forums/javadocs as i don't remember the exact details. We discarded that route as we support multiple portals including Liferay and JBoss so need a more generic solution that did not require additional 3rd party libraries.

Our solution was to add this section to the WEB-INF/portlet.xml file:

    <user-attribute>
        <name>user.home-info.online.email</name>
    </user-attribute>

And then look for that value (set by Liferay as part of the JSR-168 Portal spec contract) when processing the portlet request:

            // look for the user info map in the portlet request - populated by the portlet container
            Map userInfo = (Map)req.getAttribute(PortletRequest.USER_INFO);
            if (userInfo != null)
            {
                // look for the special Liferay email (username) key
                String liferayUsername = (String)userInfo.get("user.home-info.online.email");
                if (liferayUsername != null)
                {
                    // strip suffix from email address - we only need username part
                    if (liferayUsername.indexOf('@') != -1)
                    {
                        liferayUsername = liferayUsername.substring(0, liferayUsername.indexOf('@'));
                    }
                    // save in session for use by alfresco portlet authenticator
                    this.req.getPortletSession().setAttribute(ALFPORTLETUSERNAME, liferayUsername);
                }
            }
Basically we strip the first part of the email address of the user and use that later as the username for the Alfresco authentication. If that value is not found in the session, then we get the username as we did before via the call to getRemoteUser() on the PortletRequest. It's a bit cheesy yes but it means we have a solution for both Liferay and JBoss etc.

Thanks,

Kevin

schoony99
Champ in-the-making
Champ in-the-making
And then look for that value (set by Liferay as part of the JSR-168 Portal spec contract) when processing the portlet request:

            // look for the user info map in the portlet request - populated by the portlet container
            Map userInfo = (Map)req.getAttribute(PortletRequest.USER_INFO);
            if (userInfo != null)
            {
                // look for the special Liferay email (username) key
                String liferayUsername = (String)userInfo.get("user.home-info.online.email");
                if (liferayUsername != null)
                {
                    // strip suffix from email address - we only need username part
                    if (liferayUsername.indexOf('@') != -1)
                    {
                        liferayUsername = liferayUsername.substring(0, liferayUsername.indexOf('@'));
                    }
                    // save in session for use by alfresco portlet authenticator
                    this.req.getPortletSession().setAttribute(ALFPORTLETUSERNAME, liferayUsername);
                }
            }

Thank you for the additional info. Which file would I find that second set of code in?

Thanks!

rivetlogic
Champ on-the-rise
Champ on-the-rise
org.alfresco.web.scripts.portlet.WebScriptPortletRequest

It's in the web-client project under source/java.

Cheers,

-Aladdin

bdevore
Champ in-the-making
Champ in-the-making
What are the other properties that are available? For instance if I wanted to use the screen name instead of email address, what property could I use (if any)?

Thanks,
  -Ben