From 0e74efdfa47afe8c1c79aeac09e45e43e14fe26f Mon Sep 17 00:00:00 2001 From: YuriyZ Date: Fri, 27 Dec 2024 17:41:24 +0200 Subject: [PATCH] feat(jans-auth-server): add Token Exchange interception script #8157 Signed-off-by: YuriyZ --- .../model/custom/script/CustomScriptType.java | 3 ++ .../type/token/DummyTokenExchangeType.java | 46 +++++++++++++++++++ .../script/type/token/TokenExchangeType.java | 15 ++++++ 3 files changed, 64 insertions(+) create mode 100644 jans-core/script/src/main/java/io/jans/model/custom/script/type/token/DummyTokenExchangeType.java create mode 100644 jans-core/script/src/main/java/io/jans/model/custom/script/type/token/TokenExchangeType.java diff --git a/jans-core/script/src/main/java/io/jans/model/custom/script/CustomScriptType.java b/jans-core/script/src/main/java/io/jans/model/custom/script/CustomScriptType.java index 31208509325..6cd031c9709 100644 --- a/jans-core/script/src/main/java/io/jans/model/custom/script/CustomScriptType.java +++ b/jans-core/script/src/main/java/io/jans/model/custom/script/CustomScriptType.java @@ -67,7 +67,9 @@ import io.jans.model.custom.script.type.spontaneous.SpontaneousScopeType; import io.jans.model.custom.script.type.ssa.DummyModifySsaResponseType; import io.jans.model.custom.script.type.ssa.ModifySsaResponseType; +import io.jans.model.custom.script.type.token.DummyTokenExchangeType; import io.jans.model.custom.script.type.token.DummyUpdateTokenType; +import io.jans.model.custom.script.type.token.TokenExchangeType; import io.jans.model.custom.script.type.token.UpdateTokenType; import io.jans.model.custom.script.type.uma.*; import io.jans.model.custom.script.type.user.CacheRefreshType; @@ -106,6 +108,7 @@ public enum CustomScriptType implements AttributeEnum { new DummyAccessEvaluationType()), ACCESS_EVALUATION_DISCOVERY("access_evaluation_discovery", "Access Evaluation Discovery", AccessEvaluationDiscoveryType.class, CustomScript.class, "AccessEvaluationDiscovery", new DummyAccessEvaluationDiscoveryType()), + TOKEN_EXCHANGE("token_exchange", "Token Exchange", TokenExchangeType.class, CustomScript.class, "TokenExchange", new DummyTokenExchangeType()), CONSENT_GATHERING("consent_gathering", "Consent Gathering", ConsentGatheringType.class, CustomScript.class, "ConsentGathering", new DummyConsentGatheringType()), DYNAMIC_SCOPE("dynamic_scope", "Dynamic Scopes", DynamicScopeType.class, CustomScript.class, "DynamicScope", diff --git a/jans-core/script/src/main/java/io/jans/model/custom/script/type/token/DummyTokenExchangeType.java b/jans-core/script/src/main/java/io/jans/model/custom/script/type/token/DummyTokenExchangeType.java new file mode 100644 index 00000000000..7d05106eeb4 --- /dev/null +++ b/jans-core/script/src/main/java/io/jans/model/custom/script/type/token/DummyTokenExchangeType.java @@ -0,0 +1,46 @@ +package io.jans.model.custom.script.type.token; + +import io.jans.model.SimpleCustomProperty; +import io.jans.model.custom.script.model.CustomScript; + +import java.util.Map; + +/** + * @author Yuriy Z + */ +public class DummyTokenExchangeType implements TokenExchangeType { + @Override + public boolean modifyResponse(Object context) { + return false; + } + + @Override + public void validate(Object context) { + // dummy + } + + @Override + public boolean skipBuiltinValidation(Object context) { + return false; + } + + @Override + public boolean init(Map configurationAttributes) { + return true; + } + + @Override + public boolean init(CustomScript customScript, Map configurationAttributes) { + return true; + } + + @Override + public boolean destroy(Map configurationAttributes) { + return true; + } + + @Override + public int getApiVersion() { + return 1; + } +} diff --git a/jans-core/script/src/main/java/io/jans/model/custom/script/type/token/TokenExchangeType.java b/jans-core/script/src/main/java/io/jans/model/custom/script/type/token/TokenExchangeType.java new file mode 100644 index 00000000000..1575c021161 --- /dev/null +++ b/jans-core/script/src/main/java/io/jans/model/custom/script/type/token/TokenExchangeType.java @@ -0,0 +1,15 @@ +package io.jans.model.custom.script.type.token; + +import io.jans.model.custom.script.type.BaseExternalType; + +/** + * @author Yuriy Z + */ +public interface TokenExchangeType extends BaseExternalType { + + boolean modifyResponse(Object context); + + void validate(Object context); + + boolean skipBuiltinValidation(Object context); +}