You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2023/02/01 14:45:47 UTC

[syncope] branch master updated (7388f21987 -> 51cf43262f)

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

ilgrosso pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


    from 7388f21987 [SYNCOPE-1723] Removing static paths from generated artifacts (#405) (#406)
     new eaad1f0f2a [SYNCOPE-1726] Ensuring Core and calling WA instance are both available in Keymaster before refreshing
     new 0026b41a6b Allowing override
     new 55c86c4bbe Upgrading Elasticsearch
     new 185c9ff05f Allow to override modal window title with wizards
     new 51cf43262f Upgrading pac4j

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../console/panels/LinkedAccountModalPanel.java    | 130 ++++++++++-----------
 .../wizards/resources/ResourceProvisionPanel.java  |  26 ++---
 .../client/ui/commons/wizards/AjaxWizard.java      |  10 +-
 .../syncope/client/console/pages/Realms.java       |   2 +-
 .../console/tasks/SchedTaskDirectoryPanel.java     |   4 +-
 .../client/console/tasks/TemplatesTogglePanel.java |   2 +-
 .../client/console/wizards/WizardMgtPanel.java     |  26 +++--
 .../console/wizards/any/AnyObjectDetails.java      |   2 +-
 .../console/src/main/resources/console.properties  |   1 +
 .../src/test/resources/console-debug.properties    |   4 +-
 .../enduser/src/main/resources/enduser.properties  |   1 +
 .../syncope/common/lib/types/JWSAlgorithm.java     |  37 ------
 core/starter/src/main/resources/core.properties    |   1 +
 .../jpa/dao/ElasticsearchAnySearchDAO.java         |  11 +-
 .../panels/OIDCProvidersDirectoryPanel.java        |  18 +--
 .../apache/syncope/core/logic/OIDCC4UILogic.java   |   5 +-
 .../syncope/core/logic/oidc/OIDCClientCache.java   |  31 +++--
 .../console/panels/SAML2IdPsDirectoryPanel.java    |  26 ++---
 .../apache/syncope/core/logic/SAML2SP4UILogic.java | 104 +++++++++--------
 .../syncope/core/logic/saml2/SAML2ClientCache.java |  15 ++-
 .../core/logic/saml2/SAML2SP4UIContext.java        |  18 ++-
 fit/wa-reference/src/main/resources/log4j2.xml     |   3 +
 .../org/apache/syncope/fit/sra/SAML2SRAITCase.java |   3 +-
 .../apache/syncope/fit/ui/SAML2SP4UIITCase.java    |   3 +-
 pom.xml                                            |  12 +-
 .../org/apache/syncope/sra/SecurityConfig.java     |  15 ++-
 .../apache/syncope/sra/actuate/SRASessions.java    |  12 +-
 .../sra/security/pac4j/RedirectionActionUtils.java |  18 ++-
 .../security/saml2/SAML2AuthenticationToken.java   |  15 ++-
 .../saml2/SAML2LogoutResponseWebFilter.java        |  79 +++----------
 .../saml2/SAML2RequestServerLogoutHandler.java     |  10 +-
 .../security/saml2/SAML2SecurityConfigUtils.java   |   2 +-
 .../SAML2WebSsoAuthenticationRequestWebFilter.java |  17 ++-
 .../saml2/SAML2WebSsoAuthenticationWebFilter.java  |  30 ++---
 sra/src/main/resources/sra.properties              |   1 +
 .../wa/bootstrap/WABootstrapConfiguration.java     |   5 +-
 .../apache/syncope/wa/bootstrap/WARestClient.java  |  56 +++++----
 .../syncope/wa/starter/config/WAContext.java       |  80 ++++++++-----
 .../wa/starter/config/WARefreshContextJob.java     |   5 +-
 .../starter/oidc/WAOIDCJWKSGeneratorService.java   |   8 +-
 .../saml/idp/WASamlIdPCasEventListener.java        |  28 ++---
 ...erator.java => WASamlIdPMetadataGenerator.java} |  48 +++++---
 ...aLocator.java => WASamlIdPMetadataLocator.java} |  35 +++---
 .../wa/starter/services/WAServiceRegistry.java     |  20 ++--
 .../WASurrogateAuthenticationService.java          |   2 +-
 .../wa/starter/u2f/WAU2FDeviceRepository.java      |   2 +-
 .../webauthn/WAWebAuthnCredentialRepository.java   |   2 +-
 wa/starter/src/main/resources/wa.properties        |   1 +
 48 files changed, 485 insertions(+), 501 deletions(-)
 delete mode 100644 common/am/lib/src/main/java/org/apache/syncope/common/lib/types/JWSAlgorithm.java
 copy client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/status/Status.java => wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/WASamlIdPCasEventListener.java (63%)
 rename wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/{RestfulSamlIdPMetadataGenerator.java => WASamlIdPMetadataGenerator.java} (77%)
 rename wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/{RestfulSamlIdPMetadataLocator.java => WASamlIdPMetadataLocator.java} (84%)


[syncope] 03/05: Upgrading Elasticsearch

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 55c86c4bbe8f1a2739712a8bb17fe8a2c99c267e
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Jan 27 08:55:08 2023 +0100

    Upgrading Elasticsearch
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index fe0dcf95a9..94901713ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -428,7 +428,7 @@ under the License.
     <flowable.version>7.0.0.M1</flowable.version>
     <flowable-old.version>6.8.0</flowable-old.version>
 
-    <elasticsearch.version>8.6.0</elasticsearch.version>
+    <elasticsearch.version>8.6.1</elasticsearch.version>
 
     <disruptor.version>3.4.4</disruptor.version>
     


[syncope] 01/05: [SYNCOPE-1726] Ensuring Core and calling WA instance are both available in Keymaster before refreshing

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit eaad1f0f2a3a38bef705f917bd0014f758f701f7
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Jan 25 08:36:28 2023 +0100

    [SYNCOPE-1726] Ensuring Core and calling WA instance are both available in Keymaster before refreshing
---
 .../jpa/dao/ElasticsearchAnySearchDAO.java         | 11 ++---
 pom.xml                                            |  4 +-
 .../apache/syncope/sra/actuate/SRASessions.java    | 12 ++---
 .../wa/bootstrap/WABootstrapConfiguration.java     |  5 +-
 .../apache/syncope/wa/bootstrap/WARestClient.java  | 56 +++++++++++++---------
 .../wa/starter/config/WARefreshContextJob.java     |  5 +-
 .../starter/oidc/WAOIDCJWKSGeneratorService.java   |  8 ++--
 .../metadata/RestfulSamlIdPMetadataGenerator.java  | 10 ++--
 .../metadata/RestfulSamlIdPMetadataLocator.java    | 10 ++--
 .../WASurrogateAuthenticationService.java          |  2 +-
 .../wa/starter/u2f/WAU2FDeviceRepository.java      |  2 +-
 .../webauthn/WAWebAuthnCredentialRepository.java   |  2 +-
 12 files changed, 70 insertions(+), 57 deletions(-)

diff --git a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
index 8fe9dd4388..67681a51c6 100644
--- a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
+++ b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
@@ -394,14 +394,9 @@ public class ElasticsearchAnySearchDAO extends AbstractAnySearchDAO {
                 }
 
                 if (query == null) {
-                    Optional<AnyCond> anyCond = cond.getLeaf(AnyCond.class);
-                    if (anyCond.isPresent()) {
-                        query = getQuery(anyCond.get(), kind);
-                    } else {
-                        query = cond.getLeaf(AttrCond.class).
-                                map(leaf -> getQuery(leaf, kind)).
-                                orElse(null);
-                    }
+                    query = cond.getLeaf(AnyCond.class).map(ac -> getQuery(ac, kind)).
+                            or(() -> cond.getLeaf(AttrCond.class).map(ac -> getQuery(ac, kind))).
+                            orElse(null);
                 }
 
                 // allow for additional search conditions
diff --git a/pom.xml b/pom.xml
index ead40c69c5..fe0dcf95a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -413,7 +413,7 @@ under the License.
 
     <cxf.version>4.0.0</cxf.version>
     <bouncycastle.version>1.72</bouncycastle.version>
-    <nimbus-jose-jwt.version>9.28</nimbus-jose-jwt.version>
+    <nimbus-jose-jwt.version>9.29</nimbus-jose-jwt.version>
 
     <spring-boot.version>3.0.2</spring-boot.version>
     <spring-cloud-gateway.version>4.0.0</spring-cloud-gateway.version>
@@ -1488,7 +1488,7 @@ under the License.
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-dependency-plugin</artifactId>
-          <version>3.3.0</version>
+          <version>3.5.0</version>
           <configuration>
             <outputDirectory>${bundles.directory}</outputDirectory>
             <artifactItems>
diff --git a/sra/src/main/java/org/apache/syncope/sra/actuate/SRASessions.java b/sra/src/main/java/org/apache/syncope/sra/actuate/SRASessions.java
index a56e8f0b8b..db42addb11 100644
--- a/sra/src/main/java/org/apache/syncope/sra/actuate/SRASessions.java
+++ b/sra/src/main/java/org/apache/syncope/sra/actuate/SRASessions.java
@@ -67,12 +67,12 @@ public class SRASessions {
         session.setAuthenticationDate(mapSession.getCreationTime().atOffset(OffsetDateTime.now().getOffset()));
 
         String principal;
-        if (ctx.getAuthentication() instanceof SAML2AuthenticationToken) {
-            principal = ((SAML2AuthenticationToken) ctx.getAuthentication()).getPrincipal().getNameId().getValue();
-        } else if (ctx.getAuthentication() instanceof CASAuthenticationToken) {
-            principal = ((CASAuthenticationToken) ctx.getAuthentication()).getPrincipal().getPrincipal().getName();
-        } else if (ctx.getAuthentication() instanceof OAuth2AuthenticationToken) {
-            principal = ((OAuth2AuthenticationToken) ctx.getAuthentication()).getPrincipal().getName();
+        if (ctx.getAuthentication() instanceof SAML2AuthenticationToken saml2AuthenticationToken) {
+            principal = saml2AuthenticationToken.getPrincipal().getUserProfile().getUsername();
+        } else if (ctx.getAuthentication() instanceof CASAuthenticationToken casAuthenticationToken) {
+            principal = casAuthenticationToken.getPrincipal().getPrincipal().getName();
+        } else if (ctx.getAuthentication() instanceof OAuth2AuthenticationToken oauth2AuthenticationToken) {
+            principal = oauth2AuthenticationToken.getPrincipal().getName();
         } else {
             principal = ctx.getAuthentication().getPrincipal().toString();
         }
diff --git a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
index 8c505bd3c4..2215b28130 100644
--- a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
+++ b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
@@ -42,9 +42,12 @@ public class WABootstrapConfiguration {
         @Value("${wa.useGZIPCompression:true}")
         private boolean useGZIPCompression;
 
+        @Value("${service.discovery.address}")
+        private String serviceDiscoveryAddress;
+
         @Bean
         public WARestClient waRestClient() {
-            return new WARestClient(anonymousUser, anonymousKey, useGZIPCompression);
+            return new WARestClient(anonymousUser, anonymousKey, useGZIPCompression, serviceDiscoveryAddress);
         }
     }
 
diff --git a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WARestClient.java b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WARestClient.java
index 0cfcd9ae3e..7d71da2e59 100644
--- a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WARestClient.java
+++ b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WARestClient.java
@@ -41,16 +41,47 @@ public class WARestClient {
 
     private final boolean useGZIPCompression;
 
+    private final String serviceDiscoveryAddress;
+
     private SyncopeClient client;
 
     public WARestClient(
             final String anonymousUser,
             final String anonymousKey,
-            final boolean useGZIPCompression) {
+            final boolean useGZIPCompression,
+            final String serviceDiscoveryAddress) {
 
         this.anonymousUser = anonymousUser;
         this.anonymousKey = anonymousKey;
         this.useGZIPCompression = useGZIPCompression;
+        this.serviceDiscoveryAddress = serviceDiscoveryAddress;
+    }
+
+    private Optional<NetworkService> getCore() {
+        try {
+            ApplicationContext context = ApplicationContextProvider.getApplicationContext();
+            if (context == null) {
+                return Optional.empty();
+            }
+
+            Collection<ServiceOps> serviceOpsList = context.getBeansOfType(ServiceOps.class).values();
+            if (serviceOpsList.isEmpty()) {
+                return Optional.empty();
+            }
+
+            ServiceOps serviceOps = serviceOpsList.iterator().next();
+
+            if (serviceOps.list(NetworkService.Type.WA).
+                    stream().anyMatch(s -> s.getAddress().equals(serviceDiscoveryAddress))) {
+
+                return Optional.of(serviceOps.get(NetworkService.Type.CORE));
+            }
+
+            return Optional.empty();
+        } catch (KeymasterException e) {
+            LOG.trace(e.getMessage());
+        }
+        return Optional.empty();
     }
 
     public SyncopeClient getSyncopeClient() {
@@ -72,30 +103,11 @@ public class WARestClient {
         }
     }
 
-    private static Optional<NetworkService> getCore() {
-        try {
-            ApplicationContext context = ApplicationContextProvider.getApplicationContext();
-            if (context == null) {
-                return Optional.empty();
-            }
-
-            Collection<ServiceOps> serviceOpsList = context.getBeansOfType(ServiceOps.class).values();
-            if (serviceOpsList.isEmpty()) {
-                return Optional.empty();
-            }
-            ServiceOps serviceOps = serviceOpsList.iterator().next();
-            return Optional.of(serviceOps.get(NetworkService.Type.CORE));
-        } catch (KeymasterException e) {
-            LOG.trace(e.getMessage());
-        }
-        return Optional.empty();
-    }
-
-    public static boolean isReady() {
+    public boolean isReady() {
         try {
             return getCore().isPresent();
         } catch (Exception e) {
-            LOG.trace(e.getMessage());
+            LOG.trace("While checking Core's availability: {}", e.getMessage());
         }
         return false;
     }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WARefreshContextJob.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WARefreshContextJob.java
index bca830d3de..06a7203064 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WARefreshContextJob.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WARefreshContextJob.java
@@ -36,6 +36,9 @@ public class WARefreshContextJob implements Job {
 
     private static final Logger LOG = LoggerFactory.getLogger(WARefreshContextJob.class);
 
+    @Autowired
+    private WARestClient waRestClient;
+
     @Autowired
     private ContextRefresher contextRefresher;
 
@@ -46,7 +49,7 @@ public class WARefreshContextJob implements Job {
     public void execute(final JobExecutionContext jobExecutionContext) throws JobExecutionException {
         try {
             LOG.debug("Attempting to refresh WA application context");
-            if (!WARestClient.isReady()) {
+            if (!waRestClient.isReady()) {
                 LOG.debug("Syncope client is not yet ready");
                 throw new IllegalStateException("Syncope core is not yet ready to access requests");
             }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/oidc/WAOIDCJWKSGeneratorService.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/oidc/WAOIDCJWKSGeneratorService.java
index 492485cac6..bfa6865ea1 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/oidc/WAOIDCJWKSGeneratorService.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/oidc/WAOIDCJWKSGeneratorService.java
@@ -47,12 +47,12 @@ public class WAOIDCJWKSGeneratorService implements OidcJsonWebKeystoreGeneratorS
     protected final int jwksKeySize;
 
     public WAOIDCJWKSGeneratorService(
-            final WARestClient restClient,
+            final WARestClient waRestClient,
             final String jwksKeyId,
             final String jwksType,
             final int jwksKeySize) {
 
-        this.waRestClient = restClient;
+        this.waRestClient = waRestClient;
         this.jwksKeyId = jwksKeyId;
         this.jwksType = jwksType;
         this.jwksKeySize = jwksKeySize;
@@ -60,7 +60,7 @@ public class WAOIDCJWKSGeneratorService implements OidcJsonWebKeystoreGeneratorS
 
     @Override
     public JsonWebKeySet store(final JsonWebKeySet jsonWebKeySet) throws Exception {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             throw new IllegalStateException("Syncope core is not yet ready");
         }
         OIDCJWKSService service = waRestClient.getSyncopeClient().getService(OIDCJWKSService.class);
@@ -77,7 +77,7 @@ public class WAOIDCJWKSGeneratorService implements OidcJsonWebKeystoreGeneratorS
 
     @Override
     public Resource generate() {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             throw new IllegalStateException("Syncope core is not yet ready");
         }
 
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java
index 0b8cdb6efc..2161f118ce 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java
@@ -37,14 +37,14 @@ public class RestfulSamlIdPMetadataGenerator extends BaseSamlIdPMetadataGenerato
 
     private static final Logger LOG = LoggerFactory.getLogger(RestfulSamlIdPMetadataGenerator.class);
 
-    private final WARestClient restClient;
+    private final WARestClient waRestClient;
 
     public RestfulSamlIdPMetadataGenerator(
             final SamlIdPMetadataGeneratorConfigurationContext samlIdPMetadataGeneratorConfigurationContext,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
         super(samlIdPMetadataGeneratorConfigurationContext);
-        this.restClient = restClient;
+        this.waRestClient = waRestClient;
     }
 
     @Override
@@ -97,10 +97,10 @@ public class RestfulSamlIdPMetadataGenerator extends BaseSamlIdPMetadataGenerato
     }
 
     private SyncopeClient getSyncopeClient() {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             LOG.info("Syncope client is not yet ready");
             throw new IllegalStateException("Syncope core is not yet ready to access requests");
         }
-        return restClient.getSyncopeClient();
+        return waRestClient.getSyncopeClient();
     }
 }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java
index b66b2cade8..71c8fa1d5e 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java
@@ -39,15 +39,15 @@ public class RestfulSamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocato
 
     private static final Logger LOG = LoggerFactory.getLogger(RestfulSamlIdPMetadataLocator.class);
 
-    private final WARestClient restClient;
+    private final WARestClient waRestClient;
 
     public RestfulSamlIdPMetadataLocator(
             final CipherExecutor<String, String> metadataCipherExecutor,
             final Cache<String, SamlIdPMetadataDocument> metadataCache,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
         super(metadataCipherExecutor, metadataCache);
-        this.restClient = restClient;
+        this.waRestClient = waRestClient;
     }
 
     @Override
@@ -122,10 +122,10 @@ public class RestfulSamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocato
     }
 
     private SyncopeClient getSyncopeClient() {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             LOG.info("Syncope client is not yet ready");
             throw new IllegalStateException("Syncope core is not yet ready to access requests");
         }
-        return restClient.getSyncopeClient();
+        return waRestClient.getSyncopeClient();
     }
 }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/surrogate/WASurrogateAuthenticationService.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/surrogate/WASurrogateAuthenticationService.java
index ad4c0833f2..0c44fb9f25 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/surrogate/WASurrogateAuthenticationService.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/surrogate/WASurrogateAuthenticationService.java
@@ -63,7 +63,7 @@ public class WASurrogateAuthenticationService implements SurrogateAuthentication
     }
 
     private ImpersonationService getImpersonationService() {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             throw new IllegalStateException("Syncope core is not yet ready");
         }
         return waRestClient.getSyncopeClient().getService(ImpersonationService.class);
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/u2f/WAU2FDeviceRepository.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/u2f/WAU2FDeviceRepository.java
index a66a196246..6210ca349e 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/u2f/WAU2FDeviceRepository.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/u2f/WAU2FDeviceRepository.java
@@ -133,7 +133,7 @@ public class WAU2FDeviceRepository extends BaseU2FDeviceRepository {
     }
 
     private U2FRegistrationService getU2FService() {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             throw new IllegalStateException("Syncope core is not yet ready");
         }
         return waRestClient.getSyncopeClient().getService(U2FRegistrationService.class);
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/webauthn/WAWebAuthnCredentialRepository.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/webauthn/WAWebAuthnCredentialRepository.java
index d62ffe218b..6b3e8ac2f2 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/webauthn/WAWebAuthnCredentialRepository.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/webauthn/WAWebAuthnCredentialRepository.java
@@ -128,7 +128,7 @@ public class WAWebAuthnCredentialRepository extends BaseWebAuthnCredentialReposi
     }
 
     private WebAuthnRegistrationService getService() {
-        if (!WARestClient.isReady()) {
+        if (!waRestClient.isReady()) {
             throw new IllegalStateException("Syncope core is not yet ready");
         }
         return waRestClient.getSyncopeClient().getService(WebAuthnRegistrationService.class);


[syncope] 05/05: Upgrading pac4j

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 51cf43262f79775228a439ae336c04598269af04
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Jan 27 11:09:44 2023 +0100

    Upgrading pac4j
---
 .../console/src/main/resources/console.properties  |   1 +
 .../src/test/resources/console-debug.properties    |   4 +-
 .../enduser/src/main/resources/enduser.properties  |   1 +
 core/starter/src/main/resources/core.properties    |   1 +
 .../apache/syncope/core/logic/OIDCC4UILogic.java   |   5 +-
 .../syncope/core/logic/oidc/OIDCClientCache.java   |  31 +++---
 .../apache/syncope/core/logic/SAML2SP4UILogic.java | 104 +++++++++++----------
 .../syncope/core/logic/saml2/SAML2ClientCache.java |  15 ++-
 .../core/logic/saml2/SAML2SP4UIContext.java        |  18 ++--
 fit/wa-reference/src/main/resources/log4j2.xml     |   3 +
 .../org/apache/syncope/fit/sra/SAML2SRAITCase.java |   3 +-
 .../apache/syncope/fit/ui/SAML2SP4UIITCase.java    |   3 +-
 pom.xml                                            |   6 +-
 .../org/apache/syncope/sra/SecurityConfig.java     |  15 ++-
 .../sra/security/pac4j/RedirectionActionUtils.java |  18 ++--
 .../security/saml2/SAML2AuthenticationToken.java   |  15 +--
 .../saml2/SAML2LogoutResponseWebFilter.java        |  79 +++-------------
 .../saml2/SAML2RequestServerLogoutHandler.java     |  10 +-
 .../security/saml2/SAML2SecurityConfigUtils.java   |   2 +-
 .../SAML2WebSsoAuthenticationRequestWebFilter.java |  17 +++-
 .../saml2/SAML2WebSsoAuthenticationWebFilter.java  |  30 +++---
 sra/src/main/resources/sra.properties              |   1 +
 .../syncope/wa/starter/config/WAContext.java       |  80 ++++++++++------
 .../saml/idp/WASamlIdPCasEventListener.java        |  26 ++----
 ...erator.java => WASamlIdPMetadataGenerator.java} |  42 ++++++---
 ...aLocator.java => WASamlIdPMetadataLocator.java} |  25 +++--
 .../wa/starter/services/WAServiceRegistry.java     |  20 ++--
 wa/starter/src/main/resources/wa.properties        |   1 +
 28 files changed, 295 insertions(+), 281 deletions(-)

diff --git a/client/idrepo/console/src/main/resources/console.properties b/client/idrepo/console/src/main/resources/console.properties
index 44dbf8186d..173d5e5aa4 100644
--- a/client/idrepo/console/src/main/resources/console.properties
+++ b/client/idrepo/console/src/main/resources/console.properties
@@ -27,6 +27,7 @@ server.servlet.contextPath=/syncope-console
 
 management.endpoints.web.exposure.include=info,health,loggers
 management.endpoint.health.show-details=ALWAYS
+management.endpoint.env.show-values=WHEN_AUTHORIZED
 
 service.discovery.address=http://localhost:8080/syncope-console/
 
diff --git a/client/idrepo/console/src/test/resources/console-debug.properties b/client/idrepo/console/src/test/resources/console-debug.properties
index 8472125348..d41b7337e0 100644
--- a/client/idrepo/console/src/test/resources/console-debug.properties
+++ b/client/idrepo/console/src/test/resources/console-debug.properties
@@ -14,8 +14,8 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-keymaster.address=http://localhost:9080/syncope/rest/keymaster
-#keymaster.address=https://localhost:9443/syncope/rest/keymaster
+#keymaster.address=http://localhost:9080/syncope/rest/keymaster
+keymaster.address=https://localhost:9443/syncope/rest/keymaster
 keymaster.username=${anonymousUser}
 keymaster.password=${anonymousKey}
 
diff --git a/client/idrepo/enduser/src/main/resources/enduser.properties b/client/idrepo/enduser/src/main/resources/enduser.properties
index cf0af9ccc8..c7296757c3 100644
--- a/client/idrepo/enduser/src/main/resources/enduser.properties
+++ b/client/idrepo/enduser/src/main/resources/enduser.properties
@@ -27,6 +27,7 @@ server.servlet.contextPath=/syncope-enduser
 
 management.endpoints.web.exposure.include=info,health,loggers
 management.endpoint.health.show-details=ALWAYS
+management.endpoint.env.show-values=WHEN_AUTHORIZED
 
 service.discovery.address=http://localhost:8080/syncope-enduser/
 
diff --git a/core/starter/src/main/resources/core.properties b/core/starter/src/main/resources/core.properties
index 933aed4181..f75601eef6 100644
--- a/core/starter/src/main/resources/core.properties
+++ b/core/starter/src/main/resources/core.properties
@@ -29,6 +29,7 @@ cxf.path=/rest
 
 management.endpoints.web.exposure.include=health,info,loggers,entityCache
 management.endpoint.health.show-details=ALWAYS
+management.endpoint.env.show-values=WHEN_AUTHORIZED
 
 service.discovery.address=http://localhost:8080/syncope/rest/
 
diff --git a/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/OIDCC4UILogic.java b/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/OIDCC4UILogic.java
index 24fe4b0ee7..d3b5fb72bc 100644
--- a/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/OIDCC4UILogic.java
+++ b/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/OIDCC4UILogic.java
@@ -54,7 +54,6 @@ import org.apache.syncope.core.spring.security.AuthDataAccessor;
 import org.apache.syncope.core.spring.security.Encryptor;
 import org.pac4j.core.context.CallContext;
 import org.pac4j.core.exception.http.WithLocationAction;
-import org.pac4j.core.profile.factory.ProfileManagerFactory;
 import org.pac4j.oidc.client.OidcClient;
 import org.pac4j.oidc.credentials.OidcCredentials;
 import org.pac4j.oidc.profile.OidcProfile;
@@ -113,7 +112,7 @@ public class OIDCC4UILogic extends AbstractTransactionalLogic<EntityTO> {
 
         // 2. create OIDCRequest
         WithLocationAction action = oidcClient.getRedirectionAction(
-                new CallContext(new OIDC4UIContext(), NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT)).
+                new CallContext(new OIDC4UIContext(), NoOpSessionStore.INSTANCE)).
                 map(WithLocationAction.class::cast).
                 orElseThrow(() -> {
                     SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
@@ -275,7 +274,7 @@ public class OIDCC4UILogic extends AbstractTransactionalLogic<EntityTO> {
         profile.setIdTokenString((String) claimsSet.getClaim(JWT_CLAIM_ID_TOKEN));
 
         WithLocationAction action = oidcClient.getLogoutAction(
-                new CallContext(new OIDC4UIContext(), NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT),
+                new CallContext(new OIDC4UIContext(), NoOpSessionStore.INSTANCE),
                 profile,
                 redirectURI).
                 map(WithLocationAction.class::cast).
diff --git a/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/oidc/OIDCClientCache.java b/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/oidc/OIDCClientCache.java
index 4304e677dd..19ea7c3ab6 100644
--- a/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/oidc/OIDCClientCache.java
+++ b/ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/oidc/OIDCClientCache.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.logic.oidc;
 
+import com.nimbusds.jose.JWSAlgorithm;
 import com.nimbusds.oauth2.sdk.ParseException;
 import com.nimbusds.oauth2.sdk.id.Issuer;
 import com.nimbusds.openid.connect.sdk.SubjectType;
@@ -31,6 +32,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+import java.util.function.Function;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.OIDCC4UIProviderTO;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
@@ -38,6 +40,7 @@ import org.apache.syncope.core.persistence.api.entity.OIDCC4UIProvider;
 import org.pac4j.core.http.callback.NoParameterCallbackUrlResolver;
 import org.pac4j.oidc.client.OidcClient;
 import org.pac4j.oidc.config.OidcConfiguration;
+import org.pac4j.oidc.metadata.StaticOidcOpMetadataResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,18 +51,21 @@ public class OIDCClientCache {
 
     protected static final Logger LOG = LoggerFactory.getLogger(OIDCClientCache.class);
 
+    protected static final Function<String, String> DISCOVERY_URI =
+            issuer -> issuer + "/.well-known/openid-configuration";
+
     protected final List<OidcClient> cache = Collections.synchronizedList(new ArrayList<>());
 
     protected static OIDCProviderMetadata getDiscoveryDocument(final String issuer) {
-        String discoveryDocumentURL = issuer + "/.well-known/openid-configuration";
+        String discoveryDocumentURI = DISCOVERY_URI.apply(issuer);
         try {
             HttpResponse<String> response = HttpClient.newBuilder().build().send(
-                    HttpRequest.newBuilder(URI.create(discoveryDocumentURL)).GET().build(),
+                    HttpRequest.newBuilder(URI.create(discoveryDocumentURI)).GET().build(),
                     HttpResponse.BodyHandlers.ofString());
 
             return OIDCProviderMetadata.parse(response.body());
         } catch (IOException | InterruptedException | ParseException e) {
-            LOG.error("While getting the Discovery Document at {}", discoveryDocumentURL, e);
+            LOG.error("While getting the Discovery Document at {}", discoveryDocumentURI, e);
 
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
             sce.getElements().add(e.getMessage());
@@ -93,6 +99,7 @@ public class OIDCClientCache {
                 new Issuer(op.getIssuer()),
                 List.of(SubjectType.PUBLIC),
                 Optional.ofNullable(op.getJwksUri()).map(URI::create).orElse(null));
+        metadata.setIDTokenJWSAlgs(List.of(JWSAlgorithm.HS256));
         metadata.setAuthorizationEndpointURI(
                 Optional.ofNullable(op.getAuthorizationEndpoint()).map(URI::create).orElse(null));
         metadata.setTokenEndpointURI(
@@ -102,15 +109,17 @@ public class OIDCClientCache {
         metadata.setEndSessionEndpointURI(
                 Optional.ofNullable(op.getEndSessionEndpoint()).map(URI::create).orElse(null));
 
-        OidcConfiguration config = new OidcConfiguration();
-        config.setClientId(op.getClientID());
-        config.setSecret(op.getClientSecret());
-        config.setProviderMetadata(metadata);
-        config.setScope("openid profile email address phone offline_access");
-        config.setUseNonce(false);
-        config.setSessionLogoutHandler(new NoOpSessionLogoutHandler());
+        OidcConfiguration cfg = new OidcConfiguration();
+        cfg.setClientId(op.getClientID());
+        cfg.setSecret(op.getClientSecret());
+        cfg.setDiscoveryURI(DISCOVERY_URI.apply(op.getIssuer()));
+        cfg.setPreferredJwsAlgorithm(JWSAlgorithm.HS256);
+        cfg.setOpMetadataResolver(new StaticOidcOpMetadataResolver(cfg, metadata));
+        cfg.setScope("openid profile email address phone offline_access");
+        cfg.setUseNonce(false);
+        cfg.setSessionLogoutHandler(new NoOpSessionLogoutHandler());
 
-        OidcClient client = new OidcClient(config);
+        OidcClient client = new OidcClient(cfg);
         client.setName(op.getName());
         client.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
         client.setCallbackUrl(callbackUrl);
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 264574b521..55d1d9598a 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
@@ -72,14 +72,15 @@ import org.opensaml.saml.saml2.metadata.AssertionConsumerService;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
 import org.opensaml.saml.saml2.metadata.impl.AssertionConsumerServiceBuilder;
 import org.pac4j.core.context.CallContext;
+import org.pac4j.core.credentials.Credentials;
 import org.pac4j.core.exception.http.RedirectionAction;
 import org.pac4j.core.exception.http.WithContentAction;
 import org.pac4j.core.exception.http.WithLocationAction;
 import org.pac4j.core.logout.NoLogoutActionBuilder;
-import org.pac4j.core.profile.factory.ProfileManagerFactory;
 import org.pac4j.saml.client.SAML2Client;
 import org.pac4j.saml.config.SAML2Configuration;
 import org.pac4j.saml.context.SAML2MessageContext;
+import org.pac4j.saml.credentials.SAML2AuthenticationCredentials;
 import org.pac4j.saml.credentials.SAML2Credentials;
 import org.pac4j.saml.credentials.authenticator.SAML2Authenticator;
 import org.pac4j.saml.metadata.SAML2ServiceProviderMetadataResolver;
@@ -102,6 +103,28 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
 
     protected static final Encryptor ENCRYPTOR = Encryptor.getInstance();
 
+    protected static String validateUrl(final String url) {
+        boolean isValid = true;
+        if (url.contains("..")) {
+            isValid = false;
+        }
+        if (isValid) {
+            isValid = ResourceUtils.isUrl(url);
+        }
+
+        if (!isValid) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
+            sce.getElements().add("Invalid URL: " + url);
+            throw sce;
+        }
+
+        return url;
+    }
+
+    protected static String getCallbackUrl(final String spEntityID, final String urlContext) {
+        return validateUrl(spEntityID + urlContext + "/assertion-consumer");
+    }
+
     protected final SAML2SP4UILoader loader;
 
     protected final AccessTokenDataBinder accessTokenDataBinder;
@@ -134,28 +157,6 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
         this.authDataAccessor = authDataAccessor;
     }
 
-    protected static String validateUrl(final String url) {
-        boolean isValid = true;
-        if (url.contains("..")) {
-            isValid = false;
-        }
-        if (isValid) {
-            isValid = ResourceUtils.isUrl(url);
-        }
-
-        if (!isValid) {
-            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
-            sce.getElements().add("Invalid URL: " + url);
-            throw sce;
-        }
-
-        return url;
-    }
-
-    protected static String getCallbackUrl(final String spEntityID, final String urlContext) {
-        return validateUrl(spEntityID + urlContext + "/assertion-consumer");
-    }
-
     @PreAuthorize("isAuthenticated()")
     public void getMetadata(final String spEntityID, final String urlContext, final OutputStream os) {
         String metadata = metadataCache.get(spEntityID + urlContext);
@@ -221,17 +222,13 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
         return getSAML2Client(idp, spEntityID, urlContext);
     }
 
-    protected static SAML2Request buildRequest(final String idpEntityID, final RedirectionAction action) {
+    protected SAML2Request buildRequest(final String idpEntityID, final RedirectionAction action) {
         SAML2Request requestTO = new SAML2Request();
         requestTO.setIdpEntityID(idpEntityID);
-        if (action instanceof WithLocationAction) {
-            WithLocationAction withLocationAction = (WithLocationAction) action;
-
+        if (action instanceof WithLocationAction withLocationAction) {
             requestTO.setBindingType(SAML2BindingType.REDIRECT);
             requestTO.setContent(withLocationAction.getLocation());
-        } else if (action instanceof WithContentAction) {
-            WithContentAction withContentAction = (WithContentAction) action;
-
+        } else if (action instanceof WithContentAction withContentAction) {
             requestTO.setBindingType(SAML2BindingType.POST);
             requestTO.setContent(Base64.getMimeEncoder().encodeToString(withContentAction.getContent().getBytes()));
         }
@@ -294,7 +291,7 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
                 saml2Client.getConfiguration().getAuthnRequestBindingType(),
                 null);
         RedirectionAction action = saml2Client.getRedirectionAction(
-                new CallContext(ctx, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT)).
+                new CallContext(ctx, NoOpSessionStore.INSTANCE)).
                 orElseThrow(() -> {
                     SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
                     sce.getElements().add("No RedirectionAction generated for AuthnRequest");
@@ -315,17 +312,20 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
         SAML2Client saml2Client = getSAML2Client(idp, saml2Response.getSpEntityID(), saml2Response.getUrlContext());
 
         // 2. validate the provided SAML response
-        SAML2Credentials credentials;
-        try {
-            SAML2SP4UIContext ctx = new SAML2SP4UIContext(
-                    saml2Client.getConfiguration().getAuthnRequestBindingType(),
-                    saml2Response);
+        SAML2SP4UIContext webCtx = new SAML2SP4UIContext(
+                saml2Client.getConfiguration().getAuthnRequestBindingType(),
+                saml2Response);
+        CallContext ctx = new CallContext(webCtx, NoOpSessionStore.INSTANCE);
 
-            credentials = (SAML2Credentials) saml2Client.getCredentialsExtractor().
-                    extract(new CallContext(ctx, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT)).
-                    orElseThrow(() -> new IllegalStateException("No AuthnResponse found"));
+        SAML2AuthenticationCredentials authCreds;
+        try {
+            Credentials creds = saml2Client.getCredentialsExtractor().
+                    extract(ctx).
+                    orElseThrow(() -> new IllegalStateException("Could not extract credentials"));
 
-            saml2Client.getAuthenticator().validate(new CallContext(ctx, NoOpSessionStore.INSTANCE), credentials);
+            authCreds = saml2Client.validateCredentials(ctx, creds).
+                    map(SAML2AuthenticationCredentials.class::cast).
+                    orElseThrow(() -> new IllegalArgumentException("Invalid SAML credentials provided"));
         } catch (Exception e) {
             LOG.error("While validating AuthnResponse", e);
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
@@ -338,7 +338,7 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
         loginResp.setIdp(saml2Client.getIdentityProviderResolvedEntityId());
         loginResp.setSloSupported(!(saml2Client.getLogoutActionBuilder() instanceof NoLogoutActionBuilder));
 
-        SAML2Credentials.SAMLNameID nameID = credentials.getNameId();
+        SAML2AuthenticationCredentials.SAMLNameID nameID = authCreds.getNameId();
 
         Item connObjectKeyItem = idp.getConnObjectKeyItem().orElse(null);
 
@@ -350,11 +350,11 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
             keyValue = nameID.getValue();
         }
 
-        loginResp.setNotOnOrAfter(new Date(credentials.getConditions().getNotOnOrAfter().toInstant().toEpochMilli()));
+        loginResp.setNotOnOrAfter(new Date(authCreds.getConditions().getNotOnOrAfter().toInstant().toEpochMilli()));
 
-        loginResp.setSessionIndex(credentials.getSessionIndex());
+        loginResp.setSessionIndex(authCreds.getSessionIndex());
 
-        for (SAML2Credentials.SAMLAttribute attr : credentials.getAttributes()) {
+        for (SAML2AuthenticationCredentials.SAMLAttribute attr : authCreds.getAttributes()) {
             if (!attr.getAttributeValues().isEmpty()) {
                 String attrName = attr.getFriendlyName() == null ? attr.getName() : attr.getFriendlyName();
                 if (connObjectKeyItem != null && attrName.equals(connObjectKeyItem.getExtAttrName())) {
@@ -477,7 +477,7 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
         SAML2SP4UIContext ctx = new SAML2SP4UIContext(
                 saml2Client.getConfiguration().getSpLogoutRequestBindingType(), null);
         RedirectionAction action = saml2Client.getLogoutAction(
-                new CallContext(ctx, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT),
+                new CallContext(ctx, NoOpSessionStore.INSTANCE),
                 saml2Profile,
                 null).
                 orElseThrow(() -> {
@@ -504,17 +504,19 @@ public class SAML2SP4UILogic extends AbstractTransactionalLogic<EntityTO> {
         }
 
         // 2. validate the provided SAML response
-        SAML2SP4UIContext ctx = new SAML2SP4UIContext(
-                saml2Client.getConfiguration().getSpLogoutRequestBindingType(),
+        SAML2SP4UIContext webCtx = new SAML2SP4UIContext(
+                saml2Client.getConfiguration().getAuthnRequestBindingType(),
                 saml2Response);
+        CallContext ctx = new CallContext(webCtx, NoOpSessionStore.INSTANCE);
 
         LogoutResponse logoutResponse;
         try {
-            SAML2MessageContext saml2Ctx = saml2Client.getContextProvider().buildContext(
-                    new CallContext(ctx, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT), saml2Client);
-            saml2Client.getLogoutProfileHandler().receive(saml2Ctx);
+            Credentials creds = saml2Client.getCredentialsExtractor().
+                    extract(ctx).
+                    orElseThrow(() -> new IllegalStateException("Could not extract credentials"));
 
-            logoutResponse = (LogoutResponse) saml2Ctx.getMessageContext().getMessage();
+            saml2Client.getLogoutProcessor().processLogout(ctx, creds);
+            logoutResponse = (LogoutResponse) ((SAML2Credentials) creds).getContext().getMessageContext().getMessage();
         } catch (Exception e) {
             LOG.error("Could not validate LogoutResponse", e);
             return;
diff --git a/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ClientCache.java b/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ClientCache.java
index 945d2587f6..15577bcc34 100644
--- a/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ClientCache.java
+++ b/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ClientCache.java
@@ -27,6 +27,7 @@ import java.util.Base64;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.syncope.common.lib.to.Item;
@@ -125,7 +126,19 @@ public class SAML2ClientCache {
     public SAML2Client add(
             final SAML2SP4UIIdP idp, final SAML2Configuration cfg, final String spEntityID, final String callbackUrl) {
 
-        cfg.setIdentityProviderMetadataResource((new ByteArrayResource(idp.getMetadata())));
+        cfg.setIdentityProviderEntityId(idp.getEntityID());
+        cfg.setIdentityProviderMetadataResource(new ByteArrayResource(idp.getMetadata()));
+        // remove when pac4j > 6.0.0-RC5 is available
+        cfg.setIdentityProviderMetadataResolver(new SAML2IdentityProviderMetadataResolver(cfg) {
+
+            private final AtomicBoolean hasChanged = new AtomicBoolean(true);
+
+            @Override
+            public boolean hasChanged() {
+                return hasChanged.getAndSet(false);
+            }
+        });
+
         cfg.setServiceProviderEntityId(spEntityID);
         getSPMetadataPath(spEntityID).ifPresent(cfg::setServiceProviderMetadataResourceFilepath);
 
diff --git a/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2SP4UIContext.java b/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2SP4UIContext.java
index 1722676508..834618401e 100644
--- a/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2SP4UIContext.java
+++ b/ext/saml2sp4ui/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2SP4UIContext.java
@@ -49,16 +49,14 @@ public class SAML2SP4UIContext implements WebContext {
 
     @Override
     public Optional<String> getRequestParameter(final String name) {
-        switch (name) {
-            case SAML2Constants.SAML_RESPONSE:
-                return Optional.ofNullable(saml2Response.getSamlResponse());
-
-            case SAML2Constants.RELAY_STATE:
-                return Optional.ofNullable(saml2Response.getRelayState());
-
-            default:
-                return Optional.empty();
-        }
+        return switch (name) {
+            case SAML2Constants.SAML_RESPONSE ->
+                Optional.ofNullable(saml2Response.getSamlResponse());
+            case SAML2Constants.RELAY_STATE ->
+                Optional.ofNullable(saml2Response.getRelayState());
+            default ->
+                Optional.empty();
+        };
     }
 
     @Override
diff --git a/fit/wa-reference/src/main/resources/log4j2.xml b/fit/wa-reference/src/main/resources/log4j2.xml
index 9254c8ecab..744d540e4c 100644
--- a/fit/wa-reference/src/main/resources/log4j2.xml
+++ b/fit/wa-reference/src/main/resources/log4j2.xml
@@ -39,6 +39,9 @@ under the License.
     <asyncLogger name="org.apereo.cas" additivity="false" level="INFO">
       <appender-ref ref="main"/>
     </asyncLogger>
+    <asyncLogger name="org.apereo.cas.support.saml.idp.metadata.generator" additivity="false" level="TRACE">
+      <appender-ref ref="main"/>
+    </asyncLogger>
 
     <asyncLogger name="org.apereo.services.persondir" additivity="false" level="INFO">
       <appender-ref ref="main"/>
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/SAML2SRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/SAML2SRAITCase.java
index b96be4d323..d99e689221 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/SAML2SRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/SAML2SRAITCase.java
@@ -180,8 +180,7 @@ public class SAML2SRAITCase extends AbstractSRAITCase {
             post.setEntity(new UrlEncodedFormEntity(form, Consts.UTF_8));
             try (CloseableHttpResponse response = httpclient.execute(post, context)) {
                 assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, response.getStatusLine().getStatusCode());
-                location = response.getFirstHeader(HttpHeaders.LOCATION).getValue().
-                        replace("http://", "https://").replace(":8080", ":9443");
+                location = response.getFirstHeader(HttpHeaders.LOCATION).getValue();
             }
         }
 
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/SAML2SP4UIITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/SAML2SP4UIITCase.java
index fd37e60a1c..b7a38a7ad1 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/SAML2SP4UIITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/SAML2SP4UIITCase.java
@@ -257,8 +257,7 @@ public class SAML2SP4UIITCase extends AbstractUIITCase {
             post.setEntity(new UrlEncodedFormEntity(form, Consts.UTF_8));
             try (CloseableHttpResponse response = httpclient.execute(post, context)) {
                 assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, response.getStatusLine().getStatusCode());
-                location = response.getFirstHeader(HttpHeaders.LOCATION).getValue().
-                        replace("http://", "https://").replace(":8080", ":9443");
+                location = response.getFirstHeader(HttpHeaders.LOCATION).getValue();
             }
         }
 
diff --git a/pom.xml b/pom.xml
index 94901713ee..d853988d73 100644
--- a/pom.xml
+++ b/pom.xml
@@ -437,7 +437,7 @@ under the License.
 
     <modernizer-maven.version>2.5.0</modernizer-maven.version>
 
-    <pac4j.version>6.0.0-RC5-SNAPSHOT</pac4j.version>
+    <pac4j.version>6.0.0-RC5</pac4j.version>
 
     <cas.version>7.0.0-SNAPSHOT</cas.version>
     <cas-client.version>4.0.1</cas-client.version>
@@ -1687,7 +1687,7 @@ under the License.
             <dependency>
               <groupId>com.puppycrawl.tools</groupId>
               <artifactId>checkstyle</artifactId>
-              <version>10.6.0</version>
+              <version>10.7.0</version>
             </dependency>
           </dependencies>
           <configuration>
@@ -1749,7 +1749,7 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-enforcer-plugin</artifactId>
-        <version>3.1.0</version>
+        <version>3.2.1</version>
         <executions>
           <execution>
             <id>default-cli</id>
diff --git a/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java b/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java
index 8f69eccfe4..878ed14660 100644
--- a/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java
+++ b/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java
@@ -303,21 +303,19 @@ public class SecurityConfig {
                 anyExchange().authenticated();
 
         switch (props.getAmType()) {
-            case OIDC:
-            case OAUTH2:
+            case OIDC, OAUTH2 -> {
                 OAuth2SecurityConfigUtils.forLogin(http, props.getAmType(), ctx);
                 OAuth2SecurityConfigUtils.forLogout(builder, props.getAmType(), cacheManager, logoutRouteMatcher, ctx);
                 http.oauth2ResourceServer().jwt().jwtDecoder(ctx.getBean(ReactiveJwtDecoder.class));
-                break;
+            }
 
-            case SAML2:
+            case SAML2 ->
                 saml2Client.ifAvailable(client -> {
                     SAML2SecurityConfigUtils.forLogin(http, client, publicRouteMatcher);
                     SAML2SecurityConfigUtils.forLogout(builder, client, cacheManager, logoutRouteMatcher, ctx);
                 });
-                break;
 
-            case CAS:
+            case CAS -> {
                 CASSecurityConfigUtils.forLogin(
                         http,
                         props.getCas().getProtocol(),
@@ -329,9 +327,10 @@ public class SecurityConfig {
                         props.getCas().getServerPrefix(),
                         logoutRouteMatcher,
                         ctx);
-                break;
+            }
 
-            default:
+            default -> {
+            }
         }
 
         return builder.and().csrf().requireCsrfProtectionMatcher(csrfRouteMatcher).and().build();
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/pac4j/RedirectionActionUtils.java b/sra/src/main/java/org/apache/syncope/sra/security/pac4j/RedirectionActionUtils.java
index c56c23f701..63cbc6a68a 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/pac4j/RedirectionActionUtils.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/pac4j/RedirectionActionUtils.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.sra.security.pac4j;
 
 import java.net.URI;
+import java.util.Optional;
 import org.pac4j.core.exception.http.RedirectionAction;
 import org.pac4j.core.exception.http.WithContentAction;
 import org.pac4j.core.exception.http.WithLocationAction;
@@ -32,27 +33,24 @@ public final class RedirectionActionUtils {
             final RedirectionAction action,
             final ServerWebExchangeContext swec) {
 
-        if (action instanceof WithLocationAction) {
-            WithLocationAction withLocationAction = (WithLocationAction) action;
+        if (action instanceof WithLocationAction withLocationAction) {
             swec.getNative().getResponse().setStatusCode(HttpStatus.FOUND);
             swec.getNative().getResponse().getHeaders().setLocation(URI.create(withLocationAction.getLocation()));
             return swec.getNative().getResponse().setComplete();
-        } else if (action instanceof WithContentAction) {
-            WithContentAction withContentAction = (WithContentAction) action;
-            String content = withContentAction.getContent();
+        }
 
-            if (content == null) {
-                throw new IllegalArgumentException("No content set for POST AuthnRequest");
-            }
+        if (action instanceof WithContentAction withContentAction) {
+            String content = Optional.ofNullable(withContentAction.getContent()).
+                    orElseThrow(() -> new IllegalArgumentException("No content set for POST AuthnRequest"));
 
             return Mono.defer(() -> {
                 swec.getNative().getResponse().getHeaders().setContentType(MediaType.TEXT_HTML);
                 return swec.getNative().getResponse().
                         writeWith(Mono.just(swec.getNative().getResponse().bufferFactory().wrap(content.getBytes())));
             });
-        } else {
-            throw new IllegalArgumentException("Unsupported Action: " + action.getClass().getName());
         }
+
+        throw new IllegalArgumentException("Unsupported Action: " + action.getClass().getName());
     }
 
     private RedirectionActionUtils() {
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2AuthenticationToken.java b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2AuthenticationToken.java
index 74e712eb26..c99801dac7 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2AuthenticationToken.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2AuthenticationToken.java
@@ -18,9 +18,11 @@
  */
 package org.apache.syncope.sra.security.saml2;
 
+import java.util.Optional;
+import java.util.Set;
 import java.util.stream.Collectors;
 import org.apache.commons.lang3.StringUtils;
-import org.pac4j.saml.credentials.SAML2Credentials;
+import org.pac4j.saml.credentials.SAML2AuthenticationCredentials;
 import org.springframework.security.authentication.AbstractAuthenticationToken;
 import org.springframework.security.core.authority.SimpleGrantedAuthority;
 
@@ -28,11 +30,12 @@ public class SAML2AuthenticationToken extends AbstractAuthenticationToken {
 
     private static final long serialVersionUID = 8322987617416135717L;
 
-    private final SAML2Credentials credentials;
+    private final SAML2AuthenticationCredentials credentials;
 
-    public SAML2AuthenticationToken(final SAML2Credentials credentials) {
-        super(credentials.getUserProfile().getRoles().stream().
-                map(SimpleGrantedAuthority::new).collect(Collectors.toSet()));
+    public SAML2AuthenticationToken(final SAML2AuthenticationCredentials credentials) {
+        super(Optional.ofNullable(credentials.getUserProfile()).
+                map(p -> p.getRoles().stream().map(SimpleGrantedAuthority::new).collect(Collectors.toSet())).
+                orElse(Set.of()));
         this.credentials = credentials;
         this.setAuthenticated(true);
     }
@@ -43,7 +46,7 @@ public class SAML2AuthenticationToken extends AbstractAuthenticationToken {
     }
 
     @Override
-    public SAML2Credentials getPrincipal() {
+    public SAML2AuthenticationCredentials getPrincipal() {
         return credentials;
     }
 }
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2LogoutResponseWebFilter.java b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2LogoutResponseWebFilter.java
index 8d543159af..0f55618a88 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2LogoutResponseWebFilter.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2LogoutResponseWebFilter.java
@@ -18,21 +18,13 @@
  */
 package org.apache.syncope.sra.security.saml2;
 
-import java.util.Optional;
-import org.apache.syncope.sra.SessionConfig;
 import org.apache.syncope.sra.security.pac4j.NoOpSessionStore;
-import org.apache.syncope.sra.security.pac4j.RedirectionActionUtils;
 import org.apache.syncope.sra.security.pac4j.ServerWebExchangeContext;
 import org.pac4j.core.context.CallContext;
-import org.pac4j.core.exception.http.OkAction;
-import org.pac4j.core.exception.http.RedirectionAction;
-import org.pac4j.core.profile.factory.ProfileManagerFactory;
-import org.pac4j.core.util.Pac4jConstants;
+import org.pac4j.core.credentials.Credentials;
 import org.pac4j.saml.client.SAML2Client;
-import org.pac4j.saml.context.SAML2MessageContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.cache.CacheManager;
 import org.springframework.http.HttpMethod;
 import org.springframework.security.web.server.WebFilterExchange;
 import org.springframework.security.web.server.authentication.logout.ServerLogoutSuccessHandler;
@@ -51,46 +43,28 @@ public class SAML2LogoutResponseWebFilter implements WebFilter {
     public static final ServerWebExchangeMatcher MATCHER =
             ServerWebExchangeMatchers.pathMatchers("/logout/saml2/sso");
 
-    private static class ServerWebExchangeLogoutContext extends ServerWebExchangeContext {
-
-        ServerWebExchangeLogoutContext(final ServerWebExchange exchange) {
-            super(exchange);
-        }
-
-        @Override
-        public Optional<String> getRequestParameter(final String name) {
-            return Pac4jConstants.LOGOUT_ENDPOINT_PARAMETER.equals(name)
-                    ? Optional.of("true")
-                    : super.getRequestParameter(name);
-        }
-    }
-
     private final SAML2Client saml2Client;
 
     private final ServerLogoutSuccessHandler logoutSuccessHandler;
 
-    private final CacheManager cacheManager;
-
     public SAML2LogoutResponseWebFilter(
             final SAML2Client saml2Client,
-            final SAML2ServerLogoutSuccessHandler logoutSuccessHandler,
-            final CacheManager cacheManager) {
+            final SAML2ServerLogoutSuccessHandler logoutSuccessHandler) {
 
         this.saml2Client = saml2Client;
         this.logoutSuccessHandler = logoutSuccessHandler;
-        this.cacheManager = cacheManager;
     }
 
     private Mono<Void> handleLogoutResponse(
             final ServerWebExchange exchange, final WebFilterChain chain, final ServerWebExchangeContext swec) {
 
         try {
-            SAML2MessageContext ctx = saml2Client.getContextProvider().buildContext(
-                    new CallContext(swec, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT),
-                    this.saml2Client);
-            saml2Client.getLogoutProfileHandler().receive(ctx);
-        } catch (OkAction e) {
-            LOG.debug("LogoutResponse was actually validated but no postLogoutURL was set", e);
+            CallContext ctx = new CallContext(swec, NoOpSessionStore.INSTANCE);
+            Credentials creds = saml2Client.getCredentialsExtractor().
+                    extract(ctx).
+                    orElseThrow(() -> new IllegalStateException("Could not extract credentials"));
+
+            saml2Client.getLogoutProcessor().processLogout(ctx, creds);
         } catch (Exception e) {
             LOG.error("Could not validate LogoutResponse", e);
         }
@@ -98,47 +72,20 @@ public class SAML2LogoutResponseWebFilter implements WebFilter {
         return logoutSuccessHandler.onLogoutSuccess(new WebFilterExchange(exchange, chain), null);
     }
 
-    private Mono<Void> handleLogoutRequest(
-            final ServerWebExchange exchange, final WebFilterChain chain, final ServerWebExchangeContext swec) {
-
-        return exchange.getSession().
-                switchIfEmpty(chain.filter(exchange).then(Mono.empty())).
-                flatMap(session -> {
-                    cacheManager.getCache(SessionConfig.DEFAULT_CACHE).evictIfPresent(session.getId());
-
-                    return session.invalidate().then(Mono.defer(() -> {
-                        try {
-                            saml2Client.getCredentialsExtractor().extract(new CallContext(
-                                    swec, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT));
-                        } catch (RedirectionAction action) {
-                            return RedirectionActionUtils.handle(action, swec);
-                        }
-
-                        return chain.filter(exchange).then(Mono.empty());
-                    }));
-                });
-    }
-
     private Mono<Void> handleGET(final ServerWebExchange exchange, final WebFilterChain chain) {
         if (exchange.getRequest().getQueryParams().getFirst("SAMLResponse") != null) {
             return handleLogoutResponse(exchange, chain, new ServerWebExchangeContext(exchange));
-        } else if (exchange.getRequest().getQueryParams().getFirst("SAMLRequest") != null) {
-            return handleLogoutRequest(exchange, chain, new ServerWebExchangeLogoutContext(exchange));
         }
 
         return chain.filter(exchange).then(Mono.empty());
     }
 
     private Mono<Void> handlePOST(final ServerWebExchange exchange, final WebFilterChain chain) {
-        return exchange.getFormData().flatMap(form -> {
-            if (form.containsKey("SAMLResponse")) {
-                return handleLogoutResponse(exchange, chain, new ServerWebExchangeContext(exchange).setForm(form));
-            } else if (form.containsKey("SAMLRequest")) {
-                return handleLogoutRequest(exchange, chain, new ServerWebExchangeLogoutContext(exchange).setForm(form));
-            }
-
-            return chain.filter(exchange).then(Mono.empty());
-        });
+        return exchange.getFormData().
+                filter(form -> form.containsKey("SAMLResponse")).
+                flatMap(form -> handleLogoutResponse(
+                exchange, chain, new ServerWebExchangeContext(exchange).setForm(form))).
+                or(chain.filter(exchange).then(Mono.empty()));
     }
 
     @Override
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2RequestServerLogoutHandler.java b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2RequestServerLogoutHandler.java
index 6854acb90c..57f5fcee80 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2RequestServerLogoutHandler.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2RequestServerLogoutHandler.java
@@ -23,9 +23,8 @@ import org.apache.syncope.sra.security.pac4j.NoOpSessionStore;
 import org.apache.syncope.sra.security.pac4j.RedirectionActionUtils;
 import org.apache.syncope.sra.security.pac4j.ServerWebExchangeContext;
 import org.pac4j.core.context.CallContext;
-import org.pac4j.core.profile.factory.ProfileManagerFactory;
 import org.pac4j.saml.client.SAML2Client;
-import org.pac4j.saml.credentials.SAML2Credentials;
+import org.pac4j.saml.credentials.SAML2AuthenticationCredentials;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cache.CacheManager;
@@ -51,7 +50,8 @@ public class SAML2RequestServerLogoutHandler implements ServerLogoutHandler {
     public Mono<Void> logout(final WebFilterExchange exchange, final Authentication authentication) {
         return exchange.getExchange().getSession().
                 flatMap(session -> {
-                    SAML2Credentials credentials = (SAML2Credentials) authentication.getPrincipal();
+                    SAML2AuthenticationCredentials credentials = 
+                            (SAML2AuthenticationCredentials) authentication.getPrincipal();
 
                     LOG.debug("Creating SAML2 SP Logout Request for IDP[{}] and Profile[{}]",
                             saml2Client.getIdentityProviderResolvedEntityId(), credentials.getUserProfile());
@@ -60,9 +60,7 @@ public class SAML2RequestServerLogoutHandler implements ServerLogoutHandler {
 
                     cacheManager.getCache(SessionConfig.DEFAULT_CACHE).evictIfPresent(session.getId());
                     return session.invalidate().then(saml2Client.getLogoutAction(
-                            new CallContext(swec, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT),
-                            credentials.getUserProfile(),
-                            null).
+                            new CallContext(swec, NoOpSessionStore.INSTANCE), credentials.getUserProfile(), null).
                             map(action -> RedirectionActionUtils.handle(action, swec)).
                             orElseThrow(() -> new IllegalStateException("No action generated")));
                 }).onErrorResume(Mono::error);
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2SecurityConfigUtils.java b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2SecurityConfigUtils.java
index a7be69c990..21b8923e8d 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2SecurityConfigUtils.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2SecurityConfigUtils.java
@@ -84,7 +84,7 @@ public final class SAML2SecurityConfigUtils {
                     SAML2ServerLogoutSuccessHandler.class);
 
             SAML2LogoutResponseWebFilter logoutResponseWebFilter =
-                    new SAML2LogoutResponseWebFilter(saml2Client, logoutSuccessHandler, cacheManager);
+                    new SAML2LogoutResponseWebFilter(saml2Client, logoutSuccessHandler);
             builder.and().addFilterAt(logoutResponseWebFilter, SecurityWebFiltersOrder.LOGOUT);
         } catch (ClassNotFoundException e) {
             LOG.error("While creating instance of {}", SAML2ServerLogoutSuccessHandler.class.getName(), e);
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationRequestWebFilter.java b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationRequestWebFilter.java
index a895ff299c..a504bc9711 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationRequestWebFilter.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationRequestWebFilter.java
@@ -18,11 +18,13 @@
  */
 package org.apache.syncope.sra.security.saml2;
 
+import java.net.URI;
 import org.apache.syncope.sra.security.pac4j.NoOpSessionStore;
 import org.apache.syncope.sra.security.pac4j.RedirectionActionUtils;
 import org.apache.syncope.sra.security.pac4j.ServerWebExchangeContext;
+import org.apache.syncope.sra.session.SessionUtils;
 import org.pac4j.core.context.CallContext;
-import org.pac4j.core.profile.factory.ProfileManagerFactory;
+import org.pac4j.core.util.generator.ValueGenerator;
 import org.pac4j.saml.client.SAML2Client;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,14 +56,23 @@ public class SAML2WebSsoAuthenticationRequestWebFilter implements WebFilter {
         return MATCHER.matches(exchange).
                 filter(MatchResult::isMatch).
                 switchIfEmpty(chain.filter(exchange).then(Mono.empty())).
-                flatMap(matchResult -> {
+                flatMap(r -> exchange.getSession()).
+                flatMap(session -> {
                     LOG.debug("Creating SAML2 SP Authentication Request for IDP[{}]",
                             saml2Client.getIdentityProviderResolvedEntityId());
 
+                    saml2Client.setStateGenerator(new ValueGenerator() {
+
+                        @Override
+                        public String generateValue(final CallContext ctx) {
+                            return session.<URI>getRequiredAttribute(SessionUtils.INITIAL_REQUEST_URI).toASCIIString();
+                        }
+                    });
+
                     ServerWebExchangeContext swec = new ServerWebExchangeContext(exchange);
 
                     return saml2Client.getRedirectionAction(
-                            new CallContext(swec, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT)).
+                            new CallContext(swec, NoOpSessionStore.INSTANCE)).
                             map(action -> RedirectionActionUtils.handle(action, swec)).
                             orElseThrow(() -> new IllegalStateException("No action generated"));
                 }).onErrorResume(Mono::error);
diff --git a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationWebFilter.java b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationWebFilter.java
index a35e436f11..90f8346cce 100644
--- a/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationWebFilter.java
+++ b/sra/src/main/java/org/apache/syncope/sra/security/saml2/SAML2WebSsoAuthenticationWebFilter.java
@@ -22,11 +22,10 @@ import java.net.URI;
 import org.apache.syncope.sra.security.pac4j.NoOpSessionStore;
 import org.apache.syncope.sra.security.pac4j.ServerWebExchangeContext;
 import org.apache.syncope.sra.security.web.server.DoNothingIfCommittedServerRedirectStrategy;
-import org.apache.syncope.sra.session.SessionUtils;
 import org.pac4j.core.context.CallContext;
-import org.pac4j.core.profile.factory.ProfileManagerFactory;
+import org.pac4j.core.credentials.Credentials;
 import org.pac4j.saml.client.SAML2Client;
-import org.pac4j.saml.credentials.SAML2Credentials;
+import org.pac4j.saml.credentials.SAML2AuthenticationCredentials;
 import org.springframework.security.authentication.ReactiveAuthenticationManager;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.web.server.ServerRedirectStrategy;
@@ -71,7 +70,7 @@ public class SAML2WebSsoAuthenticationWebFilter extends AuthenticationWebFilter
 
     private ServerWebExchangeMatcher matchSamlResponse() {
         return exchange -> exchange.getFormData().
-                filter(form -> form.containsKey("SAMLResponse")).
+                filter(form -> form.containsKey("SAMLResponse") && form.containsKey("RelayState")).
                 flatMap(form -> ServerWebExchangeMatcher.MatchResult.match()).
                 switchIfEmpty(ServerWebExchangeMatcher.MatchResult.notMatch());
     }
@@ -79,18 +78,19 @@ public class SAML2WebSsoAuthenticationWebFilter extends AuthenticationWebFilter
     private ServerAuthenticationConverter convertSamlResponse() {
         return exchange -> exchange.getFormData().
                 flatMap(form -> MATCHER.matches(exchange).
-                flatMap(matchResult -> {
+                flatMap(r -> {
                     ServerWebExchangeContext swec = new ServerWebExchangeContext(exchange).setForm(form);
+                    CallContext ctx = new CallContext(swec, NoOpSessionStore.INSTANCE);
 
-                    SAML2Credentials credentials = (SAML2Credentials) saml2Client.getCredentialsExtractor().
-                            extract(new CallContext(
-                                    swec, NoOpSessionStore.INSTANCE, ProfileManagerFactory.DEFAULT)).
-                            orElseThrow(() -> new IllegalStateException("No AuthnResponse found"));
+                    Credentials creds = saml2Client.getCredentialsExtractor().
+                            extract(ctx).
+                            orElseThrow(() -> new IllegalStateException("Could not extract credentials"));
 
-                    saml2Client.getAuthenticator().validate(
-                            new CallContext(swec, NoOpSessionStore.INSTANCE), credentials);
+                    SAML2AuthenticationCredentials authCreds = saml2Client.validateCredentials(ctx, creds).
+                            map(SAML2AuthenticationCredentials.class::cast).
+                            orElseThrow(() -> new IllegalArgumentException("Invalid SAML credentials provided"));
 
-                    return Mono.just(new SAML2AuthenticationToken(credentials));
+                    return Mono.just(new SAML2AuthenticationToken(authCreds));
                 }));
     }
 
@@ -103,10 +103,10 @@ public class SAML2WebSsoAuthenticationWebFilter extends AuthenticationWebFilter
             public Mono<Void> onAuthenticationSuccess(
                     final WebFilterExchange webFilterExchange, final Authentication authentication) {
 
-                return webFilterExchange.getExchange().getSession().
-                        flatMap(session -> this.redirectStrategy.sendRedirect(
+                return webFilterExchange.getExchange().getFormData().
+                        flatMap(form -> this.redirectStrategy.sendRedirect(
                         webFilterExchange.getExchange(),
-                        session.<URI>getRequiredAttribute(SessionUtils.INITIAL_REQUEST_URI)));
+                        URI.create(form.get("RelayState").get(0))));
             }
         };
     }
diff --git a/sra/src/main/resources/sra.properties b/sra/src/main/resources/sra.properties
index 1e42d3efbc..ea56675260 100644
--- a/sra/src/main/resources/sra.properties
+++ b/sra/src/main/resources/sra.properties
@@ -23,6 +23,7 @@ server.port=8080
 management.endpoint.gateway.enabled=true
 management.endpoints.web.exposure.include=info,health,loggers,metrics,gateway,sraSessions
 management.endpoint.health.show-details=ALWAYS
+management.endpoint.env.show-values=WHEN_AUTHORIZED
 spring.cloud.discovery.client.health-indicator.enabled=false
 
 service.discovery.address=http://localhost:8080/
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WAContext.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WAContext.java
index 9a91ba0260..feb0743019 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WAContext.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/config/WAContext.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.wa.starter.config;
 
+import com.github.benmanes.caffeine.cache.Cache;
 import com.github.benmanes.caffeine.cache.Caffeine;
 import com.github.benmanes.caffeine.cache.LoadingCache;
 import com.warrenstrange.googleauth.IGoogleAuthenticator;
@@ -60,8 +61,9 @@ import org.apache.syncope.wa.starter.mapping.RegisteredServiceMapper;
 import org.apache.syncope.wa.starter.mapping.SAML2SPClientAppTOMapper;
 import org.apache.syncope.wa.starter.oidc.WAOIDCJWKSGeneratorService;
 import org.apache.syncope.wa.starter.pac4j.saml.WASAML2ClientCustomizer;
-import org.apache.syncope.wa.starter.saml.idp.metadata.RestfulSamlIdPMetadataGenerator;
-import org.apache.syncope.wa.starter.saml.idp.metadata.RestfulSamlIdPMetadataLocator;
+import org.apache.syncope.wa.starter.saml.idp.WASamlIdPCasEventListener;
+import org.apache.syncope.wa.starter.saml.idp.metadata.WASamlIdPMetadataGenerator;
+import org.apache.syncope.wa.starter.saml.idp.metadata.WASamlIdPMetadataLocator;
 import org.apache.syncope.wa.starter.services.WAServiceRegistry;
 import org.apache.syncope.wa.starter.surrogate.WASurrogateAuthenticationService;
 import org.apache.syncope.wa.starter.u2f.WAU2FDeviceRepository;
@@ -82,9 +84,11 @@ import org.apereo.cas.support.events.CasEventRepository;
 import org.apereo.cas.support.events.CasEventRepositoryFilter;
 import org.apereo.cas.support.pac4j.authentication.clients.DelegatedClientFactoryCustomizer;
 import org.apereo.cas.support.pac4j.authentication.handler.support.DelegatedClientAuthenticationHandler;
+import org.apereo.cas.support.saml.idp.SamlIdPCasEventListener;
 import org.apereo.cas.support.saml.idp.metadata.generator.SamlIdPMetadataGenerator;
 import org.apereo.cas.support.saml.idp.metadata.generator.SamlIdPMetadataGeneratorConfigurationContext;
 import org.apereo.cas.support.saml.idp.metadata.locator.SamlIdPMetadataLocator;
+import org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument;
 import org.apereo.cas.util.DateTimeUtils;
 import org.apereo.cas.util.LdapUtils;
 import org.apereo.cas.util.crypto.CipherExecutor;
@@ -98,6 +102,7 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.ScopedProxyMode;
 
 @Configuration(proxyBeanMethods = false)
@@ -221,36 +226,49 @@ public class WAContext {
     @Bean
     public ServiceRegistryExecutionPlanConfigurer syncopeServiceRegistryConfigurer(
             final ConfigurableApplicationContext ctx,
-            final WARestClient restClient,
+            final WARestClient waRestClient,
             final RegisteredServiceMapper registeredServiceMapper,
             @Qualifier("serviceRegistryListeners")
             final ObjectProvider<List<ServiceRegistryListener>> serviceRegistryListeners) {
 
         WAServiceRegistry registry = new WAServiceRegistry(
-                restClient, registeredServiceMapper, ctx,
+                waRestClient, registeredServiceMapper, ctx,
                 Optional.ofNullable(serviceRegistryListeners.getIfAvailable()).orElseGet(ArrayList::new));
         return plan -> plan.registerServiceRegistry(registry);
     }
 
+    @Bean
+    @RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
+    @Lazy(false)
+    public SamlIdPCasEventListener samlIdPCasEventListener() {
+        return new WASamlIdPCasEventListener();
+    }
+
     @Bean
     public SamlIdPMetadataGenerator samlIdPMetadataGenerator(
-            final WARestClient restClient,
+            final WARestClient waRestClient,
             final SamlIdPMetadataGeneratorConfigurationContext context) {
 
-        return new RestfulSamlIdPMetadataGenerator(context, restClient);
+        return new WASamlIdPMetadataGenerator(context, waRestClient);
     }
 
     @Bean
-    public SamlIdPMetadataLocator samlIdPMetadataLocator(final WARestClient restClient) {
-        return new RestfulSamlIdPMetadataLocator(
-                CipherExecutor.noOpOfStringToString(),
-                Caffeine.newBuilder().build(),
-                restClient);
+    public SamlIdPMetadataLocator samlIdPMetadataLocator(
+            @Qualifier("samlIdPMetadataGeneratorCipherExecutor")
+            final CipherExecutor<String, String> cipherExecutor,
+            @Qualifier("samlIdPMetadataCache")
+            final Cache<String, SamlIdPMetadataDocument> samlIdPMetadataCache,
+            final WARestClient waRestClient) {
+
+        return new WASamlIdPMetadataLocator(
+                cipherExecutor,
+                samlIdPMetadataCache,
+                waRestClient);
     }
 
     @Bean
-    public AuditTrailExecutionPlanConfigurer auditConfigurer(final WARestClient restClient) {
-        return plan -> plan.registerAuditTrailManager(new WAAuditTrailManager(restClient));
+    public AuditTrailExecutionPlanConfigurer auditConfigurer(final WARestClient waRestClient) {
+        return plan -> plan.registerAuditTrailManager(new WAAuditTrailManager(waRestClient));
     }
 
     @ConditionalOnMissingBean(name = "syncopeWAEventRepositoryFilter")
@@ -261,25 +279,25 @@ public class WAContext {
 
     @Bean
     public CasEventRepository casEventRepository(
-            final WARestClient restClient,
+            final WARestClient waRestClient,
             @Qualifier("syncopeWAEventRepositoryFilter")
             final CasEventRepositoryFilter syncopeWAEventRepositoryFilter) {
 
-        return new WAEventRepository(syncopeWAEventRepositoryFilter, restClient);
+        return new WAEventRepository(syncopeWAEventRepositoryFilter, waRestClient);
     }
 
     @Bean
-    public DelegatedClientFactoryCustomizer<Client> delegatedClientCustomizer(final WARestClient restClient) {
-        return new WASAML2ClientCustomizer(restClient);
+    public DelegatedClientFactoryCustomizer<Client> delegatedClientCustomizer(final WARestClient waRestClient) {
+        return new WASAML2ClientCustomizer(waRestClient);
     }
 
     @Bean
     public WAGoogleMfaAuthTokenRepository oneTimeTokenAuthenticatorTokenRepository(
             final CasConfigurationProperties casProperties,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
         return new WAGoogleMfaAuthTokenRepository(
-                restClient, casProperties.getAuthn().getMfa().getGauth().getCore().getTimeStepSize());
+                waRestClient, casProperties.getAuthn().getMfa().getGauth().getCore().getTimeStepSize());
     }
 
     @ConditionalOnMissingBean(name = CUSTOM_GOOGLE_AUTHENTICATOR_ACCOUNT_REGISTRY)
@@ -292,7 +310,7 @@ public class WAContext {
             @Qualifier("googleAuthenticatorScratchCodesCipherExecutor")
             final CipherExecutor<Number, Number> googleAuthenticatorScratchCodesCipherExecutor,
             final IGoogleAuthenticator googleAuthenticatorInstance,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
         /*
          * Declaring the LDAP-based repository as a Spring bean that would be conditionally activated
@@ -314,16 +332,16 @@ public class WAContext {
                     connectionFactory,
                     ldap);
         }
-        return new WAGoogleMfaAuthCredentialRepository(restClient, googleAuthenticatorInstance);
+        return new WAGoogleMfaAuthCredentialRepository(waRestClient, googleAuthenticatorInstance);
     }
 
     @Bean
     public OidcJsonWebKeystoreGeneratorService oidcJsonWebKeystoreGeneratorService(
             final CasConfigurationProperties casProperties,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
         return new WAOIDCJWKSGeneratorService(
-                restClient,
+                waRestClient,
                 casProperties.getAuthn().getOidc().getJwks().getCore().getJwksKeyId(),
                 casProperties.getAuthn().getOidc().getJwks().getCore().getJwksType(),
                 casProperties.getAuthn().getOidc().getJwks().getCore().getJwksKeySize());
@@ -332,15 +350,15 @@ public class WAContext {
     @Bean
     public WebAuthnCredentialRepository webAuthnCredentialRepository(
             final CasConfigurationProperties casProperties,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
-        return new WAWebAuthnCredentialRepository(casProperties, restClient);
+        return new WAWebAuthnCredentialRepository(casProperties, waRestClient);
     }
 
     @Bean
     public U2FDeviceRepository u2fDeviceRepository(
             final CasConfigurationProperties casProperties,
-            final WARestClient restClient) {
+            final WARestClient waRestClient) {
 
         U2FCoreMultifactorAuthenticationProperties u2f = casProperties.getAuthn().getMfa().getU2f().getCore();
         OffsetDateTime expirationDate = OffsetDateTime.now().
@@ -348,18 +366,18 @@ public class WAContext {
         LoadingCache<String, String> requestStorage = Caffeine.newBuilder().
                 expireAfterWrite(u2f.getExpireRegistrations(), u2f.getExpireRegistrationsTimeUnit()).
                 build(key -> StringUtils.EMPTY);
-        return new WAU2FDeviceRepository(casProperties, requestStorage, restClient, expirationDate);
+        return new WAU2FDeviceRepository(casProperties, requestStorage, waRestClient, expirationDate);
     }
 
     @Bean
-    public SurrogateAuthenticationService surrogateAuthenticationService(final WARestClient restClient) {
-        return new WASurrogateAuthenticationService(restClient);
+    public SurrogateAuthenticationService surrogateAuthenticationService(final WARestClient waRestClient) {
+        return new WASurrogateAuthenticationService(waRestClient);
     }
 
     @ConditionalOnMissingBean
     @Bean
-    public SyncopeCoreHealthIndicator syncopeCoreHealthIndicator(final WARestClient restClient) {
-        return new SyncopeCoreHealthIndicator(restClient);
+    public SyncopeCoreHealthIndicator syncopeCoreHealthIndicator(final WARestClient waRestClient) {
+        return new SyncopeCoreHealthIndicator(waRestClient);
     }
 
     @ConditionalOnMissingBean
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/JWSAlgorithm.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/WASamlIdPCasEventListener.java
similarity index 61%
rename from common/am/lib/src/main/java/org/apache/syncope/common/lib/types/JWSAlgorithm.java
rename to wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/WASamlIdPCasEventListener.java
index 015a9d2ec7..da1bcaf72c 100644
--- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/JWSAlgorithm.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/WASamlIdPCasEventListener.java
@@ -16,22 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.syncope.common.lib.types;
+package org.apache.syncope.wa.starter.saml.idp;
 
-public enum JWSAlgorithm {
-    HS256,
-    HS384,
-    HS512,
-    RS256,
-    RS384,
-    RS512,
-    ES256,
-    ES384,
-    ES512,
-    PS256,
-    PS384,
-    PS512,
-    EdDSA,
-    ES256K;
+import org.apereo.cas.support.saml.idp.SamlIdPCasEventListener;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
 
+public class WASamlIdPCasEventListener implements SamlIdPCasEventListener {
+
+    @Override
+    public void handleApplicationReadyEvent(final ApplicationReadyEvent event) {
+        // skip generating IdP metadata at this stage, as
+        // org.apereo.cas.support.saml.idp.DefaultSamlIdPCasEventListener is doing
+    }
 }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/WASamlIdPMetadataGenerator.java
similarity index 82%
rename from wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java
rename to wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/WASamlIdPMetadataGenerator.java
index 2161f118ce..07a8227ee8 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataGenerator.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/WASamlIdPMetadataGenerator.java
@@ -33,13 +33,13 @@ import org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RestfulSamlIdPMetadataGenerator extends BaseSamlIdPMetadataGenerator {
+public class WASamlIdPMetadataGenerator extends BaseSamlIdPMetadataGenerator {
 
-    private static final Logger LOG = LoggerFactory.getLogger(RestfulSamlIdPMetadataGenerator.class);
+    private static final Logger LOG = LoggerFactory.getLogger(WASamlIdPMetadataGenerator.class);
 
     private final WARestClient waRestClient;
 
-    public RestfulSamlIdPMetadataGenerator(
+    public WASamlIdPMetadataGenerator(
             final SamlIdPMetadataGeneratorConfigurationContext samlIdPMetadataGeneratorConfigurationContext,
             final WARestClient waRestClient) {
 
@@ -47,14 +47,34 @@ public class RestfulSamlIdPMetadataGenerator extends BaseSamlIdPMetadataGenerato
         this.waRestClient = waRestClient;
     }
 
+    @Override
+    public String getAppliesToFor(final Optional<SamlRegisteredService> registeredService) {
+        return registeredService.
+                map(SamlRegisteredService::getName).
+                orElse(SAML2IdPEntityService.DEFAULT_OWNER);
+    }
+
+    private SyncopeClient getSyncopeClient() {
+        if (!waRestClient.isReady()) {
+            LOG.info("Syncope client is not yet ready");
+            throw new IllegalStateException("Syncope core is not yet ready to access requests");
+        }
+        return waRestClient.getSyncopeClient();
+    }
+
+    @Override
+    public SamlIdPMetadataDocument generate(final Optional<SamlRegisteredService> registeredService) throws Exception {
+        return super.generate(registeredService);
+    }
+
     @Override
     protected SamlIdPMetadataDocument finalizeMetadataDocument(
             final SamlIdPMetadataDocument doc,
             final Optional<SamlRegisteredService> registeredService) throws Exception {
 
-        LOG.info("Generating new SAML2 IdP metadata document");
+        doc.setAppliesTo(getAppliesToFor(registeredService));
 
-        doc.setAppliesTo(SAML2IdPEntityService.DEFAULT_OWNER);
+        LOG.info("Setting new SAML2 IdP metadata document for {}", doc.getAppliesTo());
 
         SAML2IdPEntityTO entityTO = new SAML2IdPEntityTO.Builder().
                 key(doc.getAppliesTo()).
@@ -84,23 +104,15 @@ public class RestfulSamlIdPMetadataGenerator extends BaseSamlIdPMetadataGenerato
 
     @Override
     public Pair<String, String> buildSelfSignedEncryptionCert(final Optional<SamlRegisteredService> registeredService)
-        throws Exception {
+            throws Exception {
 
         return generateCertificateAndKey();
     }
 
     @Override
     public Pair<String, String> buildSelfSignedSigningCert(final Optional<SamlRegisteredService> registeredService)
-        throws Exception {
+            throws Exception {
 
         return generateCertificateAndKey();
     }
-
-    private SyncopeClient getSyncopeClient() {
-        if (!waRestClient.isReady()) {
-            LOG.info("Syncope client is not yet ready");
-            throw new IllegalStateException("Syncope core is not yet ready to access requests");
-        }
-        return waRestClient.getSyncopeClient();
-    }
 }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/WASamlIdPMetadataLocator.java
similarity index 88%
rename from wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java
rename to wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/WASamlIdPMetadataLocator.java
index 71c8fa1d5e..fa490e195f 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/saml/idp/metadata/WASamlIdPMetadataLocator.java
@@ -35,13 +35,13 @@ import org.apereo.cas.util.crypto.CipherExecutor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RestfulSamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocator {
+public class WASamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocator {
 
-    private static final Logger LOG = LoggerFactory.getLogger(RestfulSamlIdPMetadataLocator.class);
+    private static final Logger LOG = LoggerFactory.getLogger(WASamlIdPMetadataLocator.class);
 
     private final WARestClient waRestClient;
 
-    public RestfulSamlIdPMetadataLocator(
+    public WASamlIdPMetadataLocator(
             final CipherExecutor<String, String> metadataCipherExecutor,
             final Cache<String, SamlIdPMetadataDocument> metadataCache,
             final WARestClient waRestClient) {
@@ -50,6 +50,13 @@ public class RestfulSamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocato
         this.waRestClient = waRestClient;
     }
 
+    @Override
+    public String getAppliesToFor(final Optional<SamlRegisteredService> registeredService) {
+        return registeredService.
+                map(SamlRegisteredService::getName).
+                orElse(SAML2IdPEntityService.DEFAULT_OWNER);
+    }
+
     @Override
     public SamlIdPMetadataDocument fetchInternal(final Optional<SamlRegisteredService> registeredService) {
         try {
@@ -94,7 +101,7 @@ public class RestfulSamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocato
                 if (LOG.isDebugEnabled()) {
                     LOG.error("While fetching SAML2 IdP metadata", e);
                 } else {
-                    LOG.error("While fetching SAML2 IdP metadata: " + e.getMessage());
+                    LOG.error("While fetching SAML2 IdP metadata: {}", e.getMessage());
                 }
             }
         }
@@ -103,16 +110,14 @@ public class RestfulSamlIdPMetadataLocator extends AbstractSamlIdPMetadataLocato
     }
 
     private SAML2IdPEntityTO fetchFromCore(final Optional<SamlRegisteredService> registeredService) {
-        SAML2IdPEntityTO result = null;
+        SAML2IdPEntityService idpEntityService = getSyncopeClient().getService(SAML2IdPEntityService.class);
 
-        String appliesToFor = registeredService.map(SamlRegisteredService::getName).
-                orElse(SAML2IdPEntityService.DEFAULT_OWNER);
-        SAML2IdPEntityService service = getSyncopeClient().getService(SAML2IdPEntityService.class);
+        SAML2IdPEntityTO result = null;
         try {
-            result = service.get(appliesToFor);
+            result = idpEntityService.get(getAppliesToFor(registeredService));
         } catch (SyncopeClientException e) {
             if (e.getType() == ClientExceptionType.NotFound && registeredService.isPresent()) {
-                result = service.get(SAML2IdPEntityService.DEFAULT_OWNER);
+                result = idpEntityService.get(SAML2IdPEntityService.DEFAULT_OWNER);
             } else {
                 throw e;
             }
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/services/WAServiceRegistry.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/services/WAServiceRegistry.java
index 523be1164c..29665b7afe 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/services/WAServiceRegistry.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/services/WAServiceRegistry.java
@@ -20,6 +20,7 @@ package org.apache.syncope.wa.starter.services;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.common.lib.types.ClientAppType;
@@ -142,14 +143,15 @@ public class WAServiceRegistry extends AbstractServiceRegistry {
 
     @Override
     public RegisteredService findServiceByExactServiceName(final String name) {
-        SyncopeClient syncopeClient = waRestClient.getSyncopeClient();
-        if (syncopeClient == null) {
-            LOG.debug("Syncope client is not yet ready to fetch application definitions");
-            return null;
-        } else {
-            LOG.info("Searching for application definition by name {}", name);
-            return registeredServiceMapper.toRegisteredService(waRestClient.getSyncopeClient().
-                    getService(WAClientAppService.class).read(name, null));
-        }
+        return Optional.ofNullable(waRestClient.getSyncopeClient()).
+                map(syncopeClient -> {
+                    LOG.info("Searching for application definition by name {}", name);
+                    return registeredServiceMapper.toRegisteredService(waRestClient.getSyncopeClient().
+                            getService(WAClientAppService.class).read(name, null));
+                }).
+                orElseGet(() -> {
+                    LOG.debug("Syncope client is not yet ready to fetch application definitions");
+                    return null;
+                });
     }
 }
diff --git a/wa/starter/src/main/resources/wa.properties b/wa/starter/src/main/resources/wa.properties
index 8d16065d89..7c8ccd378f 100644
--- a/wa/starter/src/main/resources/wa.properties
+++ b/wa/starter/src/main/resources/wa.properties
@@ -39,6 +39,7 @@ cas.monitor.endpoints.endpoint.defaults.access=AUTHENTICATED
 management.endpoints.enabled-by-default=true
 management.endpoints.web.exposure.include=info,health,env,loggers,ssoSessions,registeredServices,refresh,authenticationHandlers,authenticationPolicies,resolveAttributes
 management.endpoint.health.show-details=ALWAYS
+management.endpoint.env.show-values=WHEN_AUTHORIZED
 spring.cloud.discovery.client.health-indicator.enabled=false
 
 # Cache service definitions for 5 minutes


[syncope] 04/05: Allow to override modal window title with wizards

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 185c9ff05f3cb5ae4a92e77991ac6a322baf404a
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Jan 27 10:54:25 2023 +0100

    Allow to override modal window title with wizards
---
 .../console/panels/LinkedAccountModalPanel.java    | 130 ++++++++++-----------
 .../wizards/resources/ResourceProvisionPanel.java  |  26 ++---
 .../client/ui/commons/wizards/AjaxWizard.java      |  10 +-
 .../syncope/client/console/pages/Realms.java       |   2 +-
 .../console/tasks/SchedTaskDirectoryPanel.java     |   4 +-
 .../client/console/tasks/TemplatesTogglePanel.java |   2 +-
 .../client/console/wizards/WizardMgtPanel.java     |  26 +++--
 .../panels/OIDCProvidersDirectoryPanel.java        |  18 +--
 .../console/panels/SAML2IdPsDirectoryPanel.java    |  26 ++---
 9 files changed, 123 insertions(+), 121 deletions(-)

diff --git a/client/idm/console/src/main/java/org/apache/syncope/client/console/panels/LinkedAccountModalPanel.java b/client/idm/console/src/main/java/org/apache/syncope/client/console/panels/LinkedAccountModalPanel.java
index c339735936..9d14bdc992 100644
--- a/client/idm/console/src/main/java/org/apache/syncope/client/console/panels/LinkedAccountModalPanel.java
+++ b/client/idm/console/src/main/java/org/apache/syncope/client/console/panels/LinkedAccountModalPanel.java
@@ -118,18 +118,18 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
         }
 
         ListViewPanel.Builder<LinkedAccountTO> builder = new ListViewPanel.Builder<>(
-            LinkedAccountTO.class, pageRef) {
+                LinkedAccountTO.class, pageRef) {
 
             private static final long serialVersionUID = -5322423525438435153L;
 
             @Override
             protected LinkedAccountTO getActualItem(final LinkedAccountTO item, final List<LinkedAccountTO> list) {
                 return item == null
-                    ? null
-                    : list.stream().filter(
-                    in -> ((item.getKey() == null && in.getKey() == null)
-                        || (in.getKey() != null && in.getKey().equals(item.getKey())))).
-                    findAny().orElse(null);
+                        ? null
+                        : list.stream().filter(
+                                in -> ((item.getKey() == null && in.getKey() == null)
+                                || (in.getKey() != null && in.getKey().equals(item.getKey())))).
+                                findAny().orElse(null);
             }
 
             @Override
@@ -196,12 +196,12 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
                         linkedAccountTO.getResource(),
                         model.getObject().getType(),
                         linkedAccountTO.getConnObjectKeyValue()),
-                    target);
+                        target);
                 target.add(mlp);
 
                 ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
                 send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
-                    new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
+                        new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
             }
         }, ActionLink.ActionType.VIEW, IdRepoEntitlement.USER_READ);
 
@@ -214,9 +214,9 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
                 public void onClick(final AjaxRequestTarget target, final LinkedAccountTO linkedAccountTO) {
                     try {
                         send(LinkedAccountModalPanel.this, Broadcast.DEPTH,
-                            new AjaxWizard.NewItemActionEvent<>(linkedAccountTO, 1, target).
-                                setResourceModel(new StringResourceModel("inner.edit.linkedAccount",
-                                    LinkedAccountModalPanel.this, Model.of(linkedAccountTO))));
+                                new AjaxWizard.NewItemActionEvent<>(linkedAccountTO, 1, target).
+                                        setTitleModel(new StringResourceModel("inner.edit.linkedAccount",
+                                                LinkedAccountModalPanel.this, Model.of(linkedAccountTO))));
                     } catch (SyncopeClientException e) {
                         LOG.error("While attempting to create new linked account", e);
                         SyncopeConsoleSession.get().onException(e);
@@ -224,7 +224,7 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
                     }
 
                     send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
-                        new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
+                            new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
                 }
             }, ActionLink.ActionType.EDIT, IdRepoEntitlement.USER_UPDATE);
 
@@ -237,8 +237,8 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
                     try {
                         linkedAccountTO.setSuspended(!linkedAccountTO.isSuspended());
                         LinkedAccountUR linkedAccountUR = new LinkedAccountUR.Builder().
-                            operation(PatchOperation.ADD_REPLACE).
-                            linkedAccountTO(linkedAccountTO).build();
+                                operation(PatchOperation.ADD_REPLACE).
+                                linkedAccountTO(linkedAccountTO).build();
 
                         UserUR req = new UserUR();
                         req.setKey(model.getObject().getKey());
@@ -261,55 +261,55 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
 
         builder.addAction(new ActionLink<>() {
 
-                  private static final long serialVersionUID = 2555747430358755813L;
-
-                  @Override
-                  public void onClick(final AjaxRequestTarget target, final LinkedAccountTO linkedAccountTO) {
-                      mlp.next("PUSH " + linkedAccountTO.getResource(),
-                          new ReconTaskPanel(
-                              linkedAccountTO.getResource(),
-                              new PushTaskTO(),
-                              model.getObject().getType(),
-                              null,
-                              ConnIdSpecialName.UID + "==" + linkedAccountTO.getConnObjectKeyValue(),
-                              true,
-                              mlp,
-                              pageRef),
-                          target);
-                      target.add(mlp);
-
-                      ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
-                      send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
-                          new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
-                  }
-              }, ActionLink.ActionType.RECONCILIATION_PUSH,
-            String.format("%s,%s", IdRepoEntitlement.USER_READ, IdRepoEntitlement.TASK_EXECUTE));
+            private static final long serialVersionUID = 2555747430358755813L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target, final LinkedAccountTO linkedAccountTO) {
+                mlp.next("PUSH " + linkedAccountTO.getResource(),
+                        new ReconTaskPanel(
+                                linkedAccountTO.getResource(),
+                                new PushTaskTO(),
+                                model.getObject().getType(),
+                                null,
+                                ConnIdSpecialName.UID + "==" + linkedAccountTO.getConnObjectKeyValue(),
+                                true,
+                                mlp,
+                                pageRef),
+                        target);
+                target.add(mlp);
+
+                ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
+                send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
+                        new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
+            }
+        }, ActionLink.ActionType.RECONCILIATION_PUSH,
+                String.format("%s,%s", IdRepoEntitlement.USER_READ, IdRepoEntitlement.TASK_EXECUTE));
 
         builder.addAction(new ActionLink<>() {
 
-                      private static final long serialVersionUID = 2555747430358755813L;
-
-                      @Override
-                      public void onClick(final AjaxRequestTarget target, final LinkedAccountTO linkedAccountTO) {
-                          mlp.next("PULL " + linkedAccountTO.getResource(),
-                              new ReconTaskPanel(
-                                  linkedAccountTO.getResource(),
-                                  new PullTaskTO(),
-                                  model.getObject().getType(),
-                                  null,
-                                  ConnIdSpecialName.UID + "==" + linkedAccountTO.getConnObjectKeyValue(),
-                                  true,
-                                  mlp,
-                                  pageRef),
-                              target);
-                          target.add(mlp);
-
-                          ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
-                          send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
-                              new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
-                      }
-                  }, ActionLink.ActionType.RECONCILIATION_PULL,
-            String.format("%s,%s", IdRepoEntitlement.USER_READ, IdRepoEntitlement.TASK_EXECUTE));
+            private static final long serialVersionUID = 2555747430358755813L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target, final LinkedAccountTO linkedAccountTO) {
+                mlp.next("PULL " + linkedAccountTO.getResource(),
+                        new ReconTaskPanel(
+                                linkedAccountTO.getResource(),
+                                new PullTaskTO(),
+                                model.getObject().getType(),
+                                null,
+                                ConnIdSpecialName.UID + "==" + linkedAccountTO.getConnObjectKeyValue(),
+                                true,
+                                mlp,
+                                pageRef),
+                        target);
+                target.add(mlp);
+
+                ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
+                send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
+                        new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
+            }
+        }, ActionLink.ActionType.RECONCILIATION_PULL,
+                String.format("%s,%s", IdRepoEntitlement.USER_READ, IdRepoEntitlement.TASK_EXECUTE));
 
         if (!recounciliationOnly) {
             builder.addAction(new ActionLink<>() {
@@ -320,8 +320,8 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
                 public void onClick(final AjaxRequestTarget target, final LinkedAccountTO linkedAccountTO) {
                     try {
                         LinkedAccountUR linkedAccountUR = new LinkedAccountUR.Builder().
-                            operation(PatchOperation.DELETE).
-                            linkedAccountTO(linkedAccountTO).build();
+                                operation(PatchOperation.DELETE).
+                                linkedAccountTO(linkedAccountTO).build();
 
                         UserUR req = new UserUR();
                         req.setKey(model.getObject().getKey());
@@ -356,12 +356,12 @@ public class LinkedAccountModalPanel extends Panel implements ModalPanel {
             @Override
             public void onClick(final AjaxRequestTarget target) {
                 send(LinkedAccountModalPanel.this, Broadcast.BREADTH,
-                    new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
+                        new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
 
                 // this opens the wizard (set above) in CREATE mode
                 send(list, Broadcast.DEPTH, new AjaxWizard.NewItemActionEvent<>(new LinkedAccountTO(), target).
-                    setResourceModel(
-                        new StringResourceModel("inner.create.linkedAccount", LinkedAccountModalPanel.this)));
+                        setTitleModel(
+                                new StringResourceModel("inner.create.linkedAccount", LinkedAccountModalPanel.this)));
             }
         };
         list.addOrReplaceInnerObject(addAjaxLink.setEnabled(!recounciliationOnly).setVisible(!recounciliationOnly));
diff --git a/client/idm/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java b/client/idm/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
index 3c59396028..cde123a787 100644
--- a/client/idm/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
+++ b/client/idm/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
@@ -85,20 +85,20 @@ public class ResourceProvisionPanel extends AbstractModalPanel<Serializable> {
         wizard = new ProvisionWizardBuilder(resourceTO, adminRealm, pageRef);
 
         ListViewPanel.Builder<ResourceProvision> builder = new ListViewPanel.Builder<>(
-            ResourceProvision.class, pageRef) {
+                ResourceProvision.class, pageRef) {
 
             private static final long serialVersionUID = 4907732721283972943L;
 
             @Override
             protected ResourceProvision getActualItem(
-                final ResourceProvision item, final List<ResourceProvision> list) {
+                    final ResourceProvision item, final List<ResourceProvision> list) {
 
                 return Optional.ofNullable(item).flatMap(resourceProvision -> list.stream()
-                    .filter(in -> ((resourceProvision.getKey() == null && in.getKey() == null)
+                        .filter(in -> ((resourceProvision.getKey() == null && in.getKey() == null)
                         || (in.getKey() != null && in.getKey().equals(resourceProvision.getKey())))
                         && ((resourceProvision.getAnyType() == null && in.getAnyType() == null)
                         || (in.getAnyType() != null && in.getAnyType().equals(resourceProvision.getAnyType())))).
-                    findAny()).orElse(null);
+                        findAny()).orElse(null);
             }
 
             @Override
@@ -150,10 +150,10 @@ public class ResourceProvisionPanel extends AbstractModalPanel<Serializable> {
             public void onClick(final AjaxRequestTarget target, final ResourceProvision provision) {
                 try {
                     send(ResourceProvisionPanel.this, Broadcast.DEPTH,
-                        new AjaxWizard.NewItemActionEvent<>(provision, 1, target).setResourceModel(
-                            new StringResourceModel("inner.provision.mapping",
-                                ResourceProvisionPanel.this,
-                                Model.of(provision))));
+                            new AjaxWizard.NewItemActionEvent<>(provision, 1, target).setTitleModel(
+                                    new StringResourceModel("inner.provision.mapping",
+                                            ResourceProvisionPanel.this,
+                                            Model.of(provision))));
                 } catch (SyncopeClientException e) {
                     LOG.error("While contacting resource", e);
                     SyncopeConsoleSession.get().onException(e);
@@ -172,7 +172,7 @@ public class ResourceProvisionPanel extends AbstractModalPanel<Serializable> {
                             SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
                         } catch (Exception e) {
                             LOG.error("While setting latest sync token for {}/{}",
-                                resourceTO.getKey(), provision.getAnyType(), e);
+                                    resourceTO.getKey(), provision.getAnyType(), e);
                             SyncopeConsoleSession.get().onException(e);
                         }
                         ((BaseWebPage) pageRef.getPage()).getNotificationPanel().refresh(target);
@@ -189,7 +189,7 @@ public class ResourceProvisionPanel extends AbstractModalPanel<Serializable> {
                             SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
                         } catch (Exception e) {
                             LOG.error("While removing sync token for {}/{}",
-                                resourceTO.getKey(), provision.getAnyType(), e);
+                                    resourceTO.getKey(), provision.getAnyType(), e);
                             SyncopeConsoleSession.get().onException(e);
                         }
                         ((BaseWebPage) pageRef.getPage()).getNotificationPanel().refresh(target);
@@ -224,7 +224,7 @@ public class ResourceProvisionPanel extends AbstractModalPanel<Serializable> {
             @Override
             public void onClick(final AjaxRequestTarget target) {
                 send(ResourceProvisionPanel.this, Broadcast.BREADTH,
-                    new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
+                        new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
                 objectTypeTogglePanel.setHeaderLabel(target);
                 objectTypeTogglePanel.toggle(target, true);
             }
@@ -305,8 +305,8 @@ public class ResourceProvisionPanel extends AbstractModalPanel<Serializable> {
             @Override
             protected List<String> load() {
                 List<String> anyTypes = AnyTypeRestClient.list().stream().
-                    filter(anyType -> resourceTO.getProvision(anyType).isEmpty()).
-                    collect(Collectors.toList());
+                        filter(anyType -> resourceTO.getProvision(anyType).isEmpty()).
+                        collect(Collectors.toList());
                 if (resourceTO.getOrgUnit() == null) {
                     anyTypes.add(SyncopeConstants.REALM_ANYTYPE);
                 }
diff --git a/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AjaxWizard.java b/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AjaxWizard.java
index 5011e9d412..c4d95375ae 100644
--- a/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AjaxWizard.java
+++ b/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AjaxWizard.java
@@ -281,7 +281,7 @@ public abstract class AjaxWizard<T extends Serializable> extends Wizard
 
         private final T item;
 
-        private IModel<String> resourceModel;
+        private IModel<String> titleModel;
 
         private final AjaxRequestTarget target;
 
@@ -309,12 +309,12 @@ public abstract class AjaxWizard<T extends Serializable> extends Wizard
             return this;
         }
 
-        public IModel<String> getResourceModel() {
-            return resourceModel;
+        public IModel<String> getTitleModel() {
+            return titleModel;
         }
 
-        public NewItemEvent<T> setResourceModel(final IModel<String> resourceModel) {
-            this.resourceModel = resourceModel;
+        public NewItemEvent<T> setTitleModel(final IModel<String> titleModel) {
+            this.titleModel = titleModel;
             return this;
         }
 
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Realms.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Realms.java
index ac51e04040..c94be75621 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Realms.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/pages/Realms.java
@@ -156,7 +156,7 @@ public class Realms extends BasePage {
             if (event.getPayload() instanceof AjaxWizard.NewItemActionEvent && modalPanel != null) {
                 final IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
                 templateModal.setFormModel(model);
-                templateModal.header(newItemEvent.getResourceModel());
+                templateModal.header(newItemEvent.getTitleModel());
                 newItemEvent.getTarget().ifPresent(t -> t.add(templateModal.setContent(modalPanel)));
                 templateModal.show(true);
             } else if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskDirectoryPanel.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskDirectoryPanel.java
index 7a0e48abba..6c19458792 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskDirectoryPanel.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/SchedTaskDirectoryPanel.java
@@ -271,7 +271,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
                 send(SchedTaskDirectoryPanel.this, Broadcast.EXACT,
                         new AjaxWizard.EditItemActionEvent<>(
                                 TaskRestClient.readTask(taskType, model.getObject().getKey()),
-                                target).setResourceModel(
+                                target).setTitleModel(
                                 new StringResourceModel("inner.task.edit",
                                         SchedTaskDirectoryPanel.this,
                                         Model.of(Pair.of(ActionLink.ActionType.EDIT, model.getObject())))));
@@ -288,7 +288,7 @@ public abstract class SchedTaskDirectoryPanel<T extends SchedTaskTO>
                 final T clone = SerializationUtils.clone(model.getObject());
                 clone.setKey(null);
                 send(SchedTaskDirectoryPanel.this, Broadcast.EXACT,
-                        new AjaxWizard.EditItemActionEvent<>(clone, target).setResourceModel(
+                        new AjaxWizard.EditItemActionEvent<>(clone, target).setTitleModel(
                                 new StringResourceModel("inner.task.clone",
                                         SchedTaskDirectoryPanel.this,
                                         Model.of(Pair.of(ActionLink.ActionType.CLONE, model.getObject())))));
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
index 8a0f0d5d8a..2a0b135e8f 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
@@ -97,7 +97,7 @@ public abstract class TemplatesTogglePanel extends TogglePanel<Serializable> {
                     final AjaxWizard.NewItemActionEvent<AnyTO> payload =
                             new AjaxWizard.NewItemActionEvent<>(null, target);
 
-                    payload.setResourceModel(new StringResourceModel("inner.template.edit", container,
+                    payload.setTitleModel(new StringResourceModel("inner.template.edit", container,
                             Model.of(Pair.of(typeModel.getObject(), targetObject))).setDefaultValue(
                             "Edit template"));
 
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
index c79f0bde58..bf636c25f4 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
@@ -47,8 +47,6 @@ import org.apache.wicket.markup.html.list.ListItem;
 import org.apache.wicket.markup.html.list.ListView;
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.CompoundPropertyModel;
-import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.model.StringResourceModel;
 
@@ -58,9 +56,9 @@ public abstract class WizardMgtPanel<T extends Serializable> extends AbstractWiz
 
     private boolean readOnly = false;
 
-    private final String actualId;
+    protected final String actualId;
 
-    private final WebMarkupContainer container;
+    protected final WebMarkupContainer container;
 
     protected final Fragment initialFragment;
 
@@ -198,25 +196,27 @@ public abstract class WizardMgtPanel<T extends Serializable> extends AbstractWiz
                 }
 
                 if (wizardInModal) {
-                    IModel<T> model = new CompoundPropertyModel<>(item);
-                    modal.setFormModel(model);
+                    modal.setFormModel(item);
 
                     target.ifPresent(t -> t.add(modal.setContent(modalPanel)));
 
-                    modal.header(new StringResourceModel(
-                            String.format("any.%s", newItemEvent.getEventDescription()),
-                            this,
-                            new Model<>(modalPanel.getItem())));
+                    modal.header(Optional.ofNullable(newItemEvent.getTitleModel()).
+                            orElse(new StringResourceModel(
+                                    String.format("any.%s", newItemEvent.getEventDescription()),
+                                    this,
+                                    Model.of(modalPanel.getItem()))));
                     modal.show(true);
                 } else {
                     Fragment fragment = new Fragment("content", "wizard", WizardMgtPanel.this);
 
-                    fragment.add(new Label("title", newItemEvent.getResourceModel() == null
-                            ? Model.of(StringUtils.EMPTY) : newItemEvent.getResourceModel()));
+                    fragment.add(new Label(
+                            "title",
+                            Optional.ofNullable(newItemEvent.getTitleModel()).orElse(Model.of(StringUtils.EMPTY))));
 
                     fragment.add(Component.class.cast(modalPanel));
                     container.addOrReplace(fragment);
                 }
+
                 target.ifPresent(this::customActionCallback);
             } else if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
                 if (wizardInModal) {
@@ -224,6 +224,7 @@ public abstract class WizardMgtPanel<T extends Serializable> extends AbstractWiz
                 } else {
                     container.addOrReplace(initialFragment);
                 }
+
                 target.ifPresent(this::customActionOnCancelCallback);
             } else if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
                 SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
@@ -256,6 +257,7 @@ public abstract class WizardMgtPanel<T extends Serializable> extends AbstractWiz
                 } else {
                     container.addOrReplace(initialFragment);
                 }
+
                 target.ifPresent(this::customActionOnFinishCallback);
             }
 
diff --git a/ext/oidcc4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/OIDCProvidersDirectoryPanel.java b/ext/oidcc4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/OIDCProvidersDirectoryPanel.java
index 8c17043d79..b93fff88e9 100644
--- a/ext/oidcc4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/OIDCProvidersDirectoryPanel.java
+++ b/ext/oidcc4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/OIDCProvidersDirectoryPanel.java
@@ -123,7 +123,7 @@ public class OIDCProvidersDirectoryPanel extends DirectoryPanel<
             public void updateHeader(final AjaxRequestTarget target, final Serializable object) {
                 if (object instanceof OIDCC4UIProviderTO) {
                     setHeader(target,
-                        StringUtils.abbreviate(((OIDCC4UIProviderTO) object).getName(), HEADER_FIRST_ABBREVIATION));
+                            StringUtils.abbreviate(((OIDCC4UIProviderTO) object).getName(), HEADER_FIRST_ABBREVIATION));
                 } else {
                     super.updateHeader(target, object);
                 }
@@ -165,7 +165,7 @@ public class OIDCProvidersDirectoryPanel extends DirectoryPanel<
             public void onClick(final AjaxRequestTarget target, final OIDCC4UIProviderTO ignore) {
                 OIDCC4UIProviderTO object = OIDCProviderRestClient.read(model.getObject().getKey());
                 send(OIDCProvidersDirectoryPanel.this, Broadcast.EXACT,
-                    new AjaxWizard.EditItemActionEvent<>(object, target));
+                        new AjaxWizard.EditItemActionEvent<>(object, target));
                 modal.header(Model.of(StringUtils.capitalize(("Edit " + object.getName()))));
             }
         }, ActionLink.ActionType.EDIT, OIDC4UIEntitlement.OP_UPDATE);
@@ -179,10 +179,10 @@ public class OIDCProvidersDirectoryPanel extends DirectoryPanel<
                 final OIDCC4UIProviderTO object = OIDCProviderRestClient.read(model.getObject().getKey());
 
                 UserTemplateWizardBuilder builder = new UserTemplateWizardBuilder(
-                    object.getUserTemplate(),
-                    AnyTypeRestClient.read(AnyTypeKind.USER.name()).getClasses(),
-                    new UserFormLayoutInfo(),
-                    pageRef) {
+                        object.getUserTemplate(),
+                        AnyTypeRestClient.read(AnyTypeKind.USER.name()).getClasses(),
+                        new UserFormLayoutInfo(),
+                        pageRef) {
 
                     private static final long serialVersionUID = -7978723352517770634L;
 
@@ -195,7 +195,7 @@ public class OIDCProvidersDirectoryPanel extends DirectoryPanel<
                     }
                 };
                 templateModal.header(Model.of(StringUtils.capitalize(
-                    new StringResourceModel("template.title", OIDCProvidersDirectoryPanel.this).getString())));
+                        new StringResourceModel("template.title", OIDCProvidersDirectoryPanel.this).getString())));
                 templateModal.setContent(builder.build(BaseModal.CONTENT_ID));
                 templateModal.show(true);
                 target.add(templateModal);
@@ -232,9 +232,9 @@ public class OIDCProvidersDirectoryPanel extends DirectoryPanel<
             WizardModalPanel<?> modalPanel = newItemEvent.getModalPanel();
 
             if (newItemEvent instanceof AjaxWizard.NewItemActionEvent && modalPanel != null) {
-                final IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
+                IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
                 templateModal.setFormModel(model);
-                templateModal.header(newItemEvent.getResourceModel());
+                templateModal.header(newItemEvent.getTitleModel());
                 newItemEvent.getTarget().ifPresent(target -> target.add(templateModal.setContent(modalPanel)));
                 templateModal.show(true);
             } else if (newItemEvent instanceof AjaxWizard.NewItemCancelEvent) {
diff --git a/ext/saml2sp4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/SAML2IdPsDirectoryPanel.java b/ext/saml2sp4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/SAML2IdPsDirectoryPanel.java
index 40470a3291..4a72fbe3dc 100644
--- a/ext/saml2sp4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/SAML2IdPsDirectoryPanel.java
+++ b/ext/saml2sp4ui/client-console/src/main/java/org/apache/syncope/client/console/panels/SAML2IdPsDirectoryPanel.java
@@ -148,7 +148,7 @@ public class SAML2IdPsDirectoryPanel extends DirectoryPanel<
             public void updateHeader(final AjaxRequestTarget target, final Serializable modelObject) {
                 if (modelObject instanceof SAML2SP4UIIdPTO) {
                     setHeader(target, StringUtils.abbreviate(
-                        ((SAML2SP4UIIdPTO) modelObject).getName(), HEADER_FIRST_ABBREVIATION));
+                            ((SAML2SP4UIIdPTO) modelObject).getName(), HEADER_FIRST_ABBREVIATION));
                 } else {
                     super.updateHeader(target, modelObject);
                 }
@@ -194,10 +194,10 @@ public class SAML2IdPsDirectoryPanel extends DirectoryPanel<
                 SAML2SP4UIIdPTO object = SAML2IdPsRestClient.read(model.getObject().getKey());
                 metadataModal.header(Model.of(object.getName() + " - Metadata"));
                 metadataModal.setContent(new XMLEditorPanel(
-                    metadataModal,
-                    Model.of(new String(Base64.getMimeDecoder().decode(object.getMetadata()))),
-                    true,
-                    pageRef));
+                        metadataModal,
+                        Model.of(new String(Base64.getMimeDecoder().decode(object.getMetadata()))),
+                        true,
+                        pageRef));
                 metadataModal.show(true);
                 target.add(metadataModal);
             }
@@ -210,7 +210,7 @@ public class SAML2IdPsDirectoryPanel extends DirectoryPanel<
             public void onClick(final AjaxRequestTarget target, final SAML2SP4UIIdPTO ignore) {
                 SAML2SP4UIIdPTO object = SAML2IdPsRestClient.read(model.getObject().getKey());
                 send(SAML2IdPsDirectoryPanel.this, Broadcast.EXACT,
-                    new AjaxWizard.EditItemActionEvent<>(object, target));
+                        new AjaxWizard.EditItemActionEvent<>(object, target));
             }
         }, ActionLink.ActionType.EDIT, SAML2SP4UIEntitlement.IDP_UPDATE);
         panel.add(new ActionLink<>() {
@@ -222,10 +222,10 @@ public class SAML2IdPsDirectoryPanel extends DirectoryPanel<
                 final SAML2SP4UIIdPTO object = SAML2IdPsRestClient.read(model.getObject().getKey());
 
                 UserTemplateWizardBuilder builder = new UserTemplateWizardBuilder(
-                    object.getUserTemplate(),
-                    AnyTypeRestClient.read(AnyTypeKind.USER.name()).getClasses(),
-                    new UserFormLayoutInfo(),
-                    pageRef) {
+                        object.getUserTemplate(),
+                        AnyTypeRestClient.read(AnyTypeKind.USER.name()).getClasses(),
+                        new UserFormLayoutInfo(),
+                        pageRef) {
 
                     private static final long serialVersionUID = -7978723352517770634L;
 
@@ -238,7 +238,7 @@ public class SAML2IdPsDirectoryPanel extends DirectoryPanel<
                     }
                 };
                 templateModal.header(Model.of(StringUtils.capitalize(
-                    new StringResourceModel("template.title", SAML2IdPsDirectoryPanel.this).getString())));
+                        new StringResourceModel("template.title", SAML2IdPsDirectoryPanel.this).getString())));
                 templateModal.setContent(builder.build(BaseModal.CONTENT_ID));
                 templateModal.show(true);
                 target.add(templateModal);
@@ -275,9 +275,9 @@ public class SAML2IdPsDirectoryPanel extends DirectoryPanel<
             WizardModalPanel<?> modalPanel = newItemEvent.getModalPanel();
 
             if (newItemEvent instanceof AjaxWizard.NewItemActionEvent && modalPanel != null) {
-                final IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
+                IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
                 templateModal.setFormModel(model);
-                templateModal.header(newItemEvent.getResourceModel());
+                templateModal.header(newItemEvent.getTitleModel());
                 newItemEvent.getTarget().ifPresent(target -> target.add(templateModal.setContent(modalPanel)));
                 templateModal.show(true);
             } else if (newItemEvent instanceof AjaxWizard.NewItemCancelEvent) {


[syncope] 02/05: Allowing override

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0026b41a6bdee26479426ebe1192df4bfd98c8c2
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Jan 27 08:55:24 2023 +0100

    Allowing override
---
 .../org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
index 714553b43b..dc0989869c 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
@@ -29,7 +29,7 @@ public class AnyObjectDetails extends Details<AnyObjectTO> {
 
     private static final long serialVersionUID = 855618618337931784L;
 
-    protected final AjaxTextFieldPanel name;
+    protected AjaxTextFieldPanel name;
 
     public AnyObjectDetails(
             final AnyWrapper<AnyObjectTO> wrapper,