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

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


The following commit(s) were added to refs/heads/3_0_X by this push:
     new c59384b84e [SYNCOPE-1795] JWTSSOProvider and AuditAppender no more 
Implementations (#577)
c59384b84e is described below

commit c59384b84e7651928d1d9643e6ff94438d82ab97
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Fri Dec 15 14:57:05 2023 +0100

    [SYNCOPE-1795] JWTSSOProvider and AuditAppender no more Implementations 
(#577)
---
 .../client/console/pages/Implementations.java      |  6 +----
 .../common/lib/types/IdRepoImplementationType.java |  6 -----
 .../core/logic/DummyImplementationLookup.java      |  5 ----
 .../init/ClassPathScanImplementationLookup.java    | 15 +----------
 .../core/logic/DummyImplementationLookup.java      |  5 ----
 .../persistence/jpa/DummyImplementationLookup.java |  5 ----
 .../provisioning/api/ImplementationLookup.java     |  2 --
 .../java/DummyImplementationLookup.java            |  5 ----
 .../core/spring/security/AuthDataAccessor.java     | 31 +++++-----------------
 .../core/spring/security/SecurityContext.java      | 13 +++++++++
 .../spring/security/SyncopeJWTSSOProvider.java     | 29 ++++++++++++--------
 .../core/spring/security/WebSecurityContext.java   |  6 ++---
 .../spring/security/DummyImplementationLookup.java |  5 ----
 .../workflow/java/DummyImplementationLookup.java   |  5 ----
 .../apache/syncope/core/logic/SAML2SP4UILogic.java | 13 ++++-----
 .../fit/core/reference/CoreReferenceContext.java   | 11 ++++++++
 .../fit/core/reference/CustomJWTSSOProvider.java   | 19 +++++++------
 .../fit/core/reference/ITImplementationLookup.java | 19 +------------
 18 files changed, 70 insertions(+), 130 deletions(-)

diff --git 
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Implementations.java
 
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Implementations.java
index 51b9f62153..86ab417fc8 100644
--- 
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Implementations.java
+++ 
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Implementations.java
@@ -25,7 +25,6 @@ import 
org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
 import org.apache.syncope.client.console.SyncopeConsoleSession;
 import org.apache.syncope.client.console.panels.ImplementationDirectoryPanel;
 import org.apache.syncope.client.console.rest.ImplementationRestClient;
-import org.apache.syncope.common.lib.types.IdRepoImplementationType;
 import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
 import org.apache.wicket.extensions.markup.html.tabs.ITab;
 import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -53,10 +52,7 @@ public class Implementations extends BasePage {
     }
 
     protected List<ITab> buildTabList() {
-        return 
SyncopeConsoleSession.get().getPlatformInfo().getImplementationTypes().stream().
-                filter(type -> 
!IdRepoImplementationType.JWT_SSO_PROVIDER.equals(type)
-                && !IdRepoImplementationType.AUDIT_APPENDER.equals(type)).
-                sorted().
+        return 
SyncopeConsoleSession.get().getPlatformInfo().getImplementationTypes().stream().sorted().
                 map(type -> new AbstractTab(Model.of(type)) {
 
             private static final long serialVersionUID = -5861786415855103549L;
diff --git 
a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoImplementationType.java
 
b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoImplementationType.java
index 981c5b99cb..f21c995a0b 100644
--- 
a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoImplementationType.java
+++ 
b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoImplementationType.java
@@ -23,8 +23,6 @@ import org.apache.commons.lang3.tuple.Pair;
 
 public final class IdRepoImplementationType {
 
-    public static final String JWT_SSO_PROVIDER = "JWT_SSO_PROVIDER";
-
     public static final String ACCOUNT_RULE = "ACCOUNT_RULE";
 
     public static final String PASSWORD_RULE = "PASSWORD_RULE";
@@ -41,12 +39,9 @@ public final class IdRepoImplementationType {
 
     public static final String RECIPIENTS_PROVIDER = "RECIPIENTS_PROVIDER";
 
-    public static final String AUDIT_APPENDER = "AUDIT_APPENDER";
-
     public static final String ITEM_TRANSFORMER = "ITEM_TRANSFORMER";
 
     private static final Map<String, String> VALUES = Map.ofEntries(
-            Pair.of(JWT_SSO_PROVIDER, 
"org.apache.syncope.core.spring.security.JWTSSOProvider"),
             Pair.of(ACCOUNT_RULE, 
"org.apache.syncope.core.provisioning.api.rules.AccountRule"),
             Pair.of(PASSWORD_RULE, 
"org.apache.syncope.core.provisioning.api.rules.PasswordRule"),
             Pair.of(TASKJOB_DELEGATE, 
"org.apache.syncope.core.provisioning.api.job.SchedTaskJobDelegate"),
@@ -55,7 +50,6 @@ public final class IdRepoImplementationType {
             Pair.of(VALIDATOR, 
"org.apache.syncope.core.persistence.api.attrvalue.validation.PlainAttrValueValidator"),
             Pair.of(COMMAND, "org.apache.syncope.core.logic.api.Command"),
             Pair.of(RECIPIENTS_PROVIDER, 
"org.apache.syncope.core.provisioning.api.notification.RecipientsProvider"),
-            Pair.of(AUDIT_APPENDER, 
"org.apache.syncope.core.logic.audit.AuditAppender"),
             Pair.of(ITEM_TRANSFORMER, 
"org.apache.syncope.core.provisioning.api.data.ItemTransformer"));
 
     public static Map<String, String> values() {
diff --git 
a/core/idm/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
 
b/core/idm/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
index 073ea28b49..e41cf4da86 100644
--- 
a/core/idm/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
+++ 
b/core/idm/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
@@ -43,11 +43,6 @@ public class DummyImplementationLookup implements 
ImplementationLookup {
         return Set.of();
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return Set.of();
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return null;
diff --git 
a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
 
b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
index 06ceec9122..ae68ae04d6 100644
--- 
a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
+++ 
b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
@@ -61,7 +61,6 @@ import 
org.apache.syncope.core.provisioning.java.data.JEXLItemTransformerImpl;
 import 
org.apache.syncope.core.provisioning.java.job.GroupMemberProvisionTaskJobDelegate;
 import org.apache.syncope.core.provisioning.java.pushpull.PullJobDelegate;
 import org.apache.syncope.core.provisioning.java.pushpull.PushJobDelegate;
-import org.apache.syncope.core.spring.security.JWTSSOProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -81,8 +80,6 @@ public class ClassPathScanImplementationLookup implements 
ImplementationLookup {
 
     private Map<String, Set<String>> classNames;
 
-    private Set<Class<?>> jwtSSOProviderClasses;
-
     private Map<Class<? extends ReportConf>, Class<? extends 
ReportJobDelegate>> reportJobDelegateClasses;
 
     private Map<Class<? extends AccountRuleConf>, Class<? extends 
AccountRule>> accountRuleClasses;
@@ -127,7 +124,6 @@ public class ClassPathScanImplementationLookup implements 
ImplementationLookup {
                 && !IdMImplementationType.values().containsKey(e.getKey())).
                 collect(Collectors.toMap(Entry::getKey, Entry::getValue));
 
-        jwtSSOProviderClasses = new HashSet<>();
         reportJobDelegateClasses = new HashMap<>();
         accountRuleClasses = new HashMap<>();
         passwordRuleClasses = new HashMap<>();
@@ -142,10 +138,7 @@ public class ClassPathScanImplementationLookup implements 
ImplementationLookup {
                     continue;
                 }
 
-                if (JWTSSOProvider.class.isAssignableFrom(clazz)) {
-                    
classNames.get(IdRepoImplementationType.JWT_SSO_PROVIDER).add(clazz.getName());
-                    jwtSSOProviderClasses.add(clazz);
-                } else if (ReportJobDelegate.class.isAssignableFrom(clazz)) {
+                if (ReportJobDelegate.class.isAssignableFrom(clazz)) {
                     ReportConfClass annotation = 
clazz.getAnnotation(ReportConfClass.class);
                     if (annotation == null) {
                         LOG.warn("Found Report {} without declared 
configuration", clazz.getName());
@@ -229,7 +222,6 @@ public class ClassPathScanImplementationLookup implements 
ImplementationLookup {
         classNames = Collections.unmodifiableMap(classNames);
         LOG.debug("Implementation classes found: {}", classNames);
 
-        jwtSSOProviderClasses = 
Collections.unmodifiableSet(jwtSSOProviderClasses);
         reportJobDelegateClasses = 
Collections.unmodifiableMap(reportJobDelegateClasses);
         accountRuleClasses = Collections.unmodifiableMap(accountRuleClasses);
         passwordRuleClasses = Collections.unmodifiableMap(passwordRuleClasses);
@@ -242,11 +234,6 @@ public class ClassPathScanImplementationLookup implements 
ImplementationLookup {
         return classNames.get(type);
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return jwtSSOProviderClasses;
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return reportJobDelegateClasses.get(reportConfClass);
diff --git 
a/core/idrepo/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
 
b/core/idrepo/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
index 073ea28b49..e41cf4da86 100644
--- 
a/core/idrepo/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
+++ 
b/core/idrepo/logic/src/test/java/org/apache/syncope/core/logic/DummyImplementationLookup.java
@@ -43,11 +43,6 @@ public class DummyImplementationLookup implements 
ImplementationLookup {
         return Set.of();
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return Set.of();
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return null;
diff --git 
a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/DummyImplementationLookup.java
 
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/DummyImplementationLookup.java
index 7fc54b387d..32eabecea7 100644
--- 
a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/DummyImplementationLookup.java
+++ 
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/DummyImplementationLookup.java
@@ -45,11 +45,6 @@ public class DummyImplementationLookup implements 
ImplementationLookup {
         return Set.of();
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return Set.of();
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return null;
diff --git 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/ImplementationLookup.java
 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/ImplementationLookup.java
index 2f5c789f17..ffd465c79f 100644
--- 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/ImplementationLookup.java
+++ 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/ImplementationLookup.java
@@ -35,8 +35,6 @@ public interface ImplementationLookup extends 
SyncopeCoreLoader {
 
     Set<String> getClassNames(String type);
 
-    Set<Class<?>> getJWTSSOProviderClasses();
-
     Class<? extends ReportJobDelegate> getReportClass(
             Class<? extends ReportConf> reportConfClass);
 
diff --git 
a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DummyImplementationLookup.java
 
b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DummyImplementationLookup.java
index 492ea53cc4..8bb73697a6 100644
--- 
a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DummyImplementationLookup.java
+++ 
b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DummyImplementationLookup.java
@@ -47,11 +47,6 @@ public class DummyImplementationLookup implements 
ImplementationLookup {
         return Set.of();
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return Set.of();
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return null;
diff --git 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/AuthDataAccessor.java
 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/AuthDataAccessor.java
index 4bfed7b889..820545ac6e 100644
--- 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/AuthDataAccessor.java
+++ 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/AuthDataAccessor.java
@@ -58,14 +58,11 @@ import org.apache.syncope.core.persistence.api.entity.Role;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.provisioning.api.AuditManager;
 import org.apache.syncope.core.provisioning.api.ConnectorManager;
-import org.apache.syncope.core.provisioning.api.ImplementationLookup;
 import org.apache.syncope.core.provisioning.api.MappingManager;
 import org.apache.syncope.core.provisioning.api.utils.RealmUtils;
-import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.identityconnectors.framework.common.objects.Uid;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import 
org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
 import org.springframework.security.authentication.DisabledException;
 import org.springframework.security.core.Authentication;
@@ -118,9 +115,7 @@ public class AuthDataAccessor {
 
     protected final MappingManager mappingManager;
 
-    protected final ImplementationLookup implementationLookup;
-
-    private Map<String, JWTSSOProvider> jwtSSOProviders;
+    private final List<JWTSSOProvider> jwtSSOProviders;
 
     public AuthDataAccessor(
             final SecurityProperties securityProperties,
@@ -135,7 +130,7 @@ public class AuthDataAccessor {
             final ConnectorManager connectorManager,
             final AuditManager auditManager,
             final MappingManager mappingManager,
-            final ImplementationLookup implementationLookup) {
+            final List<JWTSSOProvider> jwtSSOProviders) {
 
         this.securityProperties = securityProperties;
         this.realmDAO = realmDAO;
@@ -149,31 +144,17 @@ public class AuthDataAccessor {
         this.connectorManager = connectorManager;
         this.auditManager = auditManager;
         this.mappingManager = mappingManager;
-        this.implementationLookup = implementationLookup;
+        this.jwtSSOProviders = jwtSSOProviders;
     }
 
     public JWTSSOProvider getJWTSSOProvider(final String issuer) {
-        synchronized (this) {
-            if (jwtSSOProviders == null) {
-                jwtSSOProviders = new HashMap<>();
-
-                implementationLookup.getJWTSSOProviderClasses().stream().
-                        map(clazz -> (JWTSSOProvider) 
ApplicationContextProvider.getBeanFactory().
-                        createBean(clazz, 
AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true)).
-                        forEach(jwtSSOProvider -> 
jwtSSOProviders.put(jwtSSOProvider.getIssuer(), jwtSSOProvider));
-            }
-        }
-
         if (issuer == null) {
             throw new AuthenticationCredentialsNotFoundException("A null 
issuer is not permitted");
         }
-        JWTSSOProvider provider = jwtSSOProviders.get(issuer);
-        if (provider == null) {
-            throw new AuthenticationCredentialsNotFoundException(
-                    "Could not find any registered JWTSSOProvider for issuer " 
+ issuer);
-        }
 
-        return provider;
+        return jwtSSOProviders.stream().filter(provider -> 
issuer.equals(provider.getIssuer())).findFirst().
+                orElseThrow(() -> new 
AuthenticationCredentialsNotFoundException(
+                "Could not find any registered JWTSSOProvider for issuer " + 
issuer));
     }
 
     protected String getDelegationKey(final SyncopeAuthenticationDetails 
details, final String delegatedKey) {
diff --git 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/SecurityContext.java
 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/SecurityContext.java
index 7a5624837a..d6d0acc549 100644
--- 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/SecurityContext.java
+++ 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/SecurityContext.java
@@ -24,7 +24,9 @@ import com.nimbusds.jose.KeyLengthException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
 import org.apache.syncope.common.lib.types.CipherAlgorithm;
+import org.apache.syncope.core.persistence.api.dao.AccessTokenDAO;
 import org.apache.syncope.core.persistence.api.dao.RealmDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.provisioning.api.rules.RuleEnforcer;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.apache.syncope.core.spring.policy.DefaultRuleEnforcer;
@@ -109,6 +111,17 @@ public class SecurityContext {
         return new AccessTokenJWSSigner(jwsAlgorithm, jwsKey(jwsAlgorithm, 
props));
     }
 
+    @ConditionalOnMissingBean
+    @Bean
+    public SyncopeJWTSSOProvider syncopeJWTSSOProvider(
+            final SecurityProperties props,
+            final AccessTokenJWSVerifier accessTokenJWSVerifier,
+            final UserDAO userDAO,
+            final AccessTokenDAO accessTokenDAO) {
+
+        return new SyncopeJWTSSOProvider(props, accessTokenJWSVerifier, 
userDAO, accessTokenDAO);
+    }
+
     @ConditionalOnMissingBean
     @Bean
     public PasswordGenerator passwordGenerator() {
diff --git 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/SyncopeJWTSSOProvider.java
 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/SyncopeJWTSSOProvider.java
index ebf5d815f9..ecf4fc431a 100644
--- 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/SyncopeJWTSSOProvider.java
+++ 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/SyncopeJWTSSOProvider.java
@@ -36,7 +36,6 @@ import 
org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.apache.syncope.core.spring.security.jws.AccessTokenJWSVerifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -44,21 +43,29 @@ import 
org.springframework.transaction.annotation.Transactional;
  */
 public class SyncopeJWTSSOProvider implements JWTSSOProvider {
 
-    private static final Logger LOG = 
LoggerFactory.getLogger(SyncopeJWTSSOProvider.class);
+    protected static final Logger LOG = 
LoggerFactory.getLogger(SyncopeJWTSSOProvider.class);
 
-    private static final Encryptor ENCRYPTOR = Encryptor.getInstance();
+    protected static final Encryptor ENCRYPTOR = Encryptor.getInstance();
 
-    @Autowired
-    private SecurityProperties securityProperties;
+    protected final SecurityProperties securityProperties;
 
-    @Autowired
-    private AccessTokenJWSVerifier delegate;
+    protected final AccessTokenJWSVerifier delegate;
 
-    @Autowired
-    private UserDAO userDAO;
+    protected final UserDAO userDAO;
 
-    @Autowired
-    private AccessTokenDAO accessTokenDAO;
+    protected final AccessTokenDAO accessTokenDAO;
+
+    public SyncopeJWTSSOProvider(
+            final SecurityProperties securityProperties,
+            final AccessTokenJWSVerifier delegate,
+            final UserDAO userDAO,
+            final AccessTokenDAO accessTokenDAO) {
+
+        this.securityProperties = securityProperties;
+        this.delegate = delegate;
+        this.userDAO = userDAO;
+        this.accessTokenDAO = accessTokenDAO;
+    }
 
     @Override
     public String getIssuer() {
diff --git 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
index 42911045bc..76382801e7 100644
--- 
a/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
+++ 
b/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.spring.security;
 
+import java.util.List;
 import org.apache.syncope.common.keymaster.client.api.ConfParamOps;
 import org.apache.syncope.common.keymaster.client.api.DomainOps;
 import org.apache.syncope.common.lib.types.IdRepoEntitlement;
@@ -30,7 +31,6 @@ import org.apache.syncope.core.persistence.api.dao.RoleDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.provisioning.api.AuditManager;
 import org.apache.syncope.core.provisioning.api.ConnectorManager;
-import org.apache.syncope.core.provisioning.api.ImplementationLookup;
 import org.apache.syncope.core.provisioning.api.MappingManager;
 import org.apache.syncope.core.provisioning.api.UserProvisioningManager;
 import 
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -163,7 +163,7 @@ public class WebSecurityContext {
             final ConnectorManager connectorManager,
             final AuditManager auditManager,
             final MappingManager mappingManager,
-            final ImplementationLookup implementationLookup) {
+            final List<JWTSSOProvider> jwtSSOProviders) {
 
         return new AuthDataAccessor(
                 securityProperties,
@@ -178,6 +178,6 @@ public class WebSecurityContext {
                 connectorManager,
                 auditManager,
                 mappingManager,
-                implementationLookup);
+                jwtSSOProviders);
     }
 }
diff --git 
a/core/spring/src/test/java/org/apache/syncope/core/spring/security/DummyImplementationLookup.java
 
b/core/spring/src/test/java/org/apache/syncope/core/spring/security/DummyImplementationLookup.java
index 6ee74c934c..ae67678cc0 100644
--- 
a/core/spring/src/test/java/org/apache/syncope/core/spring/security/DummyImplementationLookup.java
+++ 
b/core/spring/src/test/java/org/apache/syncope/core/spring/security/DummyImplementationLookup.java
@@ -43,11 +43,6 @@ public class DummyImplementationLookup implements 
ImplementationLookup {
         return Set.of();
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return Set.of();
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return null;
diff --git 
a/core/workflow-java/src/test/java/org/apache/syncope/core/workflow/java/DummyImplementationLookup.java
 
b/core/workflow-java/src/test/java/org/apache/syncope/core/workflow/java/DummyImplementationLookup.java
index fc82c8ef1e..a43e9e95cf 100644
--- 
a/core/workflow-java/src/test/java/org/apache/syncope/core/workflow/java/DummyImplementationLookup.java
+++ 
b/core/workflow-java/src/test/java/org/apache/syncope/core/workflow/java/DummyImplementationLookup.java
@@ -45,11 +45,6 @@ public class DummyImplementationLookup implements 
ImplementationLookup {
         return Set.of();
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return Set.of();
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return null;
diff --git 
a/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/SAML2SP4UILogic.java
 
b/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/SAML2SP4UILogic.java
index 985ec78ae5..ea635aeca9 100644
--- 
a/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/SAML2SP4UILogic.java
+++ 
b/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/SAML2SP4UILogic.java
@@ -273,10 +273,8 @@ public class SAML2SP4UILogic extends 
AbstractSAML2SP4UILogic {
             final String idpEntityID) {
 
         // 0. look for IdP
-        SAML2SP4UIIdP idp = idpDAO.findByEntityID(idpEntityID);
-        if (idp == null) {
-            throw new NotFoundException("SAML 2.0 IdP '" + idpEntityID + '\'');
-        }
+        SAML2SP4UIIdP idp = 
Optional.ofNullable(idpDAO.findByEntityID(idpEntityID)).
+                orElseThrow(() -> new NotFoundException("SAML 2.0 IdP '" + 
idpEntityID + '\''));
 
         // 1. look for configured client
         SAML2Client saml2Client = getSAML2Client(saml2ClientCacheLogin, idp, 
spEntityID, urlContext);
@@ -516,10 +514,9 @@ public class SAML2SP4UILogic extends 
AbstractSAML2SP4UILogic {
                 saml2Response.getSpEntityID(),
                 saml2Response.getUrlContext());
 
-        SAML2SP4UIIdP idp = 
idpDAO.findByEntityID(saml2Client.getIdentityProviderResolvedEntityId());
-        if (idp == null) {
-            throw new NotFoundException("SAML 2.0 IdP '" + 
saml2Client.getIdentityProviderResolvedEntityId() + '\'');
-        }
+        
Optional.ofNullable(idpDAO.findByEntityID(saml2Client.getIdentityProviderResolvedEntityId())).
+                orElseThrow(() -> new NotFoundException(
+                "SAML 2.0 IdP '" + 
saml2Client.getIdentityProviderResolvedEntityId() + '\''));
 
         // 2. validate the provided SAML response
         SAML2SP4UIContext ctx = new SAML2SP4UIContext(
diff --git 
a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CoreReferenceContext.java
 
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CoreReferenceContext.java
index e0ca9c5a12..6cb5409ae1 100644
--- 
a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CoreReferenceContext.java
+++ 
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CoreReferenceContext.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.fit.core.reference;
 
+import com.nimbusds.jose.JOSEException;
 import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.core.logic.IdRepoLogicContext;
 import org.apache.syncope.core.logic.TaskLogic;
@@ -27,11 +28,13 @@ import 
org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.provisioning.api.ImplementationLookup;
+import org.apache.syncope.core.spring.security.AuthDataAccessor;
 import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
 import org.springframework.boot.autoconfigure.AutoConfigureBefore;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
 
 @AutoConfigureBefore(IdRepoLogicContext.class)
 @ComponentScan("org.apache.syncope.fit.core.reference")
@@ -82,4 +85,12 @@ public class CoreReferenceContext {
     public AuditAppender testFileRewriteAuditAppender() {
         return new 
TestFileRewriteAuditAppender(SyncopeConstants.MASTER_DOMAIN);
     }
+
+    @Bean
+    public CustomJWTSSOProvider customJWTSSOProvider(
+            final AnySearchDAO anySearchDAO,
+            final @Lazy AuthDataAccessor authDataAccessor) throws 
JOSEException {
+
+        return new CustomJWTSSOProvider(anySearchDAO, authDataAccessor);
+    }
 }
diff --git 
a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CustomJWTSSOProvider.java
 
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CustomJWTSSOProvider.java
index 891cd63414..03ab3e354d 100644
--- 
a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CustomJWTSSOProvider.java
+++ 
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/CustomJWTSSOProvider.java
@@ -37,7 +37,6 @@ import 
org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.spring.security.AuthDataAccessor;
 import org.apache.syncope.core.spring.security.JWTSSOProvider;
 import org.apache.syncope.core.spring.security.SyncopeGrantedAuthority;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -56,14 +55,18 @@ public class CustomJWTSSOProvider implements JWTSSOProvider 
{
 
     private final JWSVerifier delegate;
 
-    @Autowired
-    private AnySearchDAO searchDAO;
+    private final AnySearchDAO anySearchDAO;
 
-    @Autowired
-    private AuthDataAccessor authDataAccessor;
+    private final AuthDataAccessor authDataAccessor;
 
-    public CustomJWTSSOProvider() throws JOSEException {
-        delegate = new MACVerifier(CUSTOM_KEY);
+    public CustomJWTSSOProvider(
+            final AnySearchDAO anySearchDAO,
+            final AuthDataAccessor authDataAccessor)
+            throws JOSEException {
+
+        this.delegate = new MACVerifier(CUSTOM_KEY);
+        this.anySearchDAO = anySearchDAO;
+        this.authDataAccessor = authDataAccessor;
     }
 
     @Override
@@ -98,7 +101,7 @@ public class CustomJWTSSOProvider implements JWTSSOProvider {
         userIdCond.setType(AttrCond.Type.EQ);
         userIdCond.setExpression(jwtClaims.getSubject());
 
-        List<User> matching = searchDAO.search(SearchCond.getLeaf(userIdCond), 
AnyTypeKind.USER);
+        List<User> matching = 
anySearchDAO.search(SearchCond.getLeaf(userIdCond), AnyTypeKind.USER);
         if (matching.size() == 1) {
             User user = matching.get(0);
             Set<SyncopeGrantedAuthority> authorities = 
authDataAccessor.getAuthorities(user.getUsername(), null);
diff --git 
a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
 
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
index 196db1df6a..dd7c2e8ff2 100644
--- 
a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
+++ 
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
@@ -67,10 +67,7 @@ import 
org.apache.syncope.core.spring.policy.DefaultAccountRule;
 import org.apache.syncope.core.spring.policy.DefaultPasswordRule;
 import org.apache.syncope.core.spring.policy.HaveIBeenPwnedPasswordRule;
 import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.apache.syncope.core.spring.security.SyncopeJWTSSOProvider;
 import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.aop.support.AopUtils;
 
 /**
@@ -78,11 +75,6 @@ import org.springframework.aop.support.AopUtils;
  */
 public class ITImplementationLookup implements ImplementationLookup {
 
-    private static final Logger LOG = 
LoggerFactory.getLogger(ITImplementationLookup.class);
-
-    private static final Set<Class<?>> JWTSSOPROVIDER_CLASSES =
-            Set.of(SyncopeJWTSSOProvider.class, CustomJWTSSOProvider.class);
-
     private static final Map<Class<? extends ReportConf>, Class<? extends 
ReportJobDelegate>> REPORT_CLASSES =
             Map.of(SampleReportConf.class, SampleReportJobDelegate.class);
 
@@ -121,11 +113,7 @@ public class ITImplementationLookup implements 
ImplementationLookup {
         private static final long serialVersionUID = 3109256773218160485L;
 
         {
-            Set<String> classNames = 
ITImplementationLookup.JWTSSOPROVIDER_CLASSES.stream().
-                    map(Class::getName).collect(Collectors.toSet());
-            put(IdRepoImplementationType.JWT_SSO_PROVIDER, classNames);
-
-            classNames = new HashSet<>();
+            Set<String> classNames = new HashSet<>();
             classNames.add(SampleReportJobDelegate.class.getName());
             put(IdRepoImplementationType.REPORT_DELEGATE, classNames);
 
@@ -265,11 +253,6 @@ public class ITImplementationLookup implements 
ImplementationLookup {
         return CLASS_NAMES.get(type);
     }
 
-    @Override
-    public Set<Class<?>> getJWTSSOProviderClasses() {
-        return JWTSSOPROVIDER_CLASSES;
-    }
-
     @Override
     public Class<? extends ReportJobDelegate> getReportClass(final Class<? 
extends ReportConf> reportConfClass) {
         return REPORT_CLASSES.get(reportConfClass);

Reply via email to