From e6e76c99397fff808468c73d00d730ced39c6d4f Mon Sep 17 00:00:00 2001 From: jgomer2001 Date: Thu, 23 Feb 2023 09:13:27 -0500 Subject: [PATCH 1/2] docs: minor doc updates #3977 --- docs/admin/developer/agama/dsl-full.md | 3 ++- docs/admin/developer/agama/faq.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/admin/developer/agama/dsl-full.md b/docs/admin/developer/agama/dsl-full.md index 1292821a0bd..ffe2eebd0a3 100644 --- a/docs/admin/developer/agama/dsl-full.md +++ b/docs/admin/developer/agama/dsl-full.md @@ -445,7 +445,8 @@ Finish it.nonsense - Any statements found after `Finish` is not reached and thus, not executed - If no `Finish` statement is found in a flow's execution, this will degenerate in flow crash -- When a flow is finished and was used as subflow (part of the execution of a bigger parent flow), the parent does not terminate. Execution continues at the following instruction that triggered the subflow. More on `Trigger` later +- When a flow is finished and was used as [subflow](#subflows) (part of the execution of a bigger parent flow), the parent does not terminate. Execution continues at the following instruction that triggered the subflow. More on `Trigger` later +- Using `data` in the `Finish` directive is an effective way to communicate information to callers (parent flows). If a flow has no parents, `data` is stored in the authentication server's session of the given user under the key `agamaData`. Contents are serialized to a JSON string previously - A flow cannot be aborted by itself. This can only be achieved through a parent flow. Learn more about aborted flows [here](./flows-lifecycle.md#cancellation) - Check the best practices on finishing flows [here](./flows-lifecycle.md#finishing-flows) diff --git a/docs/admin/developer/agama/faq.md b/docs/admin/developer/agama/faq.md index e72a0360850..0d278cf8d06 100644 --- a/docs/admin/developer/agama/faq.md +++ b/docs/admin/developer/agama/faq.md @@ -46,6 +46,10 @@ To fix a serialization problem, try some of the following: This is a limitation of the scripting engine. Here, classes have to be imported even if they belong to the same package, or the fully qualified name used. +### A class is still available after removing the corresponding file + +This is because the JVM does not support unloading: even if a given source file is removed, its corresponding class will still be accessible - it remains in the classpath. The classpath will be clean again after a service restart. + ### How to append data to a flow's log directly? Call method `log` of class `io.jans.agama.engine.script.LogUtils`. This method receives a variable number of arguments as DSL's `Log` does. Thus you can do `LogUtils.log("@w Today is Friday %th", 13)`, as in the logging [examples](./dsl-full.md#logging). From 096549432553d7f5a1eb1876ec24491d3f38918f Mon Sep 17 00:00:00 2001 From: jgomer2001 Date: Thu, 23 Feb 2023 09:15:08 -0500 Subject: [PATCH 2/2] feat: update bridge to store flow result data in session #3977 --- .../agama-bridge/AgamaBridge.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/script-catalog/person_authentication/agama-bridge/AgamaBridge.py b/docs/script-catalog/person_authentication/agama-bridge/AgamaBridge.py index 3983d25f6bf..ff27b7ec32f 100644 --- a/docs/script-catalog/person_authentication/agama-bridge/AgamaBridge.py +++ b/docs/script-catalog/person_authentication/agama-bridge/AgamaBridge.py @@ -1,6 +1,9 @@ # Janssen Project software is available under the Apache 2.0 License (2004). See http://www.apache.org/licenses/ for full text. # Copyright (c) 2020, Janssen Project # + +from com.fasterxml.jackson.databind import ObjectMapper + from io.jans.agama import NativeJansFlowBridge from io.jans.agama.engine.misc import FlowUtils from io.jans.as.server.security import Identity @@ -13,6 +16,7 @@ from io.jans.util import StringHelper from jakarta.faces.application import FacesMessage +from java.util import Arrays import java import sys @@ -22,7 +26,9 @@ def __init__(self, currentTimeMillis): self.currentTimeMillis = currentTimeMillis def init(self, customScript, configurationAttributes): - print "Agama. Initialization" + print "Agama. Initialization" + self.resultParam = "agamaData" + prop = "cust_param_name" self.cust_param_name = self.configProperty(configurationAttributes, prop) @@ -78,6 +84,9 @@ def authenticate(self, configurationAttributes, requestParameters, step): if not authenticated: print "Agama. Unable to authenticate %s" % userId return False + + jsonData = CdiUtil.bean(ObjectMapper).writeValueAsString(data) + CdiUtil.bean(Identity).setWorkingParameter(self.resultParam, jsonData) except: print "Agama. Exception: ", sys.exc_info()[1] return False @@ -132,7 +141,7 @@ def prepareForStep(self, configurationAttributes, requestParameters, step): return True def getExtraParametersForStep(self, configurationAttributes, step): - return None + return Arrays.asList(self.resultParam) def getCountAuthenticationSteps(self, configurationAttributes): return 1