Dear Eric,

>From what I learned of interfaces, I would not need to redefine my
checkLogin method in each Action subclass.  By saying "public class
NewAction extends Action implements LoginCheck", I am able to use the
LoginCheck's "checkLogin(request)" method as if it were something I'd
defined in my class.  I only need to import the class to reference it as
"implements LoginCheck" and call it as "checkLogin(request)".  The only
catch (big one) is that ANY changes to the Interface class would require me
to recompile ANY classes implementing it or they will instantly break,
according to Sun documentation at:
http://java.sun.com/docs/books/tutorial/java/interpack/interfaces.html (see
title: Warning! Interfaces Cannot Grow!).  Another reason I thought of using
Interfaces was to allow me to use that function by "implementing" it within
other action sub-classes such as DispatchAction, LookupDispatchAction, etc.
rather than making an additional subclass to build off of each of those
types.

Per my posting earlier today, I figured out how to redefine the Struts 1.1
RequestProcessor class so I can use the action's built-in field 'scope' to
my own design.  That way, I can have my security information available in
the struts-config.xml (or module) file(s).

Regards,
David

-----Original Message-----
From: Jung, Eric (Contractor) [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 20, 2003 1:54 PM
To: Struts Users Mailing List
Subject: RE: login request


David,
If you implement it with an interface like you wrote:
  import com.mycompany.auth.LoginCheck;
  public class MyAction extends Action implements LoginCheck
  checkLogin(request) <--- 1st line from within the execute
won't you have to write the checkLogin() method in each and every Action in
your application?

-eric




-----Original Message-----
From: David G. Friedman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 20, 2003 9:42 AM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: login request


Dear Andy,

I'm doing the same thing you suggest.  My approach is
to extend the base Action (or any type of Action) class
by adding a functon 'checkLogin'.  It takes the 'request'
as the argument, checks the session for a User bean, and
throws an exception if the bean is missing or if the ID
number on the bean is zero/unset.  In my execute() method
I make my first line 'checkLogin(request)' and it handles
my authentication.

If you try this approach, keep in mind I'm using Struts
v1.1 final so I can use exceptions.

Tonight I'm going to try switching it to an interface so
I can use it to extend any action type by using 3 lines
(and without sub-classing):

1. import com.mycompany.auth.LoginCheck;
2. public class MyAction extends Action implements LoginCheck
3. checkLogin(request) <--- 1st line from within the execute
or DispatchAction, or LookupDispatchAction method, etc.

Regards,
David

-------Original Message-------
From: Andy Richards <[EMAIL PROTECTED]>
Sent: 08/20/03 09:46 AM
To: [EMAIL PROTECTED]
Subject: login request

>
> Hi, i have created a form and a action which checks to see if a user
exists
in
my database and if so a value object is placed into the session. What i am


unsure of is how to a action called everytime a request is made? Can i
configure struts-config.xml to send all requests via an action to see if
this
session object exists, and if not redirect the user to the login page?

many thanks

Andy
--


---------------------------------------------------------------------
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]


---------------------------------------------------------------------
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]

Reply via email to