I have a simple servlet that captures the login credentials and places them in the Web
apps HttpSession then forwards the request to "j_security_check".
| protected void doPost(HttpServletRequest req, HttpServletResponse resp)
| throws ServletException, IOException {
| String username = req.getParameter("username");
| String password = req.getParameter("password");
| if (username != null && password != null) {
| req.getSession().setAttribute("api.username", username);
| req.getSession().setAttribute("api.password", password);
| String url = "j_security_check?j_username=" + username +
"&j_password=" + password;
| String redirectUrl = resp.encodeRedirectURL(url);
| resp.sendRedirect(redirectUrl);
| }
|
| }
|
This piece is working fine but the problem is I cannot find a way to access the
HttpSession attributes from a portlet. I've tried the following api call to pull
these attributes out of the session but I'm only getting nulls .
| public void createContext(RenderRequest request, RenderResponse response,
PortletContext pContext) throws Exception{
| PortalRuntimeContext context = Navigation.getPortalRuntimeContext();
| PortalSession ps = context.getSession();
| username = (String)ps.getAttribute(USERNAME_ATTR);
| password = (String)ps.getAttribute(PASSWORD_ATTR);
| }
|
From what I understand from reading the Portal Wiki is that there are
three httpsessions: The portlet session, the portal session and the web app session. My
servlet is defined in the portal-server.war/WEB-INF/web.xml:
| <!-- Save the login -->
| <servlet>
| <servlet-name>SaveLogin</servlet-name>
| <servlet-class>....SaveLoginServlet</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>SaveLogin</servlet-name>
| <url-pattern>/auth/portal/default/saveLogin</url-pattern>
| </servlet-mapping>
|
I would have thought this meant my PortalSession object would be wrapping the HttpSession
my servlet is populating the attributes in but this does not seem to be the case.
I've spent hours looking into the API and Wiki for a way to hook into the original
HttpSession via a portlet but I keep hitting a wall. Should be a simple task but the
solution has thusfar eluded me.
<grovel>PLEASE HELP</grovel>
I am using the jboss-portal-2.6.3.GA all-in-one binary distribution.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122211#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...