Foren

getRemoteUser returns username (string) not userid (long)

Beppe Catanese, geändert vor 15 Jahren.

getRemoteUser returns username (string) not userid (long)

New Member Beiträge: 4 Beitrittsdatum: 04.09.08 Neueste Beiträge
Hi
we are using Liferay 5.1.0 on Oracle OC4J 10.1.3. We implement Oracle Single Sign-On with mod_sso protecting the URL (any /liferay is intercepted by SSO). We managed to write our own AutoLogin module which performs the login, we can now access the Liferay pages/sections but anytime we change content (add message, add category, etcc.) we hit com.liferay.portal.NoSuchUserException: No User exists with the primary key 0.

Digging into the code we found out that the method getUserId() in class com.liferay.portal.service.base.PrincipalBean
returns the userid as long. This is actually retrieved from PrincipalThreadLocal.
The issue we have is that who sets this information (MainServlet, ServletAuthorizingFilter, etc...) basically seems to store on the PrincipalThreadLocal the value returned by getRemoteUser()... which in our case is the SSO username (eg GCATANES), not
the Liferay userid (long)... causing getUserId() to return zero.

It looks like Liferay expects the Liferay userid (long) on the REMOTE_USER header... which is not always the case.. at least with Oracle SSO which sets as username the userid stored on the Oracle LDAP (string in our case)
Anyone can clarify this? Any idea/suggestion to address this problem?

Thanks in advance, any help is highly appreciated.

Beppe
Beppe Catanese, geändert vor 15 Jahren.

RE: getRemoteUser returns username (string) not userid (long

New Member Beiträge: 4 Beitrittsdatum: 04.09.08 Neueste Beiträge
Hi
eventually we have fixed the problem changing Liferay source (MainServlet class).
We we did was to NOT set the REMOTE_USER into PrincipalThreadLocal:


		request = new ProtectedServletRequest(request, remoteUser);

		if ((userId > 0) || (remoteUser != null)) {

			// Set the principal associated with this thread

			String name = String.valueOf(userId);

			if (remoteUser != null) {
				name = remoteUser;
			}

// Begin customisation
                        // set on PrincipalThreadLocal the long userId, not the 
                        // REMOTE_USER (string)

			//PrincipalThreadLocal.setName(name);
			PrincipalThreadLocal.setName(userId);
// End customisation
                        
		}
 


It is now working for us but ideally I wouldn't want to change the Liferay source code...

Beps
thumbnail
Younis Alomoush, geändert vor 14 Jahren.

RE: getRemoteUser returns username (string) not userid (long

Junior Member Beiträge: 40 Beitrittsdatum: 04.06.09 Neueste Beiträge
Dear Beppe,

Please if can help me in integrating Oracle SSO with Liferay. Please if can you send me a steps or codes.

Thanks in Advance

--
Younis