Thanks Matt,
 
I have committed the changes to CVS.
 
Cheers,
Mark
 
On 9/18/05, Matt DeHoust <[EMAIL PROTECTED]> wrote:
I have been using Acegi Security for a few months now with much
success. I am very pleased with the framework. Great job and thanks!

Last week I tried the SwitchUserProcessingFilter for the first time
and have everything working with one exception. In order to facilitate
migration of my legacy application I wrote an adapter UserDetails that
wraps the legacy User class. There are some areas in the code that
still rely on the legacy User object. The current implementation of
SwitchUserProcessingFilter  will not allow a custom UserDetails. The
new Authentication's Principal will always be a String (username).

It appears that a simple change would do the trick. I believe it is
consistent with the framework to use a UserDetails by default unless
the configuration specifically indicates String-only principals (for
example DaoAuthenticationProvider.setForcePrincipalAsString).

I've included a patch below. It sets the new Authentication's
Principal to the UserDetails returned by the configured
AuthenticationDao instead of to the username. This allows applications
to continue to leverage custom UserDetails implementations when using
the switch user functionality.

Thanks,
Matt DeHoust


Index: SwitchUserProcessingFilter.java
===================================================================
RCS file: /cvsroot/acegisecurity/acegisecurity/core/src/main/java/net/sf/acegisecurity/ui/switchuser/SwitchUserProcessingFilter.java,v
retrieving revision 1.4
diff -u -r1.4 SwitchUserProcessingFilter.java
--- SwitchUserProcessingFilter.java    3 Sep 2005 21:43:08 -0000    1.4
+++ SwitchUserProcessingFilter.java    19 Sep 2005 01:06:51 -0000
@@ -462,7 +462,7 @@
        authorities = (GrantedAuthority[]) newAuths.toArray (authorities);

        // create the new authentication token
-        targetUserRequest = new UsernamePasswordAuthenticationToken(username,
+        targetUserRequest = new UsernamePasswordAuthenticationToken(targetUser,
                targetUser.getPassword(), authorities);

        // set details


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Home: http://acegisecurity.sourceforge.net
Acegisecurity-developer mailing list
Acegisecurity-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer

Reply via email to