idea for struts actions
Dan Allen <[email protected]> Fri, 21 Mar 2003 12:21:51 -0600
| Newsgroups | gmane.comp.java.securityfilter.user |
|---|---|
| Message-ID | <[email protected]> |
Many users have asked if there is a way to get security filter to
put more information in the session when a user logs in. Also, you
might want to have custom messages and redirects for your
application. There is an easy way to accomplish all of this. You
simply have securityfilter forward to a struts action (or multiple
struts actions) to get the job done. Here are a few snippets from
struts-config.xml
<action-mappings>
<!-- this is just a placeholder, it should never get hit, it is only
to create the dynaformbean -->
<action path="/j_security_check" name="loginForm" validate="false" forward="/do/Login"/>
<!-- this will run just after the j_security_check finishes with the request -->
<action path="/Login" type="net.creativerge.struts.action.LoginAction">
<forward name="failure" path="/loginError.jsp"/>
<forward name="success" path="/index.jsp"/>
</action>
</action-mappings>
In my security filter config file I just set the login
success/failure pages to /do/Login
Then in my LoginAction class I just do the following
if (request.getRemoteUser() == null)
{
// Login must have failed, put together some ActionErrors and go
// whereever
mapping.findForward("failure");
}
else
{
// we are logged in! Go get information from the user and place
// it in the session
mapping.findForward("success");
}
Now you can use the struts tags to make the login form and you can
execute an action.
The only thing I request is that we can adjust the pattern matched
for the login procedure so that any struts action extension can be
supported (ie *.do).
Dan
--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Daniel Allen, <[email protected]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"If you are going to play the game of trial and error,
don't be suprised when the results are revealing. -- me"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en