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/03/30 08:58:37 UTC
[syncope] branch 3_0_X updated: [SYNCOPE-1747] Better WA push controls in Console (#432)
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/3_0_X by this push:
new c103eb788b [SYNCOPE-1747] Better WA push controls in Console (#432)
c103eb788b is described below
commit c103eb788bca2ecad7bb80b4a10b83b145cef5a5
Author: Francesco Chicchiriccò <il...@users.noreply.github.com>
AuthorDate: Thu Mar 30 10:58:30 2023 +0200
[SYNCOPE-1747] Better WA push controls in Console (#432)
---
.../apache/syncope/client/console/pages/WA.java | 28 ++++---
.../client/console/panels/WAConfigModalPanel.java | 2 +
.../client/console/panels/WAPushModalPanel.java | 81 ++++++++++++++++++++
.../client/console/rest/WAConfigRestClient.java | 4 +-
.../apache/syncope/client/console/pages/WA.html | 2 +
.../syncope/client/console/pages/WA.properties | 2 +
.../client/console/pages/WA_fr_CA.properties | 2 +
.../syncope/client/console/pages/WA_it.properties | 2 +
.../syncope/client/console/pages/WA_ja.properties | 2 +
.../client/console/pages/WA_pt_BR.properties | 2 +
.../syncope/client/console/pages/WA_ru.properties | 2 +
.../client/console/panels/WAPushModalPanel.html | 26 +++++++
.../WAPushModalPanel.properties} | 11 +--
.../WAPushModalPanel_fr_CA.properties} | 11 +--
.../WAPushModalPanel_it.properties} | 11 +--
.../WAPushModalPanel_ja.properties} | 11 +--
.../WAPushModalPanel_pt_BR.properties} | 11 +--
.../WAPushModalPanel_ru.properties} | 11 +--
.../ui/commons/wizards/AbstractWizardMgtPanel.java | 1 -
.../panels/DisplayAttributesModalPanel.java | 18 ++---
.../syncope/common/lib/types/AMEntitlement.java | 2 -
.../common/rest/api/service/ClientAppService.java | 7 --
.../rest/api/service/wa/WAConfigService.java | 17 ++++-
.../apache/syncope/core/logic/AMLogicContext.java | 10 +--
.../apache/syncope/core/logic/ClientAppLogic.java | 40 +---------
.../syncope/core/logic/wa/WAConfigLogic.java | 50 ++++++++++---
.../rest/cxf/service/ClientAppServiceImpl.java | 5 --
.../rest/cxf/service/wa/WAConfigServiceImpl.java | 4 +-
.../provisioning/java/ProvisioningContext.java | 12 +--
...e.java => AbstractNotificationJobDelegate.java} | 51 ++-----------
.../notification/MailNotificationJobDelegate.java | 87 ++++++++++++++++++++++
.../org/apache/syncope/fit/AbstractITCase.java | 4 +
.../org/apache/syncope/fit/sra/CASSRAITCase.java | 3 +-
.../org/apache/syncope/fit/sra/OIDCSRAITCase.java | 3 +-
.../org/apache/syncope/fit/sra/SAML2SRAITCase.java | 3 +-
.../org/apache/syncope/fit/ui/OIDC4UIITCase.java | 3 +-
.../apache/syncope/fit/ui/SAML2SP4UIITCase.java | 3 +-
wa/starter/src/main/resources/wa.properties | 3 -
.../wa/starter/SyncopeCoreTestingServer.java | 2 +-
39 files changed, 351 insertions(+), 198 deletions(-)
diff --git a/client/am/console/src/main/java/org/apache/syncope/client/console/pages/WA.java b/client/am/console/src/main/java/org/apache/syncope/client/console/pages/WA.java
index f46871dd49..db3002e311 100644
--- a/client/am/console/src/main/java/org/apache/syncope/client/console/pages/WA.java
+++ b/client/am/console/src/main/java/org/apache/syncope/client/console/pages/WA.java
@@ -20,8 +20,10 @@ package org.apache.syncope.client.console.pages;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.json.JsonMapper;
+import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
import java.io.InputStream;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.MediaType;
@@ -40,10 +42,9 @@ import org.apache.syncope.client.console.panels.AuthModuleDirectoryPanel;
import org.apache.syncope.client.console.panels.OIDC;
import org.apache.syncope.client.console.panels.SAML2;
import org.apache.syncope.client.console.panels.WAConfigDirectoryPanel;
-import org.apache.syncope.client.console.rest.WAConfigRestClient;
+import org.apache.syncope.client.console.panels.WAPushModalPanel;
import org.apache.syncope.client.console.rest.WASessionRestClient;
-import org.apache.syncope.client.ui.commons.Constants;
-import org.apache.syncope.client.ui.commons.pages.BaseWebPage;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
import org.apache.syncope.common.lib.types.AMEntitlement;
@@ -65,6 +66,8 @@ public class WA extends BasePage {
protected static final JsonMapper MAPPER = JsonMapper.builder().findAndAddModules().build();
+ protected final BaseModal<Serializable> modal;
+
@SpringBean
protected ServiceOps serviceOps;
@@ -78,20 +81,21 @@ public class WA extends BasePage {
List<NetworkService> instances = serviceOps.list(NetworkService.Type.WA);
+ modal = new BaseModal<>("push-modal");
+ modal.setWindowClosedCallback(target -> modal.show(false));
+ modal.addSubmitButton();
+ body.add(modal.size(Modal.Size.Large));
+
AjaxLink<?> push = new AjaxLink<>("push") {
private static final long serialVersionUID = -817438685948164787L;
@Override
public void onClick(final AjaxRequestTarget target) {
- try {
- WAConfigRestClient.push();
- SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
- } catch (Exception e) {
- LOG.error("While pushing to WA", e);
- SyncopeConsoleSession.get().onException(e);
- }
- ((BaseWebPage) getPageReference().getPage()).getNotificationPanel().refresh(target);
+ modal.header(new ResourceModel("push.options"));
+ modal.setContent(new WAPushModalPanel(modal, instances, getPageReference()));
+ modal.show(true);
+ target.add(modal);
}
};
push.setEnabled(!instances.isEmpty() && SyncopeConsoleSession.get().owns(AMEntitlement.WA_CONFIG_PUSH));
@@ -106,7 +110,7 @@ public class WA extends BasePage {
body.add(content);
if (!instances.isEmpty()) {
- String actuatorEndpoint = instances.get(0).getAddress() + "actuator/env";
+ String actuatorEndpoint = StringUtils.appendIfMissing(instances.get(0).getAddress(), "/") + "actuator/env";
try {
Response response = WebClient.create(
actuatorEndpoint,
diff --git a/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAConfigModalPanel.java b/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAConfigModalPanel.java
index e95f3c9295..4c1c4b5071 100644
--- a/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAConfigModalPanel.java
+++ b/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAConfigModalPanel.java
@@ -66,6 +66,8 @@ public class WAConfigModalPanel extends AbstractModalPanel<Attr> {
add(new ParametersWizardPanel(form, null, pageRef) {
+ private static final long serialVersionUID = -1469319240177117600L;
+
@Override
protected WizardModel buildModelSteps(final ParametersForm modelObject, final WizardModel wizardModel) {
wizardModel.add(new ParametersWizardAttrStep(mode, modelObject));
diff --git a/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAPushModalPanel.java b/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAPushModalPanel.java
new file mode 100644
index 0000000000..c90712bc84
--- /dev/null
+++ b/client/am/console/src/main/java/org/apache/syncope/client/console/panels/WAPushModalPanel.java
@@ -0,0 +1,81 @@
+/*
+ * 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.client.console.panels;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.pages.BasePage;
+import org.apache.syncope.client.console.rest.WAConfigRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.syncope.client.ui.commons.Constants;
+import org.apache.syncope.client.ui.commons.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.client.ui.commons.markup.html.form.AjaxPalettePanel;
+import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.util.ListModel;
+
+public class WAPushModalPanel extends AbstractModalPanel<Serializable> {
+
+ private static final long serialVersionUID = -8589310598889871801L;
+
+ private final Model<WAConfigService.PushSubject> subjectModel = new Model<>(WAConfigService.PushSubject.conf);
+
+ private final ListModel<String> servicesModel = new ListModel<>();
+
+ public WAPushModalPanel(
+ final BaseModal<Serializable> modal,
+ final List<NetworkService> instances,
+ final PageReference pageRef) {
+
+ super(modal, pageRef);
+
+ List<String> addresses = instances.stream().
+ map(NetworkService::getAddress).distinct().sorted().collect(Collectors.toList());
+ servicesModel.setObject(addresses);
+
+ add(new AjaxPalettePanel.Builder<String>().setName("services").setAllowMoveAll(true).build(
+ "services",
+ servicesModel,
+ new ListModel<>(addresses)).addRequiredLabel());
+
+ add(new AjaxDropDownChoicePanel<>(
+ "subject", getString("subject"), subjectModel).
+ setChoices(List.of(WAConfigService.PushSubject.values())).
+ setChoiceRenderer(s -> getString(s.name(), Model.of(), s.name())).setNullValid(false));
+ }
+
+ @Override
+ public void onSubmit(final AjaxRequestTarget target) {
+ try {
+ WAConfigRestClient.push(subjectModel.getObject(), servicesModel.getObject());
+
+ SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
+ this.modal.close(target);
+ } catch (Exception e) {
+ LOG.error("While pushing to WA", e);
+ SyncopeConsoleSession.get().onException(e);
+ }
+ ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
+ }
+}
diff --git a/client/am/console/src/main/java/org/apache/syncope/client/console/rest/WAConfigRestClient.java b/client/am/console/src/main/java/org/apache/syncope/client/console/rest/WAConfigRestClient.java
index 8b683eaf78..542e7cb044 100644
--- a/client/am/console/src/main/java/org/apache/syncope/client/console/rest/WAConfigRestClient.java
+++ b/client/am/console/src/main/java/org/apache/syncope/client/console/rest/WAConfigRestClient.java
@@ -38,7 +38,7 @@ public class WAConfigRestClient extends BaseRestClient {
getService(WAConfigService.class).delete(schema);
}
- public static void push() {
- getService(WAConfigService.class).pushToWA();
+ public static void push(final WAConfigService.PushSubject subject, final List<String> services) {
+ getService(WAConfigService.class).pushToWA(subject, services);
}
}
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.html b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.html
index a0f621f461..3a3a410e40 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.html
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.html
@@ -45,5 +45,7 @@ under the License.
</div>
</div>
</section>
+
+ <div wicket:id="push-modal">[modal]</div>
</wicket:extend>
</html>
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
index 10acef8689..cdd3184c2b 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
@@ -22,3 +22,5 @@ sessions=Sessions
authProfiles=Profiles
push=Push
attrRepos=Attribute Repositories
+push.options=WA Push Options
+submit=Push
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_fr_CA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_fr_CA.properties
index 10acef8689..cdd3184c2b 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_fr_CA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_fr_CA.properties
@@ -22,3 +22,5 @@ sessions=Sessions
authProfiles=Profiles
push=Push
attrRepos=Attribute Repositories
+push.options=WA Push Options
+submit=Push
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties
index 7cb10b56f3..672aa66750 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties
@@ -22,3 +22,5 @@ sessions=Sessioni
authProfiles=Profili
push=Applica
attrRepos=Depositi di Attributi
+push.options=Applica a WA
+submit=Applica
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ja.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ja.properties
index 10acef8689..cdd3184c2b 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ja.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ja.properties
@@ -22,3 +22,5 @@ sessions=Sessions
authProfiles=Profiles
push=Push
attrRepos=Attribute Repositories
+push.options=WA Push Options
+submit=Push
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_pt_BR.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_pt_BR.properties
index 10acef8689..cdd3184c2b 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_pt_BR.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_pt_BR.properties
@@ -22,3 +22,5 @@ sessions=Sessions
authProfiles=Profiles
push=Push
attrRepos=Attribute Repositories
+push.options=WA Push Options
+submit=Push
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ru.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ru.properties
index 10acef8689..cdd3184c2b 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ru.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_ru.properties
@@ -22,3 +22,5 @@ sessions=Sessions
authProfiles=Profiles
push=Push
attrRepos=Attribute Repositories
+push.options=WA Push Options
+submit=Push
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel.html b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel.html
new file mode 100644
index 0000000000..d19dcc5a65
--- /dev/null
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel.html
@@ -0,0 +1,26 @@
+<!--
+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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:extend>
+ <div class="form-group">
+ <span wicket:id="services"/>
+ <span wicket:id="subject"/>
+ </div>
+ </wicket:extend>
+</html>
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel.properties
similarity index 85%
copy from client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
copy to client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel.properties
index 10acef8689..1c6402c1a5 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel.properties
@@ -14,11 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-wa=WA
-authModules=Authentication Modules
+#
+services=WA instances
+subject=Push Subject
+conf=Full Configuration
clientApps=Client Applications
-config=Parameters
-sessions=Sessions
-authProfiles=Profiles
-push=Push
-attrRepos=Attribute Repositories
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_fr_CA.properties
similarity index 85%
copy from client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
copy to client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_fr_CA.properties
index 10acef8689..1c6402c1a5 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_fr_CA.properties
@@ -14,11 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-wa=WA
-authModules=Authentication Modules
+#
+services=WA instances
+subject=Push Subject
+conf=Full Configuration
clientApps=Client Applications
-config=Parameters
-sessions=Sessions
-authProfiles=Profiles
-push=Push
-attrRepos=Attribute Repositories
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_it.properties
similarity index 85%
copy from client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties
copy to client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_it.properties
index 7cb10b56f3..e35d265472 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA_it.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_it.properties
@@ -14,11 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-wa=WA
-authModules=Moduli di Autenticazione
+#
+services=Istanze di WA
+subject=Oggetto
+conf=Configurazione Completa
clientApps=Applicazioni Client
-config=Parametri
-sessions=Sessioni
-authProfiles=Profili
-push=Applica
-attrRepos=Depositi di Attributi
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_ja.properties
similarity index 85%
copy from client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
copy to client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_ja.properties
index 10acef8689..1c6402c1a5 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_ja.properties
@@ -14,11 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-wa=WA
-authModules=Authentication Modules
+#
+services=WA instances
+subject=Push Subject
+conf=Full Configuration
clientApps=Client Applications
-config=Parameters
-sessions=Sessions
-authProfiles=Profiles
-push=Push
-attrRepos=Attribute Repositories
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_pt_BR.properties
similarity index 85%
copy from client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
copy to client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_pt_BR.properties
index 10acef8689..1c6402c1a5 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_pt_BR.properties
@@ -14,11 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-wa=WA
-authModules=Authentication Modules
+#
+services=WA instances
+subject=Push Subject
+conf=Full Configuration
clientApps=Client Applications
-config=Parameters
-sessions=Sessions
-authProfiles=Profiles
-push=Push
-attrRepos=Attribute Repositories
diff --git a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_ru.properties
similarity index 85%
copy from client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
copy to client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_ru.properties
index 10acef8689..1c6402c1a5 100644
--- a/client/am/console/src/main/resources/org/apache/syncope/client/console/pages/WA.properties
+++ b/client/am/console/src/main/resources/org/apache/syncope/client/console/panels/WAPushModalPanel_ru.properties
@@ -14,11 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-wa=WA
-authModules=Authentication Modules
+#
+services=WA instances
+subject=Push Subject
+conf=Full Configuration
clientApps=Client Applications
-config=Parameters
-sessions=Sessions
-authProfiles=Profiles
-push=Push
-attrRepos=Attribute Repositories
diff --git a/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AbstractWizardMgtPanel.java b/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AbstractWizardMgtPanel.java
index 7ed5447020..4444f49852 100644
--- a/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AbstractWizardMgtPanel.java
+++ b/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/wizards/AbstractWizardMgtPanel.java
@@ -31,5 +31,4 @@ public abstract class AbstractWizardMgtPanel<T extends Serializable> extends Pan
public AbstractWizardMgtPanel(final String id) {
super(id);
}
-
}
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/DisplayAttributesModalPanel.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/DisplayAttributesModalPanel.java
index d2707499d9..f8d057cdcd 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/DisplayAttributesModalPanel.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/DisplayAttributesModalPanel.java
@@ -76,9 +76,6 @@ public abstract class DisplayAttributesModalPanel<T extends Serializable> extend
super(modal, pageRef);
this.type = type;
- final List<String> detailslList = SearchableFields.get(DisplayAttributesModalPanel.getTOClass(type))
- .keySet().stream().collect(Collectors.toList());
- Collections.sort(detailslList);
Collections.sort(pSchemaNames);
Collections.sort(dSchemaNames);
@@ -88,11 +85,12 @@ public abstract class DisplayAttributesModalPanel<T extends Serializable> extend
@Override
protected List<String> load() {
- return detailslList;
+ return SearchableFields.get(DisplayAttributesModalPanel.getTOClass(type))
+ .keySet().stream().sorted().collect(Collectors.toList());
}
};
- final IModel<List<String>> psnames = new LoadableDetachableModel<>() {
+ IModel<List<String>> psnames = new LoadableDetachableModel<>() {
private static final long serialVersionUID = 5275935387613157437L;
@@ -102,7 +100,7 @@ public abstract class DisplayAttributesModalPanel<T extends Serializable> extend
}
};
- final IModel<List<String>> dsnames = new LoadableDetachableModel<>() {
+ IModel<List<String>> dsnames = new LoadableDetachableModel<>() {
private static final long serialVersionUID = 5275935387613157437L;
@@ -120,7 +118,7 @@ public abstract class DisplayAttributesModalPanel<T extends Serializable> extend
selectedPlainSchemas.retainAll(pSchemaNames);
selectedDerSchemas.retainAll(dSchemaNames);
- final WebMarkupContainer container = new WebMarkupContainer("container");
+ WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
add(container);
@@ -188,10 +186,10 @@ public abstract class DisplayAttributesModalPanel<T extends Serializable> extend
public static final Class<? extends AnyTO> getTOClass(final String type) {
if (type.equalsIgnoreCase(AnyTypeKind.USER.name())) {
return UserTO.class;
- } else if (type.equalsIgnoreCase(AnyTypeKind.GROUP.name())) {
+ }
+ if (type.equalsIgnoreCase(AnyTypeKind.GROUP.name())) {
return GroupTO.class;
- } else {
- return AnyObjectTO.class;
}
+ return AnyObjectTO.class;
}
}
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java
index a80ecbe5c4..7b914dff91 100644
--- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java
@@ -48,8 +48,6 @@ public final class AMEntitlement {
public static final String CLIENTAPP_DELETE = "CLIENTAPP_DELETE";
- public static final String CLIENTAPP_PUSH = "CLIENTAPP_PUSH";
-
public static final String AUTH_MODULE_LIST = "AUTH_MODULE_LIST";
public static final String AUTH_MODULE_CREATE = "AUTH_MODULE_CREATE";
diff --git a/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientAppService.java b/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientAppService.java
index 8ef62ffcfa..e11f3692b3 100644
--- a/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientAppService.java
+++ b/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientAppService.java
@@ -131,11 +131,4 @@ public interface ClientAppService extends JAXRSService {
@Path("{type}/{key}")
@Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
void delete(@NotNull @PathParam("type") ClientAppType type, @NotNull @PathParam("key") String key);
-
- @ApiResponses(
- @ApiResponse(responseCode = "204", description = "Operation was successful"))
- @POST
- @Path("push")
- @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
- void pushToWA();
}
diff --git a/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/wa/WAConfigService.java b/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/wa/WAConfigService.java
index 548a9b3276..94c0da83fb 100644
--- a/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/wa/WAConfigService.java
+++ b/common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/wa/WAConfigService.java
@@ -36,6 +36,7 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.syncope.common.lib.Attr;
import org.apache.syncope.common.rest.api.RESTHeaders;
@@ -51,6 +52,12 @@ import org.apache.syncope.common.rest.api.service.JAXRSService;
@Path("wa/config")
public interface WAConfigService extends JAXRSService {
+ enum PushSubject {
+ clientApps,
+ conf
+
+ }
+
@GET
@Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
@@ -95,10 +102,16 @@ public interface WAConfigService extends JAXRSService {
@Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
void delete(@NotNull @PathParam("schema") String schema);
+ /**
+ * Push to WA according to the provided parameters.
+ *
+ * @param subject what is to be triggered for refresh on WA
+ * @param services WA instances to trigger; all if none specified
+ */
@ApiResponses(
@ApiResponse(responseCode = "204", description = "Operation was successful"))
@POST
- @Path("push")
+ @Path("push/{subject}")
@Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
- void pushToWA();
+ void pushToWA(@NotNull @PathParam("subject") PushSubject subject, @QueryParam("service") List<String> services);
}
diff --git a/core/am/logic/src/main/java/org/apache/syncope/core/logic/AMLogicContext.java b/core/am/logic/src/main/java/org/apache/syncope/core/logic/AMLogicContext.java
index 715f50b9e1..5535b72538 100644
--- a/core/am/logic/src/main/java/org/apache/syncope/core/logic/AMLogicContext.java
+++ b/core/am/logic/src/main/java/org/apache/syncope/core/logic/AMLogicContext.java
@@ -95,12 +95,11 @@ public class AMLogicContext {
@Bean
public ClientAppLogic clientAppLogic(
final ServiceOps serviceOps,
+ final ClientAppUtilsFactory clientAppUtilsFactory,
+ final ClientAppDataBinder binder,
final CASSPClientAppDAO casSPClientAppDAO,
final OIDCRPClientAppDAO oidcRPClientAppDAO,
- final SAML2SPClientAppDAO saml2SPClientAppDAO,
- final SecurityProperties securityProperties,
- final ClientAppUtilsFactory clientAppUtilsFactory,
- final ClientAppDataBinder binder) {
+ final SAML2SPClientAppDAO saml2SPClientAppDAO) {
return new ClientAppLogic(
serviceOps,
@@ -108,8 +107,7 @@ public class AMLogicContext {
binder,
casSPClientAppDAO,
oidcRPClientAppDAO,
- saml2SPClientAppDAO,
- securityProperties);
+ saml2SPClientAppDAO);
}
@ConditionalOnMissingBean
diff --git a/core/am/logic/src/main/java/org/apache/syncope/core/logic/ClientAppLogic.java b/core/am/logic/src/main/java/org/apache/syncope/core/logic/ClientAppLogic.java
index d6c336852c..ba3ad5de0e 100644
--- a/core/am/logic/src/main/java/org/apache/syncope/core/logic/ClientAppLogic.java
+++ b/core/am/logic/src/main/java/org/apache/syncope/core/logic/ClientAppLogic.java
@@ -18,24 +18,12 @@
*/
package org.apache.syncope.core.logic;
-import java.io.IOException;
import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.http.HttpClient;
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javax.ws.rs.InternalServerErrorException;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier;
-import org.apache.syncope.common.keymaster.client.api.KeymasterException;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
-import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.ClientAppTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
@@ -52,7 +40,6 @@ import org.apache.syncope.core.persistence.api.entity.am.ClientAppUtilsFactory;
import org.apache.syncope.core.persistence.api.entity.am.OIDCRPClientApp;
import org.apache.syncope.core.persistence.api.entity.am.SAML2SPClientApp;
import org.apache.syncope.core.provisioning.api.data.ClientAppDataBinder;
-import org.apache.syncope.core.spring.security.SecurityProperties;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
@@ -70,16 +57,13 @@ public class ClientAppLogic extends AbstractTransactionalLogic<ClientAppTO> {
protected final SAML2SPClientAppDAO saml2SPClientAppDAO;
- protected final SecurityProperties securityProperties;
-
public ClientAppLogic(
final ServiceOps serviceOps,
final ClientAppUtilsFactory clientAppUtilsFactory,
final ClientAppDataBinder binder,
final CASSPClientAppDAO casSPClientAppDAO,
final OIDCRPClientAppDAO oidcRPClientAppDAO,
- final SAML2SPClientAppDAO saml2SPClientAppDAO,
- final SecurityProperties securityProperties) {
+ final SAML2SPClientAppDAO saml2SPClientAppDAO) {
this.serviceOps = serviceOps;
this.clientAppUtilsFactory = clientAppUtilsFactory;
@@ -87,7 +71,6 @@ public class ClientAppLogic extends AbstractTransactionalLogic<ClientAppTO> {
this.casSPClientAppDAO = casSPClientAppDAO;
this.oidcRPClientAppDAO = oidcRPClientAppDAO;
this.saml2SPClientAppDAO = saml2SPClientAppDAO;
- this.securityProperties = securityProperties;
}
@PreAuthorize("hasRole('" + AMEntitlement.CLIENTAPP_LIST + "')")
@@ -258,25 +241,4 @@ public class ClientAppLogic extends AbstractTransactionalLogic<ClientAppTO> {
throw new UnresolvedReferenceException();
}
-
- @PreAuthorize("hasRole('" + AMEntitlement.CLIENTAPP_PUSH + "')")
- public void pushToWA() {
- try {
- NetworkService wa = serviceOps.get(NetworkService.Type.WA);
- String basicAuthHeader = DefaultBasicAuthSupplier.getBasicAuthHeader(
- securityProperties.getAnonymousUser(), securityProperties.getAnonymousKey());
- URI endpoint = URI.create(StringUtils.appendIfMissing(wa.getAddress(), "/")
- + "actuator/registeredServices");
- HttpClient.newBuilder().build().send(
- HttpRequest.newBuilder(endpoint).
- header(HttpHeaders.AUTHORIZATION, basicAuthHeader).
- header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).
- GET().build(),
- HttpResponse.BodyHandlers.discarding());
- } catch (KeymasterException e) {
- throw new NotFoundException("Could not find any WA instance", e);
- } catch (IOException | InterruptedException e) {
- throw new InternalServerErrorException("Errors while communicating with WA instance", e);
- }
- }
}
diff --git a/core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/WAConfigLogic.java b/core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/WAConfigLogic.java
index 547880ad40..ea7c47444d 100644
--- a/core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/WAConfigLogic.java
+++ b/core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/WAConfigLogic.java
@@ -36,6 +36,7 @@ import org.apache.syncope.common.lib.Attr;
import org.apache.syncope.common.lib.to.EntityTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
import org.apache.syncope.common.lib.types.IdRepoEntitlement;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.apache.syncope.core.logic.AbstractTransactionalLogic;
import org.apache.syncope.core.logic.UnresolvedReferenceException;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
@@ -44,6 +45,7 @@ import org.apache.syncope.core.provisioning.api.data.WAConfigDataBinder;
import org.apache.syncope.core.spring.security.SecurityProperties;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
public class WAConfigLogic extends AbstractTransactionalLogic<EntityTO> {
@@ -91,19 +93,47 @@ public class WAConfigLogic extends AbstractTransactionalLogic<EntityTO> {
waConfigDAO.delete(key);
}
+ protected void registeredServices(final HttpClient client, final String serviceAddress) {
+ String target = StringUtils.appendIfMissing(serviceAddress, "/") + "actuator/registeredServices";
+ client.sendAsync(
+ HttpRequest.newBuilder(URI.create(target)).
+ header(HttpHeaders.AUTHORIZATION, DefaultBasicAuthSupplier.getBasicAuthHeader(
+ securityProperties.getAnonymousUser(), securityProperties.getAnonymousKey())).
+ GET().build(),
+ HttpResponse.BodyHandlers.discarding()).
+ thenAcceptAsync(response -> LOG.info(
+ "Pushed to {} with HTTP status: {}", target, response.statusCode()));
+ }
+
+ protected void refresh(final HttpClient client, final String serviceAddress) {
+ String target = StringUtils.appendIfMissing(serviceAddress, "/") + "actuator/refresh";
+ client.sendAsync(
+ HttpRequest.newBuilder(URI.create(target)).
+ header(HttpHeaders.AUTHORIZATION, DefaultBasicAuthSupplier.getBasicAuthHeader(
+ securityProperties.getAnonymousUser(), securityProperties.getAnonymousKey())).
+ POST(HttpRequest.BodyPublishers.noBody()).build(),
+ HttpResponse.BodyHandlers.discarding()).
+ thenAcceptAsync(response -> LOG.info(
+ "Pushed to {} with HTTP status: {}", target, response.statusCode()));
+ }
+
@PreAuthorize("hasRole('" + AMEntitlement.WA_CONFIG_PUSH + "')")
- public void pushToWA() {
+ public void pushToWA(final WAConfigService.PushSubject subject, final List<String> services) {
HttpClient client = HttpClient.newHttpClient();
try {
- serviceOps.list(NetworkService.Type.WA).forEach(wa -> client.sendAsync(
- HttpRequest.newBuilder(URI.create(
- StringUtils.appendIfMissing(wa.getAddress(), "/") + "actuator/refresh")).
- header(HttpHeaders.AUTHORIZATION, DefaultBasicAuthSupplier.getBasicAuthHeader(
- securityProperties.getAnonymousUser(), securityProperties.getAnonymousKey())).
- POST(HttpRequest.BodyPublishers.noBody()).build(),
- HttpResponse.BodyHandlers.discarding()).
- thenAcceptAsync(response -> LOG.info(
- "Pushed to WA instance {} with HTTP status: {}", wa.getAddress(), response.statusCode())));
+ serviceOps.list(NetworkService.Type.WA).stream().
+ filter(wa -> CollectionUtils.isEmpty(services) || services.contains(wa.getAddress())).
+ forEach(wa -> {
+ switch (subject) {
+ case clientApps:
+ registeredServices(client, wa.getAddress());
+ break;
+
+ case conf:
+ default:
+ refresh(client, wa.getAddress());
+ }
+ });
} catch (KeymasterException e) {
throw new NotFoundException("Could not find any WA instance", e);
}
diff --git a/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ClientAppServiceImpl.java b/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ClientAppServiceImpl.java
index da1e1e0e15..99091c4348 100644
--- a/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ClientAppServiceImpl.java
+++ b/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ClientAppServiceImpl.java
@@ -65,9 +65,4 @@ public class ClientAppServiceImpl extends AbstractService implements ClientAppSe
public void delete(final ClientAppType type, final String key) {
logic.delete(type, key);
}
-
- @Override
- public void pushToWA() {
- logic.pushToWA();
- }
}
diff --git a/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/wa/WAConfigServiceImpl.java b/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/wa/WAConfigServiceImpl.java
index 390f409410..526293cbf9 100644
--- a/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/wa/WAConfigServiceImpl.java
+++ b/core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/wa/WAConfigServiceImpl.java
@@ -55,7 +55,7 @@ public class WAConfigServiceImpl extends AbstractService implements WAConfigServ
}
@Override
- public void pushToWA() {
- logic.pushToWA();
+ public void pushToWA(final PushSubject subject, final List<String> services) {
+ logic.pushToWA(subject, services);
}
}
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ProvisioningContext.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ProvisioningContext.java
index 4d5a714159..c8ba816f9f 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ProvisioningContext.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ProvisioningContext.java
@@ -156,7 +156,7 @@ import org.apache.syncope.core.provisioning.java.job.JobStatusUpdater;
import org.apache.syncope.core.provisioning.java.job.SchedulerDBInit;
import org.apache.syncope.core.provisioning.java.job.SyncopeSpringBeanJobFactory;
import org.apache.syncope.core.provisioning.java.job.SystemLoadReporterJob;
-import org.apache.syncope.core.provisioning.java.job.notification.DefaultNotificationJobDelegate;
+import org.apache.syncope.core.provisioning.java.job.notification.MailNotificationJobDelegate;
import org.apache.syncope.core.provisioning.java.job.notification.NotificationJob;
import org.apache.syncope.core.provisioning.java.notification.DefaultNotificationManager;
import org.apache.syncope.core.provisioning.java.propagation.DefaultPropagationManager;
@@ -707,18 +707,18 @@ public class ProvisioningContext {
public NotificationJobDelegate notificationJobDelegate(
final TaskUtilsFactory taskUtilsFactory,
final TaskDAO taskDAO,
- final JavaMailSender mailSender,
final AuditManager auditManager,
final NotificationManager notificationManager,
- final ApplicationEventPublisher publisher) {
+ final ApplicationEventPublisher publisher,
+ final JavaMailSender mailSender) {
- return new DefaultNotificationJobDelegate(
+ return new MailNotificationJobDelegate(
taskDAO,
- mailSender,
taskUtilsFactory,
auditManager,
notificationManager,
- publisher);
+ publisher,
+ mailSender);
}
@ConditionalOnMissingBean
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/DefaultNotificationJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/AbstractNotificationJobDelegate.java
similarity index 82%
rename from core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/DefaultNotificationJobDelegate.java
rename to core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/AbstractNotificationJobDelegate.java
index 3d51b85347..8754cbf731 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/DefaultNotificationJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/AbstractNotificationJobDelegate.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.provisioning.java.job.notification;
import java.time.OffsetDateTime;
import java.util.List;
-import javax.mail.internet.MimeMessage;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.types.AuditElements;
import org.apache.syncope.common.lib.types.TaskType;
@@ -40,18 +39,14 @@ import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.mail.javamail.JavaMailSender;
-import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.transaction.annotation.Transactional;
-public class DefaultNotificationJobDelegate implements NotificationJobDelegate {
+public abstract class AbstractNotificationJobDelegate implements NotificationJobDelegate {
protected static final Logger LOG = LoggerFactory.getLogger(NotificationJobDelegate.class);
protected final TaskDAO taskDAO;
- protected final JavaMailSender mailSender;
-
protected final TaskUtilsFactory taskUtilsFactory;
protected final AuditManager auditManager;
@@ -64,16 +59,14 @@ public class DefaultNotificationJobDelegate implements NotificationJobDelegate {
protected boolean interrupted;
- public DefaultNotificationJobDelegate(
+ protected AbstractNotificationJobDelegate(
final TaskDAO taskDAO,
- final JavaMailSender mailSender,
final TaskUtilsFactory taskUtilsFactory,
final AuditManager auditManager,
final NotificationManager notificationManager,
final ApplicationEventPublisher publisher) {
this.taskDAO = taskDAO;
- this.mailSender = mailSender;
this.taskUtilsFactory = taskUtilsFactory;
this.auditManager = auditManager;
this.notificationManager = notificationManager;
@@ -94,6 +87,9 @@ public class DefaultNotificationJobDelegate implements NotificationJobDelegate {
return interrupted;
}
+ protected abstract void notify(String to, NotificationTask task, TaskExec<NotificationTask> execution)
+ throws Exception;
+
@Transactional
@Override
public TaskExec<NotificationTask> executeSingle(final NotificationTask task, final String executor) {
@@ -122,7 +118,7 @@ public class DefaultNotificationJobDelegate implements NotificationJobDelegate {
}
} else {
if (LOG.isDebugEnabled()) {
- LOG.debug("About to send e-mails:\n"
+ LOG.debug("About to send notifications:\n"
+ task.getRecipients() + '\n'
+ task.getSender() + '\n'
+ task.getSubject() + '\n'
@@ -134,38 +130,7 @@ public class DefaultNotificationJobDelegate implements NotificationJobDelegate {
for (String to : task.getRecipients()) {
try {
- MimeMessage message = mailSender.createMimeMessage();
- MimeMessageHelper helper = new MimeMessageHelper(message, true);
- helper.setTo(to);
- helper.setFrom(task.getSender());
- helper.setSubject(task.getSubject());
- helper.setText(task.getTextBody(), task.getHtmlBody());
-
- mailSender.send(message);
-
- execution.setStatus(NotificationJob.Status.SENT.name());
-
- StringBuilder report = new StringBuilder();
- switch (task.getTraceLevel()) {
- case ALL:
- report.append("FROM: ").append(task.getSender()).append('\n').
- append("TO: ").append(to).append('\n').
- append("SUBJECT: ").append(task.getSubject()).append('\n').append('\n').
- append(task.getTextBody()).append('\n').append('\n').
- append(task.getHtmlBody()).append('\n');
- break;
-
- case SUMMARY:
- report.append("E-mail sent to ").append(to).append('\n');
- break;
-
- case FAILURES:
- case NONE:
- default:
- }
- if (report.length() > 0) {
- execution.setMessage(report.toString());
- }
+ notify(to, task, execution);
notificationManager.createTasks(
AuthContextUtils.getWho(),
@@ -179,7 +144,7 @@ public class DefaultNotificationJobDelegate implements NotificationJobDelegate {
task,
"Successfully sent notification to " + to);
} catch (Exception e) {
- LOG.error("Could not send e-mail", e);
+ LOG.error("Could not send out notification", e);
execution.setStatus(NotificationJob.Status.NOT_SENT.name());
if (task.getTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal()) {
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/MailNotificationJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/MailNotificationJobDelegate.java
new file mode 100644
index 0000000000..f7aa50003b
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/notification/MailNotificationJobDelegate.java
@@ -0,0 +1,87 @@
+/*
+ * 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.job.notification;
+
+import javax.mail.internet.MimeMessage;
+import org.apache.syncope.core.persistence.api.dao.TaskDAO;
+import org.apache.syncope.core.persistence.api.entity.task.NotificationTask;
+import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
+import org.apache.syncope.core.persistence.api.entity.task.TaskUtilsFactory;
+import org.apache.syncope.core.provisioning.api.AuditManager;
+import org.apache.syncope.core.provisioning.api.notification.NotificationManager;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
+
+public class MailNotificationJobDelegate extends AbstractNotificationJobDelegate {
+
+ protected final JavaMailSender mailSender;
+
+ public MailNotificationJobDelegate(
+ final TaskDAO taskDAO,
+ final TaskUtilsFactory taskUtilsFactory,
+ final AuditManager auditManager,
+ final NotificationManager notificationManager,
+ final ApplicationEventPublisher publisher,
+ final JavaMailSender mailSender) {
+
+ super(taskDAO, taskUtilsFactory, auditManager, notificationManager, publisher);
+ this.mailSender = mailSender;
+ }
+
+ @Override
+ protected void notify(
+ final String to,
+ final NotificationTask task,
+ final TaskExec<NotificationTask> execution) throws Exception {
+
+ MimeMessage message = mailSender.createMimeMessage();
+ MimeMessageHelper helper = new MimeMessageHelper(message, true);
+ helper.setTo(to);
+ helper.setFrom(task.getSender());
+ helper.setSubject(task.getSubject());
+ helper.setText(task.getTextBody(), task.getHtmlBody());
+
+ mailSender.send(message);
+
+ execution.setStatus(NotificationJob.Status.SENT.name());
+
+ StringBuilder report = new StringBuilder();
+ switch (task.getTraceLevel()) {
+ case ALL:
+ report.append("FROM: ").append(task.getSender()).append('\n').
+ append("TO: ").append(to).append('\n').
+ append("SUBJECT: ").append(task.getSubject()).append('\n').append('\n').
+ append(task.getTextBody()).append('\n').append('\n').
+ append(task.getHtmlBody()).append('\n');
+ break;
+
+ case SUMMARY:
+ report.append("E-mail sent to ").append(to).append('\n');
+ break;
+
+ case FAILURES:
+ case NONE:
+ default:
+ }
+ if (report.length() > 0) {
+ execution.setMessage(report.toString());
+ }
+ }
+}
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
index b596f3c9c7..2369d59485 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
@@ -48,6 +48,7 @@ import org.apache.syncope.common.rest.api.service.SAML2IdPEntityService;
import org.apache.syncope.common.rest.api.service.SAML2SP4UIIdPService;
import org.apache.syncope.common.rest.api.service.SRARouteService;
import org.apache.syncope.common.rest.api.service.UserService;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.apache.syncope.fit.sra.AbstractSRAITCase;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
@@ -84,6 +85,8 @@ public abstract class AbstractITCase {
protected static ClientAppService CLIENT_APP_SERVICE;
+ protected static WAConfigService WA_CONFIG_SERVICE;
+
protected static SRARouteService SRA_ROUTE_SERVICE;
protected static SAML2SP4UIIdPService SAML2SP4UI_IDP_SERVICE;
@@ -98,6 +101,7 @@ public abstract class AbstractITCase {
USER_SERVICE = ADMIN_CLIENT.getService(UserService.class);
POLICY_SERVICE = ADMIN_CLIENT.getService(PolicyService.class);
CLIENT_APP_SERVICE = ADMIN_CLIENT.getService(ClientAppService.class);
+ WA_CONFIG_SERVICE = ADMIN_CLIENT.getService(WAConfigService.class);
SRA_ROUTE_SERVICE = ADMIN_CLIENT.getService(SRARouteService.class);
SAML2SP4UI_IDP_SERVICE = ADMIN_CLIENT.getService(SAML2SP4UIIdPService.class);
OIDCC4UI_PROVIDER_SERVICE = ADMIN_CLIENT.getService(OIDCC4UIProviderService.class);
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java
index a088c07e57..0d53dfbd78 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java
@@ -48,6 +48,7 @@ import org.apache.http.util.EntityUtils;
import org.apache.syncope.common.lib.to.CASSPClientAppTO;
import org.apache.syncope.common.lib.types.ClientAppType;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -85,7 +86,7 @@ public class CASSRAITCase extends AbstractSRAITCase {
clientApp.setAuthPolicy(getAuthPolicy().getKey());
CLIENT_APP_SERVICE.update(ClientAppType.CASSP, clientApp);
- CLIENT_APP_SERVICE.pushToWA();
+ WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.clientApps, List.of());
}
@Test
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
index 4203b0a5e0..864de52504 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
@@ -60,6 +60,7 @@ import org.apache.syncope.common.lib.to.OIDCRPClientAppTO;
import org.apache.syncope.common.lib.types.ClientAppType;
import org.apache.syncope.common.lib.types.OIDCSubjectType;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.jsoup.Jsoup;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -119,7 +120,7 @@ public class OIDCSRAITCase extends AbstractSRAITCase {
clientApp.setAttrReleasePolicy(getAttrReleasePolicy().getKey());
CLIENT_APP_SERVICE.update(ClientAppType.OIDCRP, clientApp);
- CLIENT_APP_SERVICE.pushToWA();
+ WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.clientApps, List.of());
}
@BeforeAll
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 0211a0000e..8497326e81 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
@@ -50,6 +50,7 @@ import org.apache.syncope.common.lib.to.SAML2SPClientAppTO;
import org.apache.syncope.common.lib.types.ClientAppType;
import org.apache.syncope.common.lib.types.SAML2SPNameId;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -91,7 +92,7 @@ public class SAML2SRAITCase extends AbstractSRAITCase {
clientApp.setAuthPolicy(getAuthPolicy().getKey());
CLIENT_APP_SERVICE.update(ClientAppType.SAML2SP, clientApp);
- CLIENT_APP_SERVICE.pushToWA();
+ WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.clientApps, List.of());
}
@Test
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/OIDC4UIITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/OIDC4UIITCase.java
index 8f0d9ee214..2b40a82e24 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/OIDC4UIITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/ui/OIDC4UIITCase.java
@@ -52,6 +52,7 @@ import org.apache.syncope.common.lib.types.ClientAppType;
import org.apache.syncope.common.lib.types.OIDCResponseType;
import org.apache.syncope.common.lib.types.OIDCSubjectType;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.jsoup.Jsoup;
import org.junit.jupiter.api.BeforeAll;
@@ -93,7 +94,7 @@ public class OIDC4UIITCase extends AbstractUIITCase {
clientApp.setAttrReleasePolicy(getAttrReleasePolicy().getKey());
CLIENT_APP_SERVICE.update(ClientAppType.OIDCRP, clientApp);
- CLIENT_APP_SERVICE.pushToWA();
+ WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.clientApps, List.of());
}
private static String getAppName(final String address) {
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 2e10162a17..2c63604369 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
@@ -54,6 +54,7 @@ import org.apache.syncope.common.lib.to.SAML2SPClientAppTO;
import org.apache.syncope.common.lib.types.ClientAppType;
import org.apache.syncope.common.lib.types.SAML2SPNameId;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -87,7 +88,7 @@ public class SAML2SP4UIITCase extends AbstractUIITCase {
clientApp.setAttrReleasePolicy(getAttrReleasePolicy().getKey());
CLIENT_APP_SERVICE.update(ClientAppType.SAML2SP, clientApp);
- CLIENT_APP_SERVICE.pushToWA();
+ WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.clientApps, List.of());
}
@BeforeAll
diff --git a/wa/starter/src/main/resources/wa.properties b/wa/starter/src/main/resources/wa.properties
index c55ccb2677..a0e0b6a38c 100644
--- a/wa/starter/src/main/resources/wa.properties
+++ b/wa/starter/src/main/resources/wa.properties
@@ -105,9 +105,6 @@ cas.authn.mfa.web-authn.core.application-id=https://localhost:8443
cas.authn.mfa.web-authn.core.relying-party-name=Syncope
cas.authn.mfa.web-authn.core.relying-party-id=syncope.apache.org
-cas.authn.syncope.url=${cas.server.name}/syncope
-cas.authn.syncope.name=DefaultSyncopeAuthModule
-
##
# Default strategy for matching request paths against
# registered Spring MVC handler mappings
diff --git a/wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeCoreTestingServer.java b/wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeCoreTestingServer.java
index 41de8806e6..f4ffb43c8e 100644
--- a/wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeCoreTestingServer.java
+++ b/wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeCoreTestingServer.java
@@ -171,7 +171,7 @@ public class SyncopeCoreTestingServer implements ApplicationListener<ContextRefr
}
@Override
- public void pushToWA() {
+ public void pushToWA(final PushSubject subject, final List<String> services) {
// nothing to do
}
}