Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=MISSING ENTITLEMENT: CONNECTOR_READ

menu.Topology=Topology
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=DROIT MANQUANT : CONNECTOR_READ

menu.Topology=Topologie
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=ENTITLEMENT MANCANTE: CONNECTOR_READ

menu.Topology=Topologia
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=\u6a29\u5229\u4ed8\u4e0e\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093: CONNECTOR_READ

menu.Topology=\u30c8\u30dd\u30ed\u30b8\u30fc
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=MISSING ENTITLEMENT: CONNECTOR_READ

menu.Topology=Topologia
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# missingEntitlement=Нет прав доступа на просмотр коннектора (CONNECTOR_READ)
missingEntitlement=\u041d\u0435\u0442 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 (CONNECTOR_READ)

menu.Topology=\u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.ui.commons;

import java.util.HashMap;
import java.util.Map;

public class DynamicMenuRegister {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you place this class under UI commons, I would expect it to be used by both Console and Enduser, which I don't think is the case.

The correct placement would be in client-idrepo-console.

Secondly, there is no need to work with static: Console is a Spring Boot application, you can define a Bean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes It's used by both...

Static should be necessary to have the same instance Map for all the used classes.


private static final Map<String, Class<?>> KEYS_FOR_PAGES = new HashMap<>();

private DynamicMenuRegister() {
}

public static void register(final String key, final Class<?> pageClass) {
KEYS_FOR_PAGES.put(key, pageClass);
}

public static Class<?> getPage(final String key) {
return KEYS_FOR_PAGES.get(key);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.ui.commons;

import java.util.Locale;
import org.apache.wicket.core.util.resource.locator.IResourceNameIterator;
import org.apache.wicket.resource.IPropertiesFactory;
import org.apache.wicket.resource.Properties;
import org.apache.wicket.resource.loader.ClassStringResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DynamicMenuStringResourceLoader extends ClassStringResourceLoader {

protected static final Logger LOG = LoggerFactory.getLogger(DynamicMenuStringResourceLoader.class);

public DynamicMenuStringResourceLoader() {
super(DynamicMenuStringResourceLoader.class);
}

@Override
public String loadStringResource(
Class<?> clazz,
String key,
Locale locale,
String style,
String variation) {

if (key != null && key.startsWith("menu.")) {
Class<?> pageClass = DynamicMenuRegister.getPage(key);

if (pageClass != null) {
final String path = pageClass.getName().replace('.', '/');
final IResourceNameIterator iter = newResourceNameIterator(path, locale, style, variation);
final IPropertiesFactory propertiesFactory = getPropertiesFactory();

while (iter.hasNext()) {
final String newPath = iter.next();
final Properties props = propertiesFactory.load(pageClass, newPath);

if (props != null) {
final String localeLabel = props.getString(key);
LOG.debug("Found label \"{}\" for key: {}", localeLabel, key);
return localeLabel;
}
}
}
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.agilecoders.wicket.core.settings.IBootstrapSettings;
import de.agilecoders.wicket.core.settings.SingleThemeProvider;
import jakarta.servlet.http.Cookie;
import java.lang.annotation.Annotation;
import java.time.OffsetDateTime;
import java.util.Collection;
import java.util.List;
Expand All @@ -34,12 +35,15 @@
import org.apache.syncope.client.console.commons.AnyDirectoryPanelAdditionalActionLinksProvider;
import org.apache.syncope.client.console.commons.AnyDirectoryPanelAdditionalActionsProvider;
import org.apache.syncope.client.console.commons.AnyWizardBuilderAdditionalSteps;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.client.console.commons.ExternalResourceProvider;
import org.apache.syncope.client.console.commons.ImplementationInfoProvider;
import org.apache.syncope.client.console.commons.PolicyTabProvider;
import org.apache.syncope.client.console.commons.RealmsUtils;
import org.apache.syncope.client.console.commons.StatusProvider;
import org.apache.syncope.client.console.init.ClassPathScanImplementationLookup;
import org.apache.syncope.client.ui.commons.DynamicMenuStringResourceLoader;
import org.apache.syncope.client.console.pages.BaseExtPage;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.pages.Dashboard;
import org.apache.syncope.client.console.pages.Login;
Expand All @@ -53,6 +57,7 @@
import org.apache.syncope.client.ui.commons.BaseWebApplication;
import org.apache.syncope.client.ui.commons.Constants;
import org.apache.syncope.client.ui.commons.SyncopeUIRequestCycleListener;
import org.apache.syncope.client.ui.commons.annotations.ExtPage;
import org.apache.syncope.client.ui.commons.annotations.Resource;
import org.apache.syncope.client.ui.commons.themes.AdminLTE;
import org.apache.syncope.client.ui.commons.wizards.AjaxWizard;
Expand Down Expand Up @@ -240,6 +245,26 @@ protected void init() {

mountPage("/login", getSignInPageClass());

//[SYNCOPE-1942]
//--
final List<Class<? extends BasePage>> amPageClasses = lookup.getAMPageClasses();
amPageClasses.forEach(claz -> {
DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz);
});

final List<Class<? extends BasePage>> idmPageClasses = lookup.getIdMPageClasses();
idmPageClasses.forEach(claz -> {
DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz);
});

final List<Class<? extends BaseExtPage>> extPageClasses = lookup.getClasses(BaseExtPage.class);
extPageClasses.stream().filter(claz -> (claz.isAnnotationPresent(ExtPage.class))).forEach(claz -> {
DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz);
});

getResourceSettings().getStringResourceLoaders().add(new DynamicMenuStringResourceLoader());
//--

for (IResource resource : resources) {
Class<?> resourceClass = AopUtils.getTargetClass(resource);
Resource annotation = resourceClass.getAnnotation(Resource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
IdMPage ann = item.getModelObject().getAnnotation(IdMPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("idmPage", item.getModelObject());
link.add(new Label("idmPageLabel", ann.label()));
link.add(new Label("idmPageLabel", getString("menu." + ann.label(), null, ann.label())));
if (StringUtils.isNotBlank(ann.listEntitlement())) {
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.RENDER, ann.listEntitlement());
}
Expand Down Expand Up @@ -226,7 +226,8 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
AMPage ann = item.getModelObject().getAnnotation(AMPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("amPage", item.getModelObject());
link.add(new Label("amPageLabel", ann.label()));
link.add(new Label("amPageLabel", getString("menu." + ann.label(), null, ann.label())));

if (StringUtils.isNotBlank(ann.listEntitlement())) {
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.RENDER, ann.listEntitlement());
}
Expand Down Expand Up @@ -521,7 +522,7 @@ protected void populateItem(final ListItem<Class<? extends BaseExtPage>> item) {
ExtPage ann = item.getModelObject().getAnnotation(ExtPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("extPage", item.getModelObject());
link.add(new Label("extPageLabel", ann.label()));
link.add(new Label("extPageLabel", getString("menu." + ann.label(), null, ann.label())));
if (StringUtils.isNotBlank(ann.listEntitlement())) {
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.RENDER, ann.listEntitlement());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.
home=Home
version=Version
domain=Domain
domain=Domain

systemInfo=System Information
hostname=Host Name
Expand All @@ -32,4 +32,4 @@ delegations=Delegations
endDelegation=End Delegation
sessionExpiration.header=Session Expiration
sessionExpiration.body=Your session is about to expire. Please select the appropriate option to keep working.
sessionExpiration.extend=Extend
sessionExpiration.extend=Extend
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ delegations=Delegations
endDelegation=End Delegation
sessionExpiration.header=Session Expiration
sessionExpiration.body=Your session is about to expire. Please select the appropriate option to keep working.
sessionExpiration.extend=Extend
sessionExpiration.extend=Extend
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ delegations=Delegations
endDelegation=End Delegation
sessionExpiration.header=Session Expiration
sessionExpiration.body=Your session is about to expire. Please select the appropriate option to keep working.
sessionExpiration.extend=Extend
sessionExpiration.extend=Extend
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
import org.apache.syncope.client.ui.commons.BaseLogin;
import org.apache.syncope.client.ui.commons.BaseWebApplication;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.client.ui.commons.DynamicMenuStringResourceLoader;
import org.apache.syncope.client.ui.commons.SyncopeUIRequestCycleListener;
import org.apache.syncope.client.ui.commons.annotations.ExtPage;
import org.apache.syncope.client.ui.commons.annotations.Resource;
import org.apache.syncope.client.ui.commons.themes.AdminLTE;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
Expand Down Expand Up @@ -203,6 +206,26 @@ public IResource getResource() {
}
}

//[SYNCOPE-1942]
//--
final List<Class<? extends BasePage>> amPageClasses = lookup.getAMPageClasses();
amPageClasses.forEach(claz -> {
DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz);
});

final List<Class<? extends BasePage>> idmPageClasses = lookup.getIdMPageClasses();
idmPageClasses.forEach(claz -> {
DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz);
});

final List<Class<? extends BasePage>> extPageClasses = lookup.getExtPageClasses();
extPageClasses.stream().filter(claz -> (claz.isAnnotationPresent(ExtPage.class))).forEach(claz -> {
DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz);
});

getResourceSettings().getStringResourceLoaders().add(new DynamicMenuStringResourceLoader());
//--

try (InputStream is = resourceLoader.getResource(props.getCustomFormLayout()).getInputStream()) {
customFormLayout = MAPPER.readValue(is, new TypeReference<>() {
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
IdMPage ann = item.getModelObject().getAnnotation(IdMPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("idmPage", item.getModelObject());

link.add(new Label("idmPageLabel", ann.label()));
link.add(new Label("idmPageLabel", getString("menu." + ann.label(), null, ann.label())));

if (item.getModelObject().equals(pageRef.getPage().getClass())) {
link.add(new Behavior() {
Expand Down Expand Up @@ -177,8 +176,7 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
AMPage ann = item.getModelObject().getAnnotation(AMPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("amPage", item.getModelObject());

link.add(new Label("amPageLabel", ann.label()));
link.add(new Label("amPageLabel", getString("menu." + ann.label(), null, ann.label())));

if (item.getModelObject().equals(pageRef.getPage().getClass())) {
link.add(new Behavior() {
Expand Down Expand Up @@ -216,8 +214,7 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
ExtPage ann = item.getModelObject().getAnnotation(ExtPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("extPage", item.getModelObject());

link.add(new Label("extPageLabel", ann.label()));
link.add(new Label("extPageLabel", getString("menu." + ann.label(), null, ann.label())));

if (item.getModelObject().equals(pageRef.getPage().getClass())) {
link.add(new Behavior() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
xmlEditorTitle=Workflow XML Editor
userWorkflow=User workflow
external_editor.title=Flowable Modeler

menu.Flowable=Flowable
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.
xmlEditorTitle=XML \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f
userWorkflow=User workflow
external_editor.title=Flowable Modeler

menu.Flowable=Flowable
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
xmlEditorTitle=Workflow XML Editor
userWorkflow=Workflow utenti
external_editor.title=Flowable Modeler

menu.Flowable=Flowable
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
xmlEditorTitle=\u30ef\u30fc\u30af\u30d5\u30ed\u30fc XML \u30a8\u30c7\u30a3\u30bf\u30fc
userWorkflow=\u30e6\u30fc\u30b6\u30fc\u30ef\u30fc\u30af\u30d5\u30ed\u30fc
external_editor.title=Flowable \u30e2\u30c7\u30e9\u30fc

menu.Flowable=Flowable
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
xmlEditorTitle=Workflow XML Editor
userWorkflow=User workflow
external_editor.title=Flowable Modeler

menu.Flowable=Flowable
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
xmlEditorTitle=XML \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f
userWorkflow=User workflow
external_editor.title=Flowable Modeler

menu.Flowable=Flowable
Loading
Loading