diff --git a/core/src/main/java/org/acegisecurity/wrapper/ContextHolderAwareRequestWrapper.java b/core/src/main/java/org/acegisecurity/wrapper/ContextHolderAwareRequestWrapper.java index 56042aaf05..2d40fd68e8 100644 --- a/core/src/main/java/org/acegisecurity/wrapper/ContextHolderAwareRequestWrapper.java +++ b/core/src/main/java/org/acegisecurity/wrapper/ContextHolderAwareRequestWrapper.java @@ -16,10 +16,13 @@ package net.sf.acegisecurity.wrapper; import net.sf.acegisecurity.Authentication; +import net.sf.acegisecurity.AuthenticationTrustResolver; +import net.sf.acegisecurity.AuthenticationTrustResolverImpl; import net.sf.acegisecurity.GrantedAuthority; import net.sf.acegisecurity.UserDetails; import net.sf.acegisecurity.context.ContextHolder; import net.sf.acegisecurity.context.security.SecureContext; +import net.sf.acegisecurity.context.security.SecureContextUtils; import java.security.Principal; @@ -39,6 +42,10 @@ import javax.servlet.http.HttpServletRequestWrapper; * @version $Id$ */ public class ContextHolderAwareRequestWrapper extends HttpServletRequestWrapper { + //~ Instance fields ======================================================== + + private AuthenticationTrustResolver authenticationTrustResolver = new AuthenticationTrustResolverImpl(); + //~ Constructors =========================================================== public ContextHolderAwareRequestWrapper(HttpServletRequest request) { @@ -109,8 +116,12 @@ public class ContextHolderAwareRequestWrapper extends HttpServletRequestWrapper private Authentication getAuthentication() { if ((ContextHolder.getContext() != null) && ContextHolder.getContext() instanceof SecureContext) { - return ((SecureContext) ContextHolder.getContext()) - .getAuthentication(); + Authentication auth = SecureContextUtils.getSecureContext() + .getAuthentication(); + + if (!authenticationTrustResolver.isAnonymous(auth)) { + return auth; + } } return null; diff --git a/doc/xdocs/changes.xml b/doc/xdocs/changes.xml index 9dafc14a1c..518f6937cb 100644 --- a/doc/xdocs/changes.xml +++ b/doc/xdocs/changes.xml @@ -27,6 +27,7 @@