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
The following commit(s) were added to refs/heads/master by this push:
new 2c956ebe80 [SYNCOPE-1984] Add support to realm-based enduser
formLayout configuration (#1457)
2c956ebe80 is described below
commit 2c956ebe80b9e132ea4e9528eebd9c174dfdd67e
Author: Matteo Tatoni <[email protected]>
AuthorDate: Thu Jul 16 11:11:16 2026 +0200
[SYNCOPE-1984] Add support to realm-based enduser formLayout configuration
(#1457)
---
.../client/enduser/SyncopeWebApplication.java | 18 +++++-
.../client/enduser/layout/UserFormLayouts.java | 64 ++++++++++++++++++++++
.../src/main/resources/customFormLayout.json | 33 ++++++-----
3 files changed, 97 insertions(+), 18 deletions(-)
diff --git
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
index 22e9e8789c..97a6654df1 100644
---
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
+++
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Optional;
import
org.apache.syncope.client.enduser.init.ClassPathScanImplementationLookup;
import org.apache.syncope.client.enduser.layout.UserFormLayoutInfo;
+import org.apache.syncope.client.enduser.layout.UserFormLayouts;
import org.apache.syncope.client.enduser.pages.BasePage;
import org.apache.syncope.client.enduser.pages.Dashboard;
import org.apache.syncope.client.enduser.pages.Login;
@@ -46,7 +47,9 @@ import org.apache.syncope.client.ui.commons.pages.BaseLogin;
import org.apache.syncope.client.ui.commons.themes.AdminLTE;
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.SyncopeConstants;
import org.apache.syncope.common.lib.jackson.SyncopeJsonMapper;
+import org.apache.syncope.common.lib.to.UserTO;
import org.apache.wicket.Page;
import org.apache.wicket.Session;
import org.apache.wicket.WicketRuntimeException;
@@ -93,7 +96,7 @@ public class SyncopeWebApplication extends
WicketBootSecuredWebApplication imple
protected final List<IResource> resources;
- protected UserFormLayoutInfo customFormLayout;
+ protected UserFormLayouts customFormLayouts;
protected final DynamicMenuStringResourceLoader
dynamicMenuStringResourceLoader;
@@ -229,7 +232,7 @@ public class SyncopeWebApplication extends
WicketBootSecuredWebApplication imple
getResourceSettings().getStringResourceLoaders().add(dynamicMenuStringResourceLoader);
try (InputStream is =
resourceLoader.getResource(props.getCustomFormLayout()).getInputStream()) {
- customFormLayout = MAPPER.readValue(is, new TypeReference<>() {
+ customFormLayouts = MAPPER.readValue(is, new TypeReference<>() {
});
} catch (Exception e) {
throw new WicketRuntimeException("Could not read " +
props.getCustomFormLayout(), e);
@@ -272,7 +275,16 @@ public class SyncopeWebApplication extends
WicketBootSecuredWebApplication imple
}
public UserFormLayoutInfo getCustomFormLayout() {
- return customFormLayout;
+ String userRealm = SyncopeConstants.ROOT_REALM;
+ try {
+ UserTO userTO = SyncopeEnduserSession.get().getSelfTO(true);
+ if (userTO != null) {
+ userRealm = userTO.getRealm();
+ }
+ } catch (Exception e) {
+ LOG.warn("Could not get user realm from self", e);
+ }
+ return customFormLayouts.getLayout(userRealm);
}
public Class<? extends Sidebar> getSidebar() {
diff --git
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/UserFormLayouts.java
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/UserFormLayouts.java
new file mode 100644
index 0000000000..3a00e4ba07
--- /dev/null
+++
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/UserFormLayouts.java
@@ -0,0 +1,64 @@
+/*
+ * 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.enduser.layout;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.SyncopeConstants;
+
+public class UserFormLayouts implements Serializable {
+
+ private static final long serialVersionUID = 9106933641699158419L;
+
+ private final Map<String, UserFormLayoutInfo> layouts;
+
+ @JsonCreator
+ public UserFormLayouts(@JsonProperty("layouts") final Map<String,
UserFormLayoutInfo> layouts) {
+ this.layouts = layouts == null ? new HashMap<>() : new
HashMap<>(layouts);
+ this.layouts.putIfAbsent(SyncopeConstants.ROOT_REALM, new
UserFormLayoutInfo());
+ }
+
+ public Map<String, UserFormLayoutInfo> getLayouts() {
+ return layouts;
+ }
+
+ public UserFormLayoutInfo getLayout(final String realm) {
+ if (!StringUtils.isBlank(realm)) {
+ UserFormLayoutInfo layout = layouts.get(realm);
+ if (layout != null) {
+ return layout;
+ }
+
+ String current = StringUtils.substringBeforeLast(realm, "/");
+ while (!SyncopeConstants.ROOT_REALM.equals(current)) {
+ layout = layouts.get(current);
+ if (layout != null) {
+ return layout;
+ }
+
+ current = StringUtils.substringBeforeLast(current, "/");
+ }
+ }
+ return layouts.get(SyncopeConstants.ROOT_REALM);
+ }
+}
diff --git a/client/idrepo/enduser/src/main/resources/customFormLayout.json
b/client/idrepo/enduser/src/main/resources/customFormLayout.json
index 4a11228aeb..9dbd0b06ef 100644
--- a/client/idrepo/enduser/src/main/resources/customFormLayout.json
+++ b/client/idrepo/enduser/src/main/resources/customFormLayout.json
@@ -1,19 +1,22 @@
{
- "formClass": "org.apache.syncope.client.enduser.panels.UserFormPanel",
- "auxClasses": true,
- "groups": true,
- "plainAttrs": true,
- "derAttrs": true,
- "resources": true,
- "whichPlainAttrs": {},
- "whichDerAttrs": {},
- "passwordManagement": true,
- "detailsManagement": true,
- "sidebarLayout": {
- "editUserEnabled": true,
- "passwordManagementEnabled": true,
- "securityQuestionManagementEnabled": true,
- "extensionsEnabled": {
+ "layouts": {
+ "/": {
+ "formClass": "org.apache.syncope.client.enduser.panels.UserFormPanel",
+ "auxClasses": true,
+ "groups": true,
+ "plainAttrs": true,
+ "derAttrs": true,
+ "resources": true,
+ "whichPlainAttrs": {},
+ "whichDerAttrs": {},
+ "passwordManagement": true,
+ "detailsManagement": true,
+ "sidebarLayout": {
+ "editUserEnabled": true,
+ "passwordManagementEnabled": true,
+ "securityQuestionManagementEnabled": true,
+ "extensionsEnabled": {}
+ }
}
}
}