diff --git a/core/src/main/java/org/acegisecurity/ui/switchuser/SwitchUserProcessingFilter.java b/core/src/main/java/org/acegisecurity/ui/switchuser/SwitchUserProcessingFilter.java
index <HASH>..<HASH> 100644
--- a/core/src/main/java/org/acegisecurity/ui/switchuser/SwitchUserProcessingFilter.java
+++ b/core/src/main/java/org/acegisecurity/ui/switchuser/SwitchUserProcessingFilter.java
@@ -263,8 +263,8 @@ public class SwitchUserProcessingFilter implements Filter, InitializingBean,
         UserDetails originalUser = null;
         Object obj = original.getPrincipal();
 
-        if ((obj != null) && obj instanceof User) {
-            originalUser = (User) obj;
+        if ((obj != null) && obj instanceof UserDetails) {
+            originalUser = (UserDetails) obj;
         }
 
         // publish event
when extracting the original user, fix by referencing by the interface (UserDetail) rather than the concrete class (User)