I've found a workaround to get the username & password back from the Form based
authentication. I'm working with a Filter which intercepts the post and stores the
values in the session scope.
| package com.artomilito.www.colossus;
|
| import java.io.IOException;
|
| import javax.servlet.Filter;
| import javax.servlet.FilterChain;
| import javax.servlet.FilterConfig;
| import javax.servlet.ServletException;
| import javax.servlet.ServletRequest;
| import javax.servlet.ServletResponse;
| import javax.servlet.http.HttpServletRequest;
| import javax.servlet.http.HttpServletResponse;
| import javax.servlet.http.HttpSession;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
|
| /**
| * Login Filter 14-oct-2004, Wessel de Roode
| * From an idea of dmitry_ame at yahoo.com.
| * Written for Struts & Xdoclet & changed for
| * EJB Authentication by Wessel.
| * Purpose to intecept the username & password from a
| * FORM based authentication. The username & password
| * can now used for authenticating with EJB's
| * This filter should point to an unprotected directory
| * with an empty jsp file in it. Example /login/dummy.jsp
| *
| * The loginform should look like this in struts:
| * <FORM name="loginform" action="login/dummy.jsp" method="post">
| * <input type="text" name="j_username"/>
| * <input type="password" name="j_password"/>
| *
| * After login the loginAction or any first action that is addressed can retrieve
the
| * values with:
| * HttpSession session = request.getSession();
| * String user = session.getAttribute("j_username"));
| * String pass = session.getAttribute("j_password"));
| * Without the Filter these values will be null
| * @author Wessel de Roode
| *
| * @web.filter
| * name = "LoginFilter"
| *
| * @web.filter-mapping
| * url-pattern = "/login/*"
| */
| public class LoginFilter implements Filter {
|
| static Log log = LogFactory.getLog(LoginFilter.class);
| public void init(FilterConfig arg0) throws ServletException {}
|
| public void doFilter(ServletRequest request,
| ServletResponse response, FilterChain chain)
| throws IOException, ServletException {
| HttpServletResponse httpResponse = (HttpServletResponse)response;
| HttpServletRequest httpRequest = (HttpServletRequest) request;
| String redirectString = "j_security_check";
| log.info( "Sending redirect to: " + redirectString);
|
| String username = httpRequest.getParameter("j_username");
| String password = httpRequest.getParameter("j_password");
|
| HttpSession session = httpRequest.getSession();
| // Set the attributes in the session space
| session.setAttribute("j_username", username );
| session.setAttribute("j_password", password );
|
| httpResponse.sendRedirect( redirectString
+"?j_username="+username+"&j_password="+password );
|
| chain.doFilter(httpRequest, httpResponse);
| }
|
| public void destroy() {}
| }
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3851439#3851439
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3851439
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user