Re: setUserPrincipal or something like that if u have a selfregistration button.
Marius Oancea <[email protected]> Thu, 21 Aug 2003 10:36:15 +0300
| Newsgroups | gmane.comp.jakarta.struts.user,gmane.comp.java.securityfilter.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Should not be a big task to put the
SecurityRequestWrapper request on the request as a attribute into securityfilter code.
Max Cooper wrote:
>Marius,
>
>I know this is something that would be very useful to have, but I haven't
>given it too much thought about how to implement it yet.
>
>I do have a few tips:
>
>1) Don't cast the current request to SecurityRequestWrapper.
>
>// don't do this
>SecurityRequestWrapper srw = (SecurityRequestWrapper) request;
>
>This won't work if the app server decides to wrap the request (JRun does
>this, and I assume other containers might do it, too). It will also break if
>you add another filter to the system that wraps the request. Casting like
>this is a bad idea, and it makes your code fragile.
>
>However, it would be nice to offer the request processors (other filters,
>servlets, etc.) access to an "extended" request API, that perhaps includes a
>method to programmatically log the current user in. I have thought about
>this a bit, and my current thinking is that a reference to the
>SecurityRequestWrapper should be placed in the request scope so that any
>code "down the pipeline" can access it, even if the request gets wrapped
>again. Here's an example of how that might work:
>
>// NOTE: This code will NOT work with the current release of SecurityFilter!
>// It is intended only as an example of how it might work in the future.
>
>// get a reference to the SecurityRequestWrapper
>SecurityRequestWrapper srw = (SecurityRequestWrapper)
> request.getAttribute(SecurityRequestWrapper.REQUEST_KEY);
>// log the current user in
>srw.login("username", "password");
>
>2) If you do decide to call setUserPrincipal() directly, you will want to
>set the Principal by getting it from the current SecurityRealm, just like
>SecurityFilter does.
>
>
>I hope we have a solution for this problem in the future. I welcome your
>feedback.
>
>-Max
>
>----- Original Message -----
>From: "Marius Oancea" <[email protected]>
>To: "Marius Oancea" <[email protected]>
>Sent: Tuesday, August 19, 2003 11:13 PM
>Subject: setUserPrincipal or something like that if u have a
>selfregistration button.
>
>
>
>
>>Hi,
>>I have a webapp made with struts and securityfilter using BasicAuth.
>>
>>All worked like a charm but:
>>How can i log in (or authenticate) the user after createUser process
>>is complete?
>>In other words:
>>- I have a button (free registration). The user will enter his data
>>and after that I want to automatically login that user. Is that
>>possible? I looked for a setUserPrincipal but i'm not able to access
>>that form an action.
>>
>>Thanx
>>
>>Marius Oancea
>>
>>--
>>"Why program by hand in five days what you can spend five years of your
>>life automating." - Terence Parr
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe-sSm70nXyYxXWgOoZo4XcuR2eb7JE58TQ@public.gmane.org
>>For additional commands, e-mail: struts-user-help-sSm70nXyYxXWgOoZo4XcuR2eb7JE58TQ@public.gmane.org
>>
>>
>>
>>
>
>
>
--
"Why program by hand in five days what you can spend five years of your life automating." - Terence Parr