From c0ea3819bb9d1b8b0dfa99d94785eb4282ed6f65 Mon Sep 17 00:00:00 2001 From: "Carlos A. Munoz" Date: Wed, 28 Aug 2013 11:35:31 +1000 Subject: [PATCH] Fix identity check failures for asynchronous tasks. Passing identity before which is automatically logged out when the session context is destroyed (which may happen when the original request ends). Replaced with passing of the subject and principal directly. --- .../java/org/zanata/async/AsynchronousTaskExecutor.java | 8 ++++---- .../src/main/java/org/zanata/async/TaskExecutor.java | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/async/AsynchronousTaskExecutor.java b/zanata-war/src/main/java/org/zanata/async/AsynchronousTaskExecutor.java index 00fb28a07d..7ab78ac715 100644 --- a/zanata-war/src/main/java/org/zanata/async/AsynchronousTaskExecutor.java +++ b/zanata-war/src/main/java/org/zanata/async/AsynchronousTaskExecutor.java @@ -29,7 +29,6 @@ import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.async.Asynchronous; -import org.jboss.seam.security.Identity; import org.jboss.seam.security.RunAsOperation; import lombok.extern.slf4j.Slf4j; @@ -49,7 +48,8 @@ public class AsynchronousTaskExecutor { @Asynchronous - public > void runAsynchronously(final AsyncTask task, final Identity runAs) + public > void runAsynchronously(final AsyncTask task, final Principal runAsPpal, + final Subject runAsSubject) { AsyncUtils.outject(task.getHandle(), ScopeType.EVENT); @@ -73,13 +73,13 @@ public void execute() @Override public Principal getPrincipal() { - return runAs.getPrincipal(); + return runAsPpal; } @Override public Subject getSubject() { - return runAs.getSubject(); + return runAsSubject; } }; diff --git a/zanata-war/src/main/java/org/zanata/async/TaskExecutor.java b/zanata-war/src/main/java/org/zanata/async/TaskExecutor.java index 0275ce0e18..2665be5dd1 100644 --- a/zanata-war/src/main/java/org/zanata/async/TaskExecutor.java +++ b/zanata-war/src/main/java/org/zanata/async/TaskExecutor.java @@ -57,7 +57,8 @@ public > AsyncTaskHandle startTask(AsyncTask< throw new RuntimeException("An Asynchronous task should always return a non-null handle"); } - asynchronousTaskExecutor.runAsynchronously(task, Identity.instance()); + Identity identity = Identity.instance(); + asynchronousTaskExecutor.runAsynchronously(task, identity.getPrincipal(), identity.getSubject()); return handle; }