This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 4_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/4_1_X by this push:
     new 8a3ed1bf5d Create Groovy CommandArgs instances under GroovyInterceptor
8a3ed1bf5d is described below

commit 8a3ed1bf5d1915a85dcc5f49c9d1468c05316ffc
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Thu Aug 20 14:11:23 2026 +0200

    Create Groovy CommandArgs instances under GroovyInterceptor
---
 .../implementation/ImplementationManager.java      | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git 
a/core/spring/src/main/java/org/apache/syncope/core/spring/implementation/ImplementationManager.java
 
b/core/spring/src/main/java/org/apache/syncope/core/spring/implementation/ImplementationManager.java
index 99a89b3490..2f9c890be2 100644
--- 
a/core/spring/src/main/java/org/apache/syncope/core/spring/implementation/ImplementationManager.java
+++ 
b/core/spring/src/main/java/org/apache/syncope/core/spring/implementation/ImplementationManager.java
@@ -20,6 +20,7 @@ package org.apache.syncope.core.spring.implementation;
 
 import groovy.grape.GrabAnnotationTransformation;
 import groovy.lang.GroovyClassLoader;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -246,7 +247,7 @@ public final class ImplementationManager {
                 && (commandArgsClass.getEnclosingClass() == null
                 || Modifier.isStatic(commandArgsClass.getModifiers()))) {
 
-            return commandArgsClass.getDeclaredConstructor().newInstance();
+            return newInstance(commandArgsClass, impl.getEngine());
         }
 
         throw new IllegalArgumentException(
@@ -277,6 +278,25 @@ public final class ImplementationManager {
         return Pair.of((Class<T>) clazz, false);
     }
 
+    private static <T> T newInstance(final Class<T> clazz, final 
ImplementationEngine engine)
+            throws NoSuchMethodException, InstantiationException, 
IllegalAccessException, IllegalArgumentException,
+            InvocationTargetException {
+
+        if (engine == ImplementationEngine.JAVA) {
+            return clazz.getDeclaredConstructor().newInstance();
+        }
+
+        GroovyInterceptor interceptor = new SandboxInterceptor(
+                
ApplicationContextProvider.getApplicationContext().getBean(Blacklist.class));
+        try {
+            interceptor.register();
+
+            return clazz.getDeclaredConstructor().newInstance();
+        } finally {
+            interceptor.unregister();
+        }
+    }
+
     private static <T> T createBean(final Class<T> clazz, final 
ImplementationEngine engine) {
         if (engine == ImplementationEngine.JAVA) {
             return 
ApplicationContextProvider.getBeanFactory().createBean(clazz);

Reply via email to