+ securityDao.update(simpleArgeoUser);
+ }
+
+ public TaskExecutor createSystemAuthenticatedTaskExecutor() {
+ return new SimpleAsyncTaskExecutor() {
+ private static final long serialVersionUID = -8126773862193265020L;
+
+ @Override
+ public Thread createThread(Runnable runnable) {
+ return super
+ .createThread(wrapWithSystemAuthentication(runnable));
+ }
+
+ };
+ }
+
+ /**
+ * Wraps another runnable, adding security context <br/>
+ * TODO: secure the call to this method with Java Security
+ */
+ public Runnable wrapWithSystemAuthentication(final Runnable runnable) {
+ return new Runnable() {
+
+ public void run() {
+ SecurityContext securityContext = SecurityContextHolder
+ .getContext();
+ Authentication auth = authenticationManager
+ .authenticate(new InternalAuthentication(
+ systemAuthenticationKey));
+ securityContext.setAuthentication(auth);
+
+ runnable.run();
+ }
+ };