The first time I did that, I did it the same way you did. However, what I do
now is use a base class for all my actions that does the authentication
check before calling my perform/execute-equivalent method to do the real
work. It looks something like this:

public abstract class AuthenticatedAction extends Action {
    public ActionForward execute(...) {
        if (!authenticated(...)) {
            return mapping.findForward("authError");
        }
        return executeAuthenticated(...);
    }
    protected abstract ActionForward executeAuthenticated(...);
    protected boolean authenticated(...) {
        // Do whatever kind of auth check you need here
    }
}

I've left out the details of parameters, exceptions, etc., but hopefully you
get the idea. Now my worker actions extend AuthenticatedAction and implement
executeAuthenticated().

Changing over from the old code to the new was very simple, because it
involved only changing the base class of my worker actions and the name of
the method they implement. Also, if you ever need actions that don't care
about authentication, you can simply have them extend Action instead of
AuthenticatedAction. (That's much harder to do using the scheme you are
using, and I was using before.)

--
Martin Cooper


> -----Original Message-----
> From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 10, 2002 2:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Migration from 1.0.2 to 1.1
> 
> 
> Subject: Re: Migration from 1.0.2 to 1.1
> From: "Heritier Arnaud" <[EMAIL PROTECTED]>
>  ===
> Thx for your help Martin.
> 
> In struts 1.0.2 I subclassed the ActionServlet to define a 
> processPreprocess
> method which verify the user authentification.
> I needed to use the processPath to determine if the user don't do the
> authentification action (it's normal that he is not yet 
> authenticated) and
> the processActionForward to transfert the user to the login 
> page if he is
> not connected.
> 
> Any idea ??
> 
> 
> 
> "Martin Cooper" <[EMAIL PROTECTED]> a écrit dans 
> le message de
> news: [EMAIL PROTECTED]
> > Depending on why you were subclassing ActionServlet in 
> Struts 1.0.2, you
> may
> > find that you don't need to do so in Struts 1.1. Or, you 
> can subclass
> > RequestProcessor instead, or use a PlugIn to do what you need.
> >
> > If you can tell us more about why you needed to subclass in 
> 1.0.2, we
> should
> > be able to help you find the right solution for Struts 1.1.
> >
> > --
> > Martin Cooper
> >
> >
> > > -----Original Message-----
> > > From: Arnaud HERITIER [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, July 10, 2002 5:27 AM
> > > To: Struts Users Mailing List (E-mail)
> > > Subject: Migration from 1.0.2 to 1.1
> > >
> > >
> > > In my WebApp using struts 1.0.2 I subclassed the ActionServlet.
> > > In this servlet I used the methods processPath() and
> > > processActionForward()
> > > from the ActionServlet 1.0.2.
> > > How can I do with the 1.1 because when I retreive the
> > > RequestProcessor,
> > > these methods are protected :-(
> > >
> > > Bugzilla ????
> > >   Arnaud HERITIER
> > >   EAI Consulting
> > >   Sopra Group
> > >   Tél. : +33 (0)1 53 33 44 74
> > >   email : [EMAIL PROTECTED]
> > >
> > >   Ce message est exclusivement destiné aux personnes dont le
> > > nom figure
> > > ci-dessus. Il peut contenir des informations 
> confidentielles dont la
> > > divulgation est à ce titre rigoureusement interdite. Dans
> > > l'hypothèse où
> > > vous avez reçu ce message par erreur, merci de le 
> renvoyer à l'adresse
> > > e-mail ci-dessus et de détruire toute copie.
> > >
> > >   This message may contain confidential and proprietary
> > > material for the
> > > sole use of the intended recipient. Any review or
> > > distribution by others is
> > > strictly prohibited. If you are not the intended recipient,
> > > please contact
> > > the sender and delete all copies.
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to