diff --git a/core/src/main/java/org/acegisecurity/intercept/AbstractSecurityInterceptor.java b/core/src/main/java/org/acegisecurity/intercept/AbstractSecurityInterceptor.java index 8587cfcc84..05cc7fe784 100644 --- a/core/src/main/java/org/acegisecurity/intercept/AbstractSecurityInterceptor.java +++ b/core/src/main/java/org/acegisecurity/intercept/AbstractSecurityInterceptor.java @@ -59,8 +59,8 @@ import java.util.Set; * *
null objects.
+ * Extract the {@link SecureContext} from the {@link SecurityContextHolder},
+ * handling any errors such as invalid or null objects.
* Authentication object on
- * the ContextHolder with the returned value.
+ * If either the {@link net.sf.acegisecurity.Authentication#isAuthenticated()}
+ * returns false, or the {@link #alwaysReauthenticate} is
+ * true, authenticate the request against the configured {@link
+ * AuthenticationManager}. When authenticated, replace the
+ * Authentication object on the
+ * SecurityContextHolder with the returned value.
* RunAsManager replaced the Authentication
- * object, return the ContextHolder to the object that existed
- * after the call to AuthenticationManager.
+ * object, return the SecurityContextHolder to the object that
+ * existed after the call to AuthenticationManager.
* AfterInvocationManager is defined, invoke the invocation
@@ -118,11 +121,6 @@ import java.util.Set;
*
* ContextHolder contains a SecureContext, set
- * the isAuthenticated flag on the Authentication
- * object to false.
- * InterceptorStatusToken which is subsequently re-presented to
* the AbstractSecurityInterceptor after the secure object has
@@ -157,6 +155,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
private ApplicationContext context;
private AuthenticationManager authenticationManager;
private RunAsManager runAsManager = new NullRunAsManager();
+ private boolean alwaysReauthenticate = false;
private boolean validateConfigAttributes = true;
//~ Methods ================================================================
@@ -170,6 +169,27 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
return afterInvocationManager;
}
+ /**
+ * Indicates whether the AbstractSecurityInterceptor should
+ * ignore the {@link Authentication#isAuthenticated()} property. Defaults
+ * to false, meaning by default the
+ * Authentication.isAuthenticated() property is trusted and
+ * re-authentication will not occur if the principal has already been
+ * authenticated.
+ *
+ * @param alwaysReauthenticate true to force
+ * AbstractSecurityInterceptor to disregard the value
+ * of Authentication.isAuthenticated() and always
+ * re-authenticate the request (defaults to false).
+ */
+ public void setAlwaysReauthenticate(boolean alwaysReauthenticate) {
+ this.alwaysReauthenticate = alwaysReauthenticate;
+ }
+
+ public boolean isAlwaysReauthenticate() {
+ return alwaysReauthenticate;
+ }
+
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.context = applicationContext;
@@ -364,11 +384,12 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
object, attr);
}
- // Attempt authentication if not already authenticated
+ // Attempt authentication if not already authenticated, or user always wants reauthentication
Authentication authenticated;
if (!SecurityContextHolder.getContext().getAuthentication()
- .isAuthenticated()) {
+ .isAuthenticated()
+ || alwaysReauthenticate) {
try {
authenticated = this.authenticationManager.authenticate(SecurityContextHolder.getContext()
.getAuthentication());
diff --git a/doc/xdocs/changes.xml b/doc/xdocs/changes.xml
index 9f2e23f10d..1e26283155 100644
--- a/doc/xdocs/changes.xml
+++ b/doc/xdocs/changes.xml
@@ -37,7 +37,7 @@