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 2025/05/13 10:32:03 UTC
(syncope) branch master updated (80665a9707 -> a75a07a630)
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 80665a9707 [SYNCOPE-1879] managing ConnectorObjectIdentification serialization/deserialization (#1076)
new bd74b2a3f3 [SYNCOPE-1878] Refactoring PriorityPropagationTaskExecutor
new 2510cbece1 [SYNCOPE-1881] Ensure to fetch the SP metadata value from the matching AuthModule instance
new a75a07a630 Upgrading Tomcat
The 3 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/wizards/AuthModuleWizardBuilder.java | 31 +++++++-
.../api/propagation/PropagationTaskCallable.java | 32 --------
.../DefaultPropagationTaskCallable.java | 88 ----------------------
.../PriorityPropagationTaskExecutor.java | 66 ++++++++++------
pom.xml | 2 +-
.../pac4j/saml/WASAML2ClientMetadataGenerator.java | 67 ++++++++++++++--
.../pac4j/saml/WASAML2MetadataResolver.java | 4 +-
7 files changed, 132 insertions(+), 158 deletions(-)
delete mode 100644 core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskCallable.java
delete mode 100644 core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/DefaultPropagationTaskCallable.java
(syncope) 01/03: [SYNCOPE-1878] Refactoring PriorityPropagationTaskExecutor
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 bd74b2a3f3f6b5cf13075c26935e9c86eb2f7480
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue May 13 10:49:59 2025 +0200
[SYNCOPE-1878] Refactoring PriorityPropagationTaskExecutor
---
.../api/propagation/PropagationTaskCallable.java | 32 --------
.../DefaultPropagationTaskCallable.java | 88 ----------------------
.../PriorityPropagationTaskExecutor.java | 66 ++++++++++------
3 files changed, 41 insertions(+), 145 deletions(-)
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskCallable.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskCallable.java
deleted file mode 100644
index c7a1877714..0000000000
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskCallable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.api.propagation;
-
-import java.util.concurrent.Callable;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
-
-public interface PropagationTaskCallable extends Callable<TaskExec<PropagationTask>> {
-
- void setTaskInfo(PropagationTaskInfo taskInfo);
-
- void setReporter(PropagationReporter reporter);
-
- void setExecutor(String executor);
-}
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/DefaultPropagationTaskCallable.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/DefaultPropagationTaskCallable.java
deleted file mode 100644
index 8f92e03e68..0000000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/DefaultPropagationTaskCallable.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.propagation;
-
-import java.util.Collection;
-import java.util.stream.Collectors;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskCallable;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskInfo;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-public class DefaultPropagationTaskCallable implements PropagationTaskCallable {
-
- protected static final Logger LOG = LoggerFactory.getLogger(PropagationTaskCallable.class);
-
- @Autowired
- protected PropagationTaskExecutor taskExecutor;
-
- protected final String domain;
-
- protected final Collection<String> authorities;
-
- protected PropagationTaskInfo taskInfo;
-
- protected PropagationReporter reporter;
-
- protected String executor;
-
- public DefaultPropagationTaskCallable() {
- SecurityContext ctx = SecurityContextHolder.getContext();
- domain = AuthContextUtils.getDomain();
- authorities = ctx.getAuthentication().getAuthorities().stream().
- map(GrantedAuthority::getAuthority).collect(Collectors.toSet());
- }
-
- @Override
- public void setTaskInfo(final PropagationTaskInfo taskInfo) {
- this.taskInfo = taskInfo;
- }
-
- @Override
- public void setReporter(final PropagationReporter reporter) {
- this.reporter = reporter;
- }
-
- @Override
- public void setExecutor(final String executor) {
- this.executor = executor;
- }
-
- @Override
- public TaskExec<PropagationTask> call() {
- return AuthContextUtils.callAs(domain, executor, authorities, () -> {
- LOG.debug("Execution started for {}", taskInfo);
-
- TaskExec<PropagationTask> execution = taskExecutor.execute(taskInfo, reporter, executor);
-
- LOG.debug("Execution completed for {}, {}", taskInfo, execution);
-
- return execution;
- });
- }
-}
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PriorityPropagationTaskExecutor.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PriorityPropagationTaskExecutor.java
index a95a20d09c..f4bfc86950 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PriorityPropagationTaskExecutor.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PriorityPropagationTaskExecutor.java
@@ -23,11 +23,13 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future;
+import java.util.stream.Collectors;
import org.apache.syncope.common.lib.types.ExecStatus;
-import org.apache.syncope.core.persistence.api.ApplicationContextProvider;
import org.apache.syncope.core.persistence.api.attrvalue.PlainAttrValidationManager;
import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
@@ -43,12 +45,14 @@ import org.apache.syncope.core.provisioning.api.data.TaskDataBinder;
import org.apache.syncope.core.provisioning.api.notification.NotificationManager;
import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskCallable;
import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskInfo;
import org.apache.syncope.core.provisioning.java.pushpull.OutboundMatcher;
import org.apache.syncope.core.provisioning.java.utils.ConnObjectUtils;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.apache.syncope.core.spring.task.VirtualThreadPoolTaskExecutor;
import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
/**
* Sorts the tasks to be executed according to related
@@ -59,28 +63,6 @@ import org.springframework.context.ApplicationEventPublisher;
*/
public class PriorityPropagationTaskExecutor extends AbstractPropagationTaskExecutor {
- /**
- * Creates new instances of {@link PropagationTaskCallable} for usage with
- * {@link java.util.concurrent.CompletionService}.
- *
- * @param taskInfo to be executed
- * @param reporter to report propagation execution status
- * @param executor user that triggered the propagation execution
- * @return new {@link PropagationTaskCallable} instance for usage with
- * {@link java.util.concurrent.CompletionService}
- */
- protected PropagationTaskCallable newPropagationTaskCallable(
- final PropagationTaskInfo taskInfo, final PropagationReporter reporter, final String executor) {
-
- PropagationTaskCallable callable = ApplicationContextProvider.getBeanFactory().
- createBean(DefaultPropagationTaskCallable.class);
- callable.setTaskInfo(taskInfo);
- callable.setReporter(reporter);
- callable.setExecutor(executor);
-
- return callable;
- }
-
protected final VirtualThreadPoolTaskExecutor taskExecutor;
public PriorityPropagationTaskExecutor(
@@ -115,6 +97,40 @@ public class PriorityPropagationTaskExecutor extends AbstractPropagationTaskExec
this.taskExecutor = taskExecutor;
}
+ /**
+ * Creates new instances of {@link Callable} for usage with{@link java.util.concurrent.CompletionService}.
+ *
+ * @param taskInfo to be executed
+ * @param reporter to report propagation execution status
+ * @param executor user that triggered the propagation execution
+ * @return new {@link Callable} instance for usage with {@link java.util.concurrent.CompletionService}
+ */
+ protected Callable<TaskExec<PropagationTask>> newPropagationTaskCallable(
+ final PropagationTaskInfo taskInfo, final PropagationReporter reporter, final String executor) {
+
+ String domain = AuthContextUtils.getDomain();
+ Set<String> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities().stream().
+ map(GrantedAuthority::getAuthority).collect(Collectors.toSet());
+
+ return () -> AuthContextUtils.callAs(domain, executor, authorities, () -> {
+ LOG.debug("Execution started for {}", taskInfo);
+
+ TaskExec<PropagationTask> execution = this.execute(taskInfo, reporter, executor);
+
+ LOG.debug("Execution completed for {} with results {}", taskInfo, execution);
+
+ return execution;
+ });
+ }
+
+ protected boolean failed(
+ final PropagationTaskInfo taskInfpo,
+ final TaskExec<PropagationTask> exec,
+ final ExecStatus execStatus) {
+
+ return execStatus == ExecStatus.FAILURE;
+ }
+
@Override
public PropagationReporter execute(
final Collection<PropagationTaskInfo> taskInfos,
@@ -147,7 +163,7 @@ public class PriorityPropagationTaskExecutor extends AbstractPropagationTaskExec
execStatus = ExecStatus.FAILURE;
errorMessage = e.getMessage();
}
- if (execStatus == ExecStatus.FAILURE) {
+ if (failed(taskInfo, exec, execStatus)) {
throw new PropagationException(
taskInfo.getResource().getKey(),
Optional.ofNullable(exec).map(Exec::getMessage).orElse(errorMessage));
(syncope) 03/03: Upgrading Tomcat
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 a75a07a6301303de56f177d4df4d900621cba2eb
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue May 13 12:22:25 2025 +0200
Upgrading Tomcat
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 077518150d..8b21e6dc9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -503,7 +503,7 @@ under the License.
<cargo.rmi.port>9805</cargo.rmi.port>
<cargo.deployable.ping.timeout>60000</cargo.deployable.ping.timeout>
- <tomcat.version>11.0.6</tomcat.version>
+ <tomcat.version>11.0.7</tomcat.version>
<wildfly.version>36.0.0.Final</wildfly.version>
<payara.version>6.2025.4</payara.version>
<jakarta.faces.version>4.1.3</jakarta.faces.version>
(syncope) 02/03: [SYNCOPE-1881] Ensure to fetch the SP metadata value from the matching AuthModule instance
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 2510cbece1cc20384a13b26a34bfe8ab3c03547d
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue May 13 12:09:49 2025 +0200
[SYNCOPE-1881] Ensure to fetch the SP metadata value from the matching AuthModule instance
---
.../console/wizards/AuthModuleWizardBuilder.java | 31 +++++++++-
.../pac4j/saml/WASAML2ClientMetadataGenerator.java | 67 +++++++++++++++++++---
.../pac4j/saml/WASAML2MetadataResolver.java | 4 +-
3 files changed, 90 insertions(+), 12 deletions(-)
diff --git a/client/am/console/src/main/java/org/apache/syncope/client/console/wizards/AuthModuleWizardBuilder.java b/client/am/console/src/main/java/org/apache/syncope/client/console/wizards/AuthModuleWizardBuilder.java
index 2dac0c7875..6afacdc038 100644
--- a/client/am/console/src/main/java/org/apache/syncope/client/console/wizards/AuthModuleWizardBuilder.java
+++ b/client/am/console/src/main/java/org/apache/syncope/client/console/wizards/AuthModuleWizardBuilder.java
@@ -19,6 +19,8 @@
package org.apache.syncope.client.console.wizards;
import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
@@ -205,8 +207,33 @@ public class AuthModuleWizardBuilder extends BaseAjaxWizardBuilder<AuthModuleTO>
return pageRef;
}
});
- add(new XMLEditorPanel(null,
- new PropertyModel<>(authModule, "conf.serviceProviderMetadata"), false, pageRef));
+ add(new XMLEditorPanel(null, new IModel<String>() {
+
+ private static final long serialVersionUID = -6439061267623081672L;
+
+ @Override
+ public String getObject() {
+ SAML2IdPAuthModuleConf conf = (SAML2IdPAuthModuleConf) authModule.getConf();
+ if (StringUtils.isEmpty(conf.getServiceProviderMetadata())) {
+ return null;
+ }
+
+ return new String(
+ Base64.getDecoder().decode(conf.getServiceProviderMetadata()),
+ StandardCharsets.UTF_8);
+ }
+
+ @Override
+ public void setObject(final String object) {
+ SAML2IdPAuthModuleConf conf = (SAML2IdPAuthModuleConf) authModule.getConf();
+ if (StringUtils.isEmpty(object)) {
+ conf.setServiceProviderMetadata(null);
+ } else {
+ conf.setServiceProviderMetadata(Base64.getEncoder().
+ encodeToString(object.getBytes(StandardCharsets.UTF_8)));
+ }
+ }
+ }, false, pageRef));
}
@Override
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2ClientMetadataGenerator.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2ClientMetadataGenerator.java
index 9f90207dca..eaadfdd8a2 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2ClientMetadataGenerator.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2ClientMetadataGenerator.java
@@ -20,11 +20,13 @@ package org.apache.syncope.wa.starter.pac4j.saml;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
+import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.apache.syncope.common.rest.api.service.wa.WASAML2SPService;
import org.apache.syncope.wa.bootstrap.WARestClient;
import org.opensaml.saml.metadata.resolver.MetadataResolver;
import org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.pac4j.saml.client.SAML2Client;
import org.pac4j.saml.metadata.BaseSAML2MetadataGenerator;
import org.slf4j.Logger;
@@ -48,6 +50,52 @@ public class WASAML2ClientMetadataGenerator extends BaseSAML2MetadataGenerator {
return true;
}
+ protected Optional<String> metadataAvailable() {
+ try {
+ String encodedMetadata = waRestClient.getService(WASAML2SPService.class).
+ getSAML2SPMetadata(saml2Client.getName()).readEntity(String.class);
+
+ LOG.debug("Retrieved metadata {}", encodedMetadata);
+ return Optional.of(new String(Base64.getDecoder().decode(encodedMetadata), StandardCharsets.UTF_8));
+ } catch (Exception e) {
+ LOG.error("While attempting to read metadata for SP Entity {}", saml2Client.getName(), e);
+ return Optional.empty();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return {@code null} if metadata was found in Syncope Core via REST
+ */
+ @Override
+ public EntityDescriptor buildEntityDescriptor() {
+ return metadataAvailable().
+ map(m -> (EntityDescriptor) null).
+ orElseGet(() -> {
+ EntityDescriptor entityDescriptor = super.buildEntityDescriptor();
+ entityDescriptor.setValidUntil(null);
+ if (signMetadata) {
+ signMetadata(entityDescriptor);
+ }
+ return entityDescriptor;
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * return metadata from Syncope Core via REST, if available; otherwise, generate
+ */
+ @Override
+ public String getMetadata(final EntityDescriptor entityDescriptor) throws Exception {
+ String metadata = metadataAvailable().orElse(null);
+ if (metadata == null) {
+ return super.getMetadata(entityDescriptor);
+ }
+ return metadata;
+ }
+
@Override
protected AbstractMetadataResolver createMetadataResolver() {
return new WASAML2MetadataResolver(waRestClient, saml2Client);
@@ -55,15 +103,18 @@ public class WASAML2ClientMetadataGenerator extends BaseSAML2MetadataGenerator {
@Override
public MetadataResolver buildMetadataResolver() throws Exception {
- String encodedMetadata = Base64.getEncoder().encodeToString(
- getMetadata(buildEntityDescriptor()).getBytes(StandardCharsets.UTF_8));
- LOG.debug("Encoded SP metadata {}", encodedMetadata);
+ EntityDescriptor entityDescriptor = buildEntityDescriptor();
+ if (entityDescriptor != null) {
+ String encodedMetadata = Base64.getEncoder().encodeToString(
+ getMetadata(entityDescriptor).getBytes(StandardCharsets.UTF_8));
+ LOG.debug("Encoded SP metadata {}", encodedMetadata);
- try {
- waRestClient.getService(WASAML2SPService.class).setSAML2SPMetadata(
- saml2Client.getName(), IOUtils.toInputStream(encodedMetadata, StandardCharsets.UTF_8));
- } catch (Exception e) {
- LOG.error("While storing SP {} metadata", saml2Client.getName(), e);
+ try {
+ waRestClient.getService(WASAML2SPService.class).setSAML2SPMetadata(
+ saml2Client.getName(), IOUtils.toInputStream(encodedMetadata, StandardCharsets.UTF_8));
+ } catch (Exception e) {
+ LOG.error("While storing SP {} metadata", saml2Client.getName(), e);
+ }
}
return super.buildMetadataResolver();
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2MetadataResolver.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2MetadataResolver.java
index 1788e31baf..da9b3ea7a0 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2MetadataResolver.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/pac4j/saml/WASAML2MetadataResolver.java
@@ -51,10 +51,10 @@ public class WASAML2MetadataResolver extends AbstractReloadingMetadataResolver {
String encodedMetadata = waRestClient.getService(WASAML2SPService.class).
getSAML2SPMetadata(saml2Client.getName()).readEntity(String.class);
- LOG.debug("Retrieved keystore {}", encodedMetadata);
+ LOG.debug("Retrieved metadata {}", encodedMetadata);
return Base64.getDecoder().decode(encodedMetadata);
} catch (Exception e) {
- String message = "Unable to fetch SP metadata for " + saml2Client.getName();
+ String message = "Unable to fetch SP metadata for SP entity " + saml2Client.getName();
LOG.error(message, e);
throw new ResolverException(message);
}