diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalDynamicClientRegistrationService.java b/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalDynamicClientRegistrationService.java index 3e81856e116..dab8d4f319f 100644 --- a/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalDynamicClientRegistrationService.java +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalDynamicClientRegistrationService.java @@ -11,6 +11,7 @@ import io.jans.as.model.error.ErrorResponseFactory; import io.jans.as.model.jwt.Jwt; import io.jans.as.model.util.CertUtils; +import io.jans.as.server.model.common.ExecutionContext; import io.jans.as.server.service.external.context.DynamicClientRegistrationContext; import io.jans.model.custom.script.CustomScriptType; import io.jans.model.custom.script.conf.CustomScriptConfiguration; @@ -231,4 +232,27 @@ public boolean isCertValidForClient(X509Certificate cert, DynamicClientRegistrat return false; } } + + public boolean modifyPostResponse(JSONObject responseAsJsonObject, ExecutionContext context) { + CustomScriptConfiguration script = defaultExternalCustomScript; + + try { + if (log.isTraceEnabled()) { + log.trace("Executing python 'modifyPostResponse' method, script name: {}, context: {}, response: {}", script.getName(), context, responseAsJsonObject.toString()); + } + context.setScript(script); + + ClientRegistrationType type = (ClientRegistrationType) script.getExternalType(); + final boolean result = type.modifyPostResponse(responseAsJsonObject, context); + if (log.isTraceEnabled()) { + log.trace("Finished 'modifyPostResponse' method, script name: {}, context: {}, result: {}, response: {}", script.getName(), context, result, responseAsJsonObject.toString()); + } + + return result; + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + saveScriptError(script.getCustomScript(), ex); + } + return false; + } }