import org.apache.commons.logging.LogFactory;
import org.argeo.ArgeoException;
import org.argeo.security.SystemAuthentication;
-import org.springframework.security.Authentication;
-import org.springframework.security.AuthenticationManager;
-import org.springframework.security.context.SecurityContext;
-import org.springframework.security.context.SecurityContextHolder;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
/** Provides base method for executing code with system authorization. */
public abstract class AbstractSystemExecution {
// Forces Spring Security to use inheritable strategy
// FIXME find a better place for forcing spring security mode
// doesn't work for the time being
-// if (System.getProperty(SecurityContextHolder.SYSTEM_PROPERTY) == null)
-// SecurityContextHolder
-// .setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
+ // if (System.getProperty(SecurityContextHolder.SYSTEM_PROPERTY) ==
+ // null)
+ // SecurityContextHolder
+ // .setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
}
private final static Log log = LogFactory
InternalAuthentication.SYSTEM_KEY_DEFAULT);
if (key == null)
throw new ArgeoException("No system key defined");
+ if (authenticationManager == null)
+ throw new ArgeoException("Authentication manager cannot be null.");
Authentication auth = authenticationManager
.authenticate(new InternalAuthentication(key));
securityContext.setAuthentication(auth);
+
authenticatedBySelf.set(true);
if (log.isTraceEnabled())
log.trace("System authenticated");
public void setSystemAuthenticationKey(String systemAuthenticationKey) {
this.systemAuthenticationKey = systemAuthenticationKey;
}
-
}