You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/05/23 17:16:59 UTC
[isis] branch master updated: ISIS-2688: make IsisRequestCycle
aware of ImpersonatedUserHolder
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 040a3e2 ISIS-2688: make IsisRequestCycle aware of ImpersonatedUserHolder
040a3e2 is described below
commit 040a3e28f33cdc2fcba166c7d8b0898587309865
Author: andi-huber <ah...@apache.org>
AuthorDate: Sun May 23 19:16:52 2021 +0200
ISIS-2688: make IsisRequestCycle aware of ImpersonatedUserHolder
---
.../core/interaction/integration/IsisRequestCycle.java | 15 +++++++++++++--
.../wicket/viewer/integration/WebRequestCycleForIsis.java | 5 ++++-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/core/interaction/src/main/java/org/apache/isis/core/interaction/integration/IsisRequestCycle.java b/core/interaction/src/main/java/org/apache/isis/core/interaction/integration/IsisRequestCycle.java
index cc5b85d..1db3507 100644
--- a/core/interaction/src/main/java/org/apache/isis/core/interaction/integration/IsisRequestCycle.java
+++ b/core/interaction/src/main/java/org/apache/isis/core/interaction/integration/IsisRequestCycle.java
@@ -18,10 +18,13 @@
*/
package org.apache.isis.core.interaction.integration;
+import org.apache.isis.applib.services.user.ImpersonatedUserHolder;
import org.apache.isis.core.interaction.session.InteractionFactory;
import org.apache.isis.core.security.authentication.Authentication;
+import org.apache.isis.core.security.authentication.standard.SimpleAuthentication;
import lombok.RequiredArgsConstructor;
+import lombok.val;
/**
*
@@ -31,12 +34,20 @@ import lombok.RequiredArgsConstructor;
public class IsisRequestCycle {
private final InteractionFactory isisInteractionFactory;
+ private final ImpersonatedUserHolder impersonatedUserHolder;
// -- SUPPORTING WEB REQUEST CYCLE FOR ISIS ...
- public void onBeginRequest(Authentication authentication) {
+ public void onBeginRequest(final Authentication authentication) {
- isisInteractionFactory.openInteraction(authentication);
+ val authenticationToUse = impersonatedUserHolder.getUserMemento()
+ .<Authentication>map(impersonatingUserMemento->
+ SimpleAuthentication.of(
+ impersonatingUserMemento,
+ authentication.getValidationCode()))
+ .orElse(authentication);
+
+ isisInteractionFactory.openInteraction(authenticationToUse);
}
public void onRequestHandlerExecuted() {
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/WebRequestCycleForIsis.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/WebRequestCycleForIsis.java
index c6aa8c5..30a19b4 100644
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/WebRequestCycleForIsis.java
+++ b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/WebRequestCycleForIsis.java
@@ -52,6 +52,7 @@ import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerService;
import org.apache.isis.applib.services.exceprecog.Recognition;
import org.apache.isis.applib.services.i18n.TranslationContext;
import org.apache.isis.applib.services.iactn.Interaction;
+import org.apache.isis.applib.services.user.ImpersonatedUserHolder;
import org.apache.isis.commons.collections.Can;
import org.apache.isis.commons.internal.base._Strings;
import org.apache.isis.commons.internal.exceptions._Exceptions;
@@ -146,7 +147,9 @@ public class WebRequestCycleForIsis implements IRequestCycleListener {
}
val isisRequestCycle = IsisRequestCycle.next(
- commonContext.lookupServiceElseFail(InteractionFactory.class));
+ commonContext.lookupServiceElseFail(InteractionFactory.class),
+ commonContext.lookupServiceElseFail(ImpersonatedUserHolder.class)
+ );
requestCycle.setMetaData(REQ_CYCLE_HANDLE_KEY, isisRequestCycle);