Create mock subject to satisfy legman

The posted restart event will trigger legman to request the current
subject so that it can be passed over. This will lead to an exception
if no subject is registered. The subject itself is of no importance
here.

Reported here:
https://groups.google.com/d/msg/scmmanager/m4CfDE2n4h8/Yn6fddaYBgAJ
This commit is contained in:
Rene Pfeuffer
2020-01-13 10:56:47 +01:00
parent dd3949b817
commit b6590673c0

View File

@@ -5,6 +5,9 @@ import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.event.ScmEventBus;
@@ -116,6 +119,8 @@ class MigrationWizardServlet extends HttpServlet {
respondWithTemplate(resp, model, "templates/repository-migration-restart.mustache");
ThreadContext.bind(new Subject.Builder(new DefaultSecurityManager()).authenticated(false).buildSubject());
ScmEventBus.getInstance().post(new RestartEvent(MigrationWizardServlet.class, "wrote migration data"));
}