Combination View Flat View Tree View
Threads [ Previous | Next ]
Sebastián Gurin
programatically portlet login
November 9, 2007 7:46 AM

Sebastián Gurin

Rank: Junior Member

Posts: 75

Join Date: June 13, 2007

Recent Posts

Hi all (first of all excuse my very basic english)

Well, I'm trying tntegrate existing desktop and internet applications to liferay. In particular i'm interested in dialogate with portlets like the document library from applications writte in variuos language like (javascript, C/C++, visual basic, html pages, java, etc).

Since I had a lot of problems with soap dialog, I choose the next sollution: create a servlet in the portal side asociated with a url iside the portal and define the dialog passing the data in the form of http parameters. For example a basic use case could be: the client should pass the userId, passwird, companyId document title and document data in the httprequest and the servlet has to login the user and invoke the DL service util function for adding the document.

This is working pretty well, except for the login part. For login in the portal, from my servlet I'm doing:

request.getSession().setAttribute(WebKeys.COMPANY_ID, companyId);
request.getSession().setAttribute(WebKeys.USER_ID, userId);
request.getSession().setAttribute(WebKeys.USER_PASSWORD, psswd);
LoginAction.login(request, response, userId, psswd, false); //that calls UserServiceUtil.authenticateByUserId(...)

Loggin in this way seems to work in the portal but not inside individual portlets. For example, the lines

System.out.println("remote user: "+req.getRemoteUser());
System.out.println("user principal: "+req.getUserPrincipal());

the lines inside an struts action portlet file prints


where in the normal usage (normal login) they print:


So my question is how do I set the user principal in the http session?

Hope you can understand my problem. thanks in advance