diff --git a/jans-linux-setup/jans_setup/static/extension/discovery/Discovery.java b/jans-linux-setup/jans_setup/static/extension/discovery/Discovery.java new file mode 100644 index 00000000000..3a0fe7bc5ad --- /dev/null +++ b/jans-linux-setup/jans_setup/static/extension/discovery/Discovery.java @@ -0,0 +1,51 @@ +/* Copyright (c) 2022, Gluu + Author: Yuriy Z + */ + +import io.jans.model.SimpleCustomProperty; +import io.jans.model.custom.script.model.CustomScript; +import io.jans.model.custom.script.type.discovery.DiscoveryType; +import io.jans.service.custom.script.CustomScriptManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.json.JSONObject; + +import java.util.Map; + +public class Discovery implements DiscoveryType { + + private static final Logger log = LoggerFactory.getLogger(Discovery.class); + private static final Logger scriptLogger = LoggerFactory.getLogger(CustomScriptManager.class); + + @Override + public boolean init(Map configurationAttributes) { + log.info("Init of Discovery Java custom script"); + return true; + } + + @Override + public boolean init(CustomScript customScript, Map configurationAttributes) { + log.info("Init of Discovery Java custom script"); + return true; + } + + @Override + public boolean destroy(Map configurationAttributes) { + log.info("Destroy of Discovery Java custom script"); + return true; + } + + @Override + public int getApiVersion() { + log.info("getApiVersion Discovery Java custom script: 11"); + return 11; + } + + @Override + public boolean modifyResponse(Object responseAsJsonObject, Object context) { + scriptLogger.info("write to script logger"); + JSONObject response = (JSONObject) responseAsJsonObject; + response.accumulate("key_from_java", "value_from_script_on_java"); + return true; + } +}