X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.security.core%2Fsrc%2Forg%2Fargeo%2Fsecurity%2Fcore%2FAbstractSystemExecution.java;h=3acf26c8a1d3097f0336aea0d1c0051556d477dc;hb=d12f4cda6ff7b1de242a19362c3680f30ccc5168;hp=b84f3de00e6819139292d613cddc504b0cacdb7b;hpb=10ed6557c631d5feee8541badd0c9f16a9e791c6;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.core/src/org/argeo/security/core/AbstractSystemExecution.java b/org.argeo.security.core/src/org/argeo/security/core/AbstractSystemExecution.java index b84f3de00..3acf26c8a 100644 --- a/org.argeo.security.core/src/org/argeo/security/core/AbstractSystemExecution.java +++ b/org.argeo.security.core/src/org/argeo/security/core/AbstractSystemExecution.java @@ -19,10 +19,10 @@ import org.apache.commons.logging.Log; 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 { @@ -30,9 +30,10 @@ 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 @@ -72,13 +73,16 @@ public abstract class AbstractSystemExecution { String key = systemAuthenticationKey != null ? systemAuthenticationKey : System.getProperty( - InternalAuthentication.SYSTEM_KEY_PROPERTY, + SystemAuthentication.SYSTEM_KEY_PROPERTY, 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"); @@ -112,5 +116,4 @@ public abstract class AbstractSystemExecution { public void setSystemAuthenticationKey(String systemAuthenticationKey) { this.systemAuthenticationKey = systemAuthenticationKey; } - }