In struts-config.xml
<controller processorClass="blah.blah.MyRequestProcessor"/>
My authentication filter used an atribute "authenticationRequired" in the
action mapping (note that this is not an elegant solution because it doesn't
follows the DTD specification)
<action-mappings
type="es.udc.is203.j2ee.eshop.http.controller.frontcontroller.EShopActionMap
ping">
<action path="/user/UpdateUserProfileDetails"
type="es.udc.is203.j2ee.eshop.http.controller.actions.user.UpdateUserProfile
DetailsAction"
name="userProfileForm"
scope="request"
input="/user/EditUserProfile.do"
validate="true"
authenticationRequired="true"/>
/**
* A filter to check if the action to be executed requires that the user had
* been authenticated. If the user has not been authenticated and the action
* requires it, <code>doProcess</code> returns the
<code>ActionForward</code>
* returned by <code>mapping.findForward("AuthenticationPage")</code>.
* <br>
* The uri of the action to be executed is stored in the request as
* <code>uri</code> and the parameters as <code>parameters</code> so them
can
* be retrieved later to continue the operation.
*
* <p>Title: IS e-Shop</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author <a href="mailto:[EMAIL PROTECTED]">Carlos Sanchez Gonzalez</a>
-
* <a href="mailto:[EMAIL PROTECTED]">Ines Silva Liste</a> -
* <a href="mailto:[EMAIL PROTECTED]">Jose Mora Garcia</a>
* @version 4.1
*/
public class AuthenticationPreProcessingFilter extends PreProcessingFilter {
public AuthenticationPreProcessingFilter(PreProcessingFilter nextFilter)
{
super(nextFilter);
}
protected ActionForward doProcess(HttpServletRequest request,
HttpServletResponse response,
Action action, ActionForm form,
ActionMapping mapping) throws
IOException,
ServletException,
InternalErrorException {
EShopActionMapping eShopActionMapping =
(EShopActionMapping) mapping;
if (eShopActionMapping.getAuthenticationRequired()) {
if (SessionManager.isUserAuthenticated(request)) {
return null;
} else {
String uri = request.getRequestURI();
uri = uri.substring(request.getContextPath().length());
request.setAttribute("uri", uri);
request.setAttribute("parameters",
request.getParameterMap().entrySet());
return mapping.findForward("AuthenticationPage");
}
} else {
return null;
}
}
}
> -----Mensaje original-----
> De: koen boutsen [mailto:[EMAIL PROTECTED]
> Enviado el: viernes, 10 de octubre de 2003 14:52
> Para: Struts Users Mailing List
> Asunto: RE: redirect problem
>
>
> So,I have to write my session control in the doProcess() method ?
>
> How do I have to configure my application so that every
> request goes through this filter ?
>
> --
>
> --------- Original Message ---------
>
> DATE: Fri, 10 Oct 2003 13:58:40
> From: Carlos Sanchez <[EMAIL PROTECTED]>
> To: "'Struts Users Mailing List'"
> <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
> Cc:
>
> >You can extend RequestProcessor using a intercepting filter
> pattern for
> >preprocessing
> >(http://java.sun.com/blueprints/patterns/InterceptingFilter.h
> tml), so
> >you don't have to check the session in every jsp.
> >
> >
> >
> >public class MyRequestProcessor extends RequestProcessor {
> >
> > PreProcessingFilter firstPreProcessingFilter;
> >
> > public MyRequestProcessor() {
> >
> > firstPreProcessingFilter =
> > new SessionPreProcessingFilter(
> > new AuthenticationPreProcessingFilter(null));
> >
> > }
> >
> > protected ActionForward processActionPerform(
> > HttpServletRequest request, HttpServletResponse response,
> > Action action, ActionForm form, ActionMapping
> mapping) throws
> > IOException, ServletException {
> >
> > ActionForward actionForward =
> firstPreProcessingFilter.process(
> > request, response, action, form, mapping);
> >
> > if (actionForward == null) {
> > return super.processActionPerform(request,
> response, action,
> > form, mapping);
> > } else {
> > return actionForward;
> > }
> >
> > }
> >
> >}
> >
> >
> >
> >/**
> > * A base clase for all preprocessing filters. Usually, concrete
> >filters only
> > * need to provide an implementation of <code>doProcess</code>. */
> >public abstract class PreProcessingFilter {
> >
> > private PreProcessingFilter nextFilter;
> >
> > public PreProcessingFilter(PreProcessingFilter nextFilter) {
> > this.nextFilter = nextFilter;
> > }
> >
> > /**
> > * Calls upon <code>doProcess</code>, and if necessary,
> continues
> >to call
> > * <code>process</code> on the next filter.
> > */
> > public ActionForward process(HttpServletRequest request,
> > HttpServletResponse
> response, Action
> >action,
> > ActionForm form,
> > ActionMapping mapping)
> throws IOException,
> > ServletException {
> >
> > ActionForward actionForward = null;
> >
> > /* Process this filter. */
> > actionForward = doProcess(request, response, action, form,
> > mapping);
> >
> > /* Process next filter in the chain. */
> > if ((actionForward == null) && (nextFilter != null)) {
> > return nextFilter.process(request, response,
> action, form,
> >mapping);
> > } else {
> > return actionForward;
> > }
> >
> > }
> >
> > /**
> > * Does the processing of this filter.
> > *
> > * @return <code>null</code> if the next filter must be
> processed; an
> > * <code>ActionForward</code> otherwise
> > */
> > protected abstract ActionForward
> doProcess(HttpServletRequest request,
> >
> HttpServletResponse response,
> > Action action,
> >ActionForm form,
> > ActionMapping
> mapping) throws
> > IOException, ServletException,
> > InternalErrorException;
> >}
> >
> >
> >
> >
> >
> >> -----Mensaje original-----
> >> De: koen boutsen [mailto:[EMAIL PROTECTED]
> >> Enviado el: viernes, 10 de octubre de 2003 13:32
> >> Para: Struts Users Mailing List
> >> Asunto: redirect problem
> >>
> >>
> >> Hi
> >> If my httpsession is invalid, I want to send the user to the
> >> logon page. I tried it in different ways, but get an error
> >> everytime I tried it like this : (sessionIsValid is a
> >> attribute in the session. If this attribute is null, it means
> >> that my session does no longer exist).
> >>
> >>
> >> <logic:notPresent name="sessionIsValid" scope="session">
> >> <logic:forward name="/sessionTimedOut"/> </logic:notPresent>
> >>
> >>
> >> This is the error I get :
> >> javax.servlet.jsp.JspException: Exception redirecting for
> >> name /sessionTimedOut: java.lang.IllegalStateException
> >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R
> >> at
> >> org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.
> >> java:164)
> >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R
> >> at org.apache.jsp._specialCode1._jspService(_specialCode1.java:164)
> >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R
> >> at
> >> com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJs
> >> pBase.java:89)
> >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R
> >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >> [10/10/03 13:08:25:043 CEST] 5355efea SystemErr R
> >> at
> >> com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapp
> >> er.service(JspServlet.java:344)
> >> [10/10/03 13:08:25:043 CEST] 5355efea SystemErr R
> >> at
> >> com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(
> >> JspServlet.java:598)
> >> [10/10/03 13:08:25:043 CEST] 5355efea SystemErr R
> >>
> >> Thanks for any help.
> >>
> >> Koen
> >>
> >>
> >> ____________________________________________________________
> >> Get advanced SPAM filtering on Webmail or POP Mail ... Get
> >> Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail:
> [EMAIL PROTECTED]
> >>
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
> ____________________________________________________________
> Get advanced SPAM filtering on Webmail or POP Mail ... Get
> Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]