diff --git a/.gitignore b/.gitignore index 16dc62e8e96..b3be89ec71b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .settings .idea *.iml +*.versionsBackup target rebel.xml samples/model-client-sample-dotnet/ModelClientSample/ModelClientSample/bin diff --git a/build-system/pom.xml b/build-system/pom.xml index 789ee3ecabf..520748dd182 100644 --- a/build-system/pom.xml +++ b/build-system/pom.xml @@ -25,7 +25,7 @@ com.evolveum.midpoint midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -406,7 +406,7 @@ com.evolveum.polygon connector-ldap - 1.4.1.23 + 1.4.2.0-SNAPSHOT com.evolveum.polygon @@ -828,6 +828,7 @@ + src/test/resources/truststore.jks target/midpoint-home ${project.build.directory}/test-classes/logging.properties diff --git a/cli/common/pom.xml b/cli/common/pom.xml index fc4ba74ed3c..9f602f1f48d 100644 --- a/cli/common/pom.xml +++ b/cli/common/pom.xml @@ -23,12 +23,12 @@ midPoint CLI Interface - common com.evolveum.midpoint.cli common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint cli - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/cli/ninja/pom.xml b/cli/ninja/pom.xml index 92b97e7a5a4..0e573815ff2 100644 --- a/cli/ninja/pom.xml +++ b/cli/ninja/pom.xml @@ -23,12 +23,12 @@ midPoint CLI Interface - ninja com.evolveum.midpoint.cli ninja - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint cli - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/cli/pom.xml b/cli/pom.xml index bcb4bbbfccd..a471a5cd414 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -22,13 +22,13 @@ midPoint CLI Interface cli - 3.2-SNAPSHOT + 3.3-SNAPSHOT pom parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/cli/seppuku/pom.xml b/cli/seppuku/pom.xml index df633f75e18..c92371c674c 100644 --- a/cli/seppuku/pom.xml +++ b/cli/seppuku/pom.xml @@ -23,12 +23,12 @@ midPoint CLI Interface - seppuku com.evolveum.midpoint.cli seppuku - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint cli - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/custom/pom.xml b/custom/pom.xml index 3d6e3bec8af..04331affaf5 100644 --- a/custom/pom.xml +++ b/custom/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/dist/midpoint-api/pom.xml b/dist/midpoint-api/pom.xml index 244503b4db2..2710a2fe1fd 100644 --- a/dist/midpoint-api/pom.xml +++ b/dist/midpoint-api/pom.xml @@ -24,7 +24,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -51,22 +51,22 @@ com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/dist/pom.xml b/dist/pom.xml index e04a17c0240..503185882ff 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -24,7 +24,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml @@ -51,20 +51,20 @@ com.evolveum.midpoint.gui admin-gui - 3.2-SNAPSHOT + 3.3-SNAPSHOT war com.evolveum.midpoint.tools repo-ninja - 3.2-SNAPSHOT + 3.3-SNAPSHOT zip bin com.evolveum.midpoint.tools repo-ninja - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/gui/admin-gui-en-US/pom.xml b/gui/admin-gui-en-US/pom.xml index ff33f66a434..75d5991af66 100644 --- a/gui/admin-gui-en-US/pom.xml +++ b/gui/admin-gui-en-US/pom.xml @@ -21,11 +21,11 @@ com.evolveum.midpoint.gui admin-gui-en-US jar - 3.2-SNAPSHOT + 3.3-SNAPSHOT gui com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -44,7 +44,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/gui/admin-gui-es-ES/pom.xml b/gui/admin-gui-es-ES/pom.xml index dd4e639770d..d26db87772d 100644 --- a/gui/admin-gui-es-ES/pom.xml +++ b/gui/admin-gui-es-ES/pom.xml @@ -21,11 +21,11 @@ com.evolveum.midpoint.gui admin-gui-es-ES jar - 3.2-SNAPSHOT + 3.3-SNAPSHOT gui com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -44,7 +44,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/gui/admin-gui-sk-SK/pom.xml b/gui/admin-gui-sk-SK/pom.xml index a4242b50b50..f40883afdc0 100644 --- a/gui/admin-gui-sk-SK/pom.xml +++ b/gui/admin-gui-sk-SK/pom.xml @@ -21,11 +21,11 @@ com.evolveum.midpoint.gui admin-gui-sk-SK jar - 3.2-SNAPSHOT + 3.3-SNAPSHOT gui com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -44,7 +44,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/gui/admin-gui-tr-TR/pom.xml b/gui/admin-gui-tr-TR/pom.xml index fc17a776749..904b0adbe16 100644 --- a/gui/admin-gui-tr-TR/pom.xml +++ b/gui/admin-gui-tr-TR/pom.xml @@ -21,11 +21,11 @@ com.evolveum.midpoint.gui admin-gui-tr-TR jar - 3.2-SNAPSHOT + 3.3-SNAPSHOT gui com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -39,7 +39,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/gui/admin-gui/pom.xml b/gui/admin-gui/pom.xml index e89bd9b9004..6c95a225aaa 100644 --- a/gui/admin-gui/pom.xml +++ b/gui/admin-gui/pom.xml @@ -20,11 +20,11 @@ com.evolveum.midpoint.gui admin-gui war - 3.2-SNAPSHOT + 3.3-SNAPSHOT gui com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -188,22 +188,22 @@ com.evolveum.midpoint.gui admin-gui-en-US - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.gui admin-gui-sk-SK - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.gui admin-gui-tr-TR - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.gui admin-gui-es-ES - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -216,7 +216,7 @@ com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT jaxb-impl @@ -231,38 +231,38 @@ com.evolveum.midpoint.model report-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model certification-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model workflow-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model notifications-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime @@ -278,7 +278,7 @@ com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime @@ -302,25 +302,25 @@ com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime @@ -332,31 +332,31 @@ com.evolveum.midpoint.model certification-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.model workflow-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.model notifications-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime @@ -368,13 +368,13 @@ com.evolveum.midpoint.model report-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime com.evolveum.midpoint.model report-ds-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT runtime @@ -392,7 +392,7 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT xml-apis @@ -496,13 +496,13 @@ com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -519,7 +519,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -641,7 +641,7 @@ com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/MenuItem.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/MenuItem.java index ba6fc6e0c2f..a0f06e4374f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/MenuItem.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/MenuItem.java @@ -1,12 +1,14 @@ package com.evolveum.midpoint.web.component.menu.top; import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; -import com.github.sommeri.less4j.core.ast.Page; +import org.apache.commons.lang.Validate; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.model.IModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * @author lazyman @@ -19,6 +21,8 @@ public class MenuItem implements Serializable { private boolean menuHeader; private PageParameters pageParameters; + private List dependsOn; + public MenuItem(IModel name) { this(name, false, null, null); } @@ -68,4 +72,20 @@ public boolean isDivider() { public PageParameters getPageParameters() { return pageParameters; } + + public List getDependsOn() { + if (dependsOn == null) { + dependsOn = new ArrayList<>(); + } + return dependsOn; + } + + public void setDependsOn(List dependsOn) { + this.dependsOn = dependsOn; + } + + public void addDependsOn(MenuItem item) { + Validate.notNull(item, "Menu item must not be null."); + getDependsOn().add(item); + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/TopMenuBar.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/TopMenuBar.java index d3c5d2e2983..b3276280174 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/TopMenuBar.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/menu/top/TopMenuBar.java @@ -1,6 +1,7 @@ package com.evolveum.midpoint.web.component.menu.top; import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; +import com.evolveum.midpoint.web.security.SecurityUtils; import org.apache.wicket.Application; import org.apache.wicket.AttributeModifier; import org.apache.wicket.Page; @@ -112,7 +113,7 @@ protected void populateItem(ListItem menuItem) { }); } - private void initMenuItem(ListItem menuItem) { + private void initMenuItem(final ListItem menuItem) { final MenuItem item = menuItem.getModelObject(); if (item.isMenuHeader()) { menuItem.add(new AttributeModifier("class", "dropdown-header")); @@ -128,5 +129,29 @@ private void initMenuItem(ListItem menuItem) { } menuItemBody.setRenderBodyOnly(true); menuItem.add(menuItemBody); + + + menuItem.add(new VisibleEnableBehaviour() { + + @Override + public boolean isVisible() { + MenuItem item = menuItem.getModelObject(); + return SecurityUtils.isMenuAuthorized(item) || areDependentsVisible(item); + } + }); + } + + private boolean areDependentsVisible(MenuItem item) { + if (item.getDependsOn().isEmpty()) { + return false; + } + + for (MenuItem dependend : item.getDependsOn()) { + if (!SecurityUtils.isMenuAuthorized(dependend)) { + return false; + } + } + + return true; } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdmin.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdmin.java index 722b7f5ba91..9f970243f48 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdmin.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdmin.java @@ -56,6 +56,7 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -139,13 +140,20 @@ private MenuBarItem createWorkItemsItems() { PageWorkItems.class)); workItems.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listClaimable"), PageWorkItemsClaimable.class)); - workItems.addMenuItem(new MenuItem(null)); - workItems.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listProcessInstancesAll"), - PageProcessInstancesAll.class)); - workItems.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listProcessInstancesRequestedBy"), - PageProcessInstancesRequestedBy.class)); - workItems.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listProcessInstancesRequestedFor"), - PageProcessInstancesRequestedFor.class)); + + MenuItem processAll = new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listProcessInstancesAll"), + PageProcessInstancesAll.class); + MenuItem processBy = new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listProcessInstancesRequestedBy"), + PageProcessInstancesRequestedBy.class); + MenuItem processFor = new MenuItem(createStringResource("PageAdmin.menu.top.workItems.listProcessInstancesRequestedFor"), + PageProcessInstancesRequestedFor.class); + MenuItem divider = new MenuItem(null); + divider.setDependsOn(Arrays.asList(new MenuItem[]{processAll, processBy, processFor})); + + workItems.addMenuItem(divider); + workItems.addMenuItem(processAll); + workItems.addMenuItem(processBy); + workItems.addMenuItem(processFor); return workItems; } @@ -180,10 +188,21 @@ private MenuBarItem createCertificationItems() { MenuBarItem certification = new MenuBarItem(createStringResource("PageAdmin.menu.top.certification"), null); certification.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.certification.definitions"), PageCertDefinitions.class)); certification.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.certification.newDefinition"), PageImportObject.class)); - certification.addMenuItem(new MenuItem(null)); - certification.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.certification.campaigns"), PageCertCampaigns.class)); - certification.addMenuItem(new MenuItem(null)); - certification.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.certification.decisions"), PageCertDecisions.class)); + + + MenuItem campaigns = new MenuItem(createStringResource("PageAdmin.menu.top.certification.campaigns"), PageCertCampaigns.class); + MenuItem divider = new MenuItem(null); + divider.addDependsOn(campaigns); + + certification.addMenuItem(divider); + certification.addMenuItem(campaigns); + + MenuItem decisions = new MenuItem(createStringResource("PageAdmin.menu.top.certification.decisions"), PageCertDecisions.class); + divider = new MenuItem(null); + divider.addDependsOn(decisions); + + certification.addMenuItem(divider); + certification.addMenuItem(decisions); return certification; } @@ -193,25 +212,46 @@ private MenuBarItem createConfigurationItems() { configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.bulkActions"), PageBulkAction.class)); configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.importObject"), PageImportObject.class)); configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.repositoryObjects"), PageDebugList.class)); - configuration.addMenuItem(new MenuItem(null)); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.configuration"), true, null, null)); PageParameters params = new PageParameters(); params.add(PageSystemConfiguration.SELECTED_TAB_INDEX, PageSystemConfiguration.CONFIGURATION_TAB_BASIC); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.basic"), PageSystemConfiguration.class, params)); + MenuItem basic = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.basic"), PageSystemConfiguration.class, params); params = new PageParameters(); params.add(PageSystemConfiguration.SELECTED_TAB_INDEX, PageSystemConfiguration.CONFIGURATION_TAB_LOGGING); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.logging"), PageSystemConfiguration.class, params)); + MenuItem logging = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.logging"), PageSystemConfiguration.class, params); + + MenuItem header = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.configuration"), true, null, null); + header.setDependsOn(Arrays.asList(new MenuItem[]{basic, logging})); + MenuItem divider = new MenuItem(null); + divider.setDependsOn(Arrays.asList(new MenuItem[]{basic, logging})); + + configuration.addMenuItem(divider); + configuration.addMenuItem(header); + configuration.addMenuItem(basic); + configuration.addMenuItem(logging); + + MenuItem details = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.shadowsDetails"), PageAccounts.class); + MenuItem internals = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.internals"), PageInternals.class); + + header = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.development"), true, null, null); + header.setDependsOn(Arrays.asList(new MenuItem[]{details, internals})); + divider = new MenuItem(null); + divider.setDependsOn(Arrays.asList(new MenuItem[]{details, internals})); // configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.security"), PageDashboard.class)); - configuration.addMenuItem(new MenuItem(null)); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.development"), true, null, null)); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.shadowsDetails"), PageAccounts.class)); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.internals"), PageInternals.class)); + configuration.addMenuItem(divider); + configuration.addMenuItem(header); + configuration.addMenuItem(details); + configuration.addMenuItem(internals); // configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.expressionEvaluator"), PageDashboard.class)); - configuration.addMenuItem(new MenuItem(null)); - configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.about"), PageAbout.class)); + + MenuItem about = new MenuItem(createStringResource("PageAdmin.menu.top.configuration.about"), PageAbout.class); + divider = new MenuItem(null); + divider.addDependsOn(about); + + configuration.addMenuItem(divider); + configuration.addMenuItem(about); return configuration; } @@ -227,10 +267,20 @@ private MenuBarItem createUsersItems() { users.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.users.list"), PageUsers.class)); // users.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.users.find"), PageFindUsers.class)); users.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.users.new"), PageUser.class)); - users.addMenuItem(new MenuItem(null)); - users.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.users.org"), true, null, null)); - users.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.users.org.tree"), PageOrgTree.class)); - users.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.users.org.new"), PageOrgUnit.class)); + + MenuItem orgTree = new MenuItem(createStringResource("PageAdmin.menu.top.users.org.tree"), PageOrgTree.class); + MenuItem orgNew = new MenuItem(createStringResource("PageAdmin.menu.top.users.org.new"), PageOrgUnit.class); + List orgs = Arrays.asList(new MenuItem[]{orgTree, orgNew}); + + MenuItem divider = new MenuItem(null); + divider.setDependsOn(orgs); + MenuItem org = new MenuItem(createStringResource("PageAdmin.menu.top.users.org"), true, null, null); + org.setDependsOn(orgs); + + users.addMenuItem(divider); + users.addMenuItem(org); + users.addMenuItem(orgTree); + users.addMenuItem(orgNew); return users; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java index d750374aff8..c01b40be515 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java @@ -39,6 +39,7 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.logging.LoggingUtils; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -1184,8 +1185,8 @@ private void suspendPerformed(AjaxRequestTarget target) { result.recordWarning("Task suspension has been successfully requested; please check for its completion using task list."); } } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't suspend the task due to an unexpected exception", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't suspend the task", e); } showResultInSession(result); @@ -1202,8 +1203,8 @@ private void resumePerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "The task has been successfully resumed."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't resume the task due to an unexpected exception", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't resume the task", e); } showResultInSession(result); @@ -1220,8 +1221,8 @@ private void runNowPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "The task has been successfully scheduled to run."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't schedule the task due to an unexpected exception", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't schedule the task", e); } showResultInSession(result); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java index 27e96d42f3e..cee93e50eb4 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java @@ -23,6 +23,9 @@ import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskExecutionStatus; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.logging.LoggingUtils; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -809,8 +812,8 @@ private void suspendTasksPerformed(AjaxRequestTarget target) { result.recordWarning("Task(s) suspension has been successfully requested; please check for its completion using task list."); } } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't suspend the task(s) due to an unexpected exception", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't suspend the task(s)", e); } showResult(result); @@ -833,8 +836,8 @@ private void resumeTasksPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "The task(s) have been successfully resumed."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't resume the task(s) due to an unexpected exception", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't resume the task(s)", e); } showResult(result); @@ -857,8 +860,8 @@ private void deleteTasksPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "The task(s) have been successfully deleted."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't delete the task(s) because of an unexpected exception", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't delete the task(s)", e); } showResult(result); @@ -884,8 +887,8 @@ private void scheduleTasksPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "The task(s) have been successfully scheduled."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't schedule the task(s) due to an unexpected exception.", e); + } catch (ObjectNotFoundException|SchemaException|SecurityViolationException|RuntimeException e) { + result.recordFatalError("Couldn't schedule the task(s)", e); } showResult(result); @@ -918,8 +921,8 @@ private void stopSchedulersAndTasksPerformed(AjaxRequestTarget target) { result.recordWarning("Selected node scheduler(s) have been successfully paused; however, some of the tasks they were executing are still running on them. Please check their completion using task list."); } } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't stop schedulers due to an unexpected exception.", e); + } catch (SecurityViolationException|ObjectNotFoundException|SchemaException|RuntimeException e) { + result.recordFatalError("Couldn't stop schedulers due", e); } showResult(result); @@ -942,8 +945,8 @@ private void startSchedulersPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "Selected node scheduler(s) have been successfully started."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't start the scheduler(s) because of unexpected exception.", e); + } catch (SecurityViolationException|ObjectNotFoundException|SchemaException|RuntimeException e) { + result.recordFatalError("Couldn't start the scheduler(s)", e); } showResult(result); @@ -967,8 +970,8 @@ private void stopSchedulersPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "Selected node scheduler(s) have been successfully stopped."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't stop the scheduler(s) because of unexpected exception.", e); + } catch (SecurityViolationException|ObjectNotFoundException|SchemaException|RuntimeException e) { + result.recordFatalError("Couldn't stop the scheduler(s)", e); } showResult(result); @@ -989,7 +992,7 @@ private void deleteNodesPerformed(AjaxRequestTarget target) { Task task = createSimpleTask(OPERATION_DELETE_NODES); for (NodeDto nodeDto : nodeDtoList) { - Collection> deltas = new ArrayList>(); + Collection> deltas = new ArrayList<>(); deltas.add(ObjectDelta.createDeleteDelta(NodeType.class, nodeDto.getOid(), getPrismContext())); try { getModelService().executeChanges(deltas, null, task, result); @@ -1028,8 +1031,8 @@ private void deactivateServiceThreadsPerformed(AjaxRequestTarget target) { result.recordWarning("Deactivation of service threads on local node have been successfully requested; however, some of the tasks are still running. Please check their completion using task list."); } } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't deactivate service threads on this node because of an unexpected exception.", e); + } catch (RuntimeException|SchemaException|SecurityViolationException e) { + result.recordFatalError("Couldn't deactivate service threads on this node", e); } showResult(result); @@ -1048,8 +1051,8 @@ private void reactivateServiceThreadsPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { result.recordStatus(OperationResultStatus.SUCCESS, "Service threads on local node have been successfully reactivated."); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't reactivate service threads on local node because of an unexpected exception.", e); + } catch (RuntimeException|SchemaException|SecurityViolationException e) { + result.recordFatalError("Couldn't reactivate service threads on local node", e); } showResult(result); @@ -1068,8 +1071,8 @@ private void synchronizeTasksPerformed(AjaxRequestTarget target) { if (result.isSuccess()) { // brutal hack - the subresult's message contains statistics result.recordStatus(OperationResultStatus.SUCCESS, result.getLastSubresult().getMessage()); } - } catch (RuntimeException e) { - result.recordFatalError("Couldn't synchronize tasks because of an unexpected exception.", e); + } catch (RuntimeException|SchemaException|SecurityViolationException e) { + result.recordFatalError("Couldn't synchronize tasks", e); } showResult(result); @@ -1122,7 +1125,7 @@ private ObjectQuery createTaskQuery(){ ObjectQuery query = null; try { - List filters = new ArrayList(); + List filters = new ArrayList<>(); if (status != null) { ObjectFilter filter = status.createFilter(TaskType.class, getPrismContext()); if (filter != null) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/dto/TaskDto.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/dto/TaskDto.java index db9272fae9f..f4d88c52829 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/dto/TaskDto.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/dto/TaskDto.java @@ -333,7 +333,6 @@ private String getTaskObjectName(TaskType taskType, TaskManager taskManager, Mod private void fillInParentTaskAttributes(TaskType taskType, TaskService taskService, TaskDtoProviderOptions options, OperationResult thisOpResult) { if (options.isGetTaskParent() && taskType.getParent() != null) { - Throwable failReason = null; try { //TaskType parentTaskType = taskService.getTaskByIdentifier(taskType.getParent(), GetOperationOptions.createRetrieveNameOnlyOptions(), thisOpResult).asObjectable(); TaskType parentTaskType = taskService.getTaskByIdentifier(taskType.getParent(), null, thisOpResult).asObjectable(); @@ -341,13 +340,8 @@ private void fillInParentTaskAttributes(TaskType taskType, TaskService taskServi parentTaskName = parentTaskType.getName() != null ? parentTaskType.getName().getOrig() : "(unnamed)"; // todo i18n parentTaskOid = parentTaskType.getOid(); } - } catch (SchemaException e) { - failReason = e; - } catch (ObjectNotFoundException e) { - failReason = e; - } - if (failReason != null) { - LoggingUtils.logException(LOGGER, "Couldn't retrieve parent task for task {}", failReason, taskType.getOid()); + } catch (SchemaException|ObjectNotFoundException|SecurityViolationException|ConfigurationException e) { + LoggingUtils.logException(LOGGER, "Couldn't retrieve parent task for task {}", e, taskType.getOid()); } } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointApplication.properties b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointApplication.properties index 5aff7694f6c..8122a846bb6 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointApplication.properties +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointApplication.properties @@ -270,6 +270,9 @@ ActivationType.effectiveStatus=Effective status ActivationType.validFrom=Valid from ActivationType.validTo=Valid to +LockoutStatusType.NORMAL=Normal +LockoutStatusType.LOCKED=Locked + operation.com.evolveum.midpoint.common.operation.import.object=Import object operation.com.evolveum.midpoint.common.validator.Validator.objectBasicsCheck=Basic checks operation.com.evolveum.midpoint.common.validator.Validator.resourceNamespaceCheck=Resource namespace check diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/SecurityUtils.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/SecurityUtils.java index 51c5fe77a76..80b708f4e6e 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/SecurityUtils.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/SecurityUtils.java @@ -20,9 +20,16 @@ import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.web.application.AuthorizationAction; +import com.evolveum.midpoint.web.application.PageDescriptor; +import com.evolveum.midpoint.web.component.menu.top.MenuItem; +import com.evolveum.midpoint.web.util.WebMiscUtil; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; +import java.util.ArrayList; +import java.util.List; + /** * @author lazyman */ @@ -51,4 +58,27 @@ public static MidPointPrincipal getPrincipalUser(Authentication authentication) return (MidPointPrincipal) principal; } + + public static boolean isMenuAuthorized(MenuItem item) { + Class clazz = item.getPage(); + if (clazz == null) { + return false; + } + + PageDescriptor descriptor = (PageDescriptor) clazz.getAnnotation(PageDescriptor.class); + if (descriptor == null ){ + return false; + } + + + AuthorizationAction[] actions = descriptor.action(); + List list = new ArrayList<>(); + if (actions != null) { + for (AuthorizationAction action : actions) { + list.add(action.actionUri()); + } + } + + return WebMiscUtil.isAuthorized(list.toArray(new String[list.size()])); + } } diff --git a/gui/admin-gui/src/main/resources/initial-objects/090-report-audit.xml b/gui/admin-gui/src/main/resources/initial-objects/090-report-audit.xml index 39a67557c61..c3524301135 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/090-report-audit.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/090-report-audit.xml @@ -1,16 +1,30 @@ - - Audit logs report + + + Audit logs report Report made from audit records. true - + UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQWdJQ0FnQ1R4emRIbHNaU0JtYjI1MFRtRnRaVDBpUkdWcVlWWjFJRk5oYm5NaUlHWnZiblJUYVhwbFBTSXhNQ0lnYUVGc2FXZHVQU0pNWldaMElpQnBjMFJsWm1GMWJIUTlJblJ5ZFdVaUlHbHpVR1JtUlcxaVpXUmtaV1E5SW5SeWRXVWlJQTBLQ1FrSkNTQWdJRzVoYldVOUlrSmhjMlVpSUhCa1prVnVZMjlrYVc1blBTSkpaR1Z1ZEdsMGVTMUlJaUJ3WkdaR2IyNTBUbUZ0WlQwaVJHVnFZVloxVTJGdWN5NTBkR1lpSUhaQmJHbG5iajBpVFdsa1pHeGxJajROQ2drSkNUd3ZjM1I1YkdVK0RRb0pDUWs4YzNSNWJHVWdZbUZqYTJOdmJHOXlQU0lqTWpZM09UazBJaUJtYjI1MFUybDZaVDBpTWpZaUlHWnZjbVZqYjJ4dmNqMGlJMFpHUmtaR1JpSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0J0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWxScGRHeGxJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBpQU5DZ2tKQ1R4emRIbHNaU0JtYjI1MFUybDZaVDBpTVRJaUlHWnZjbVZqYjJ4dmNqMGlJekF3TURBd01DSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSWdibUZ0WlQwaVVHRm5aU0JvWldGa1pYSWlEUW9nSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnYzNSNWJHVTlJa0poYzJVaUx6NE5DZ2tKQ1R4emRIbHNaU0JpWVdOclkyOXNiM0k5SWlNek16TXpNek1pSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqUmtaR1JrWkdJaUJvUVd4cFoyNDlJa05sYm5SbGNpSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0JwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWtOdmJIVnRiaUJvWldGa1pYSWlJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdhWE5DYjJ4a1BTSm1ZV3h6WlNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpUkdWMFlXbHNJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBnMEtJQ0FnSUNBZ0lDQWdJQ0FnUEhOMGVXeGxJR2x6UW05c1pEMGlabUZzYzJVaUlHbHpSR1ZtWVhWc2REMGlabUZzYzJVaUlHNWhiV1U5SWtOdlpHVWlJSE4wZVd4bFBTSkNZWE5sSWlCbWIyNTBVMmw2WlQwaU9TSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJNUlpQm1iM0psWTI5c2IzSTlJaU13TURBd01EQWlJR2x6UkdWbVlYVnNkRDBpWm1Gc2MyVWlJRzVoYldVOUlsQmhaMlVnWm05dmRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUhOMGVXeGxQU0pDWVhObElpOCtEUW9KQ1R3dmFtRnpjR1Z5VkdWdGNHeGhkR1Ur - landscape html - + \ No newline at end of file diff --git a/gui/admin-gui/src/main/resources/initial-objects/100-report-reconciliation.xml b/gui/admin-gui/src/main/resources/initial-objects/100-report-reconciliation.xml index c46a64c9cc4..1118d9b60d2 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/100-report-reconciliation.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/100-report-reconciliation.xml @@ -1,21 +1,30 @@ - + + oid="00000000-0000-0000-0000-000000000100"> Reconciliation report Reconciliation report for selected resource. true - - owner - - - - UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQUpDVHh6ZEhsc1pTQm1iMjUwVG1GdFpUMGlSR1ZxWVZaMUlGTmhibk1pSUdadmJuUlRhWHBsUFNJeE1DSWdhRUZzYVdkdVBTSk1aV1owSWlCcGMwUmxabUYxYkhROUluUnlkV1VpSUdselVHUm1SVzFpWldSa1pXUTlJblJ5ZFdVaUlBMEtDUWtKQ1NBZ0lHNWhiV1U5SWtKaGMyVWlJSEJrWmtWdVkyOWthVzVuUFNKSlpHVnVkR2wwZVMxSUlpQndaR1pHYjI1MFRtRnRaVDBpUkdWcVlWWjFVMkZ1Y3k1MGRHWWlJSFpCYkdsbmJqMGlUV2xrWkd4bElqNE5DZ2tKQ1R3dmMzUjViR1UrRFFvSkNRazhjM1I1YkdVZ1ltRmphMk52Ykc5eVBTSWpNalkzT1RrMElpQm1iMjUwVTJsNlpUMGlNallpSUdadmNtVmpiMnh2Y2owaUkwWkdSa1pHUmlJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnRiMlJsUFNKUGNHRnhkV1VpSUc1aGJXVTlJbFJwZEd4bElpQnpkSGxzWlQwaVFtRnpaU0l2UGlBTkNna0pDVHh6ZEhsc1pTQm1iMjUwVTJsNlpUMGlNVElpSUdadmNtVmpiMnh2Y2owaUl6QXdNREF3TUNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpVUdGblpTQm9aV0ZrWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pDVHh6ZEhsc1pTQmlZV05yWTI5c2IzSTlJaU16TXpNek16TWlJR1p2Ym5SVGFYcGxQU0l4TWlJZ1ptOXlaV052Ykc5eVBTSWpSa1pHUmtaR0lpQm9RV3hwWjI0OUlrTmxiblJsY2lJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnBjMFJsWm1GMWJIUTlJbVpoYkhObElpQnRiMlJsUFNKUGNHRnhkV1VpSUc1aGJXVTlJa052YkhWdGJpQm9aV0ZrWlhJaUlITjBlV3hsUFNKQ1lYTmxJaTgrRFFvSkNRazhjM1I1YkdVZ2FYTkNiMnhrUFNKbVlXeHpaU0lnYVhORVpXWmhkV3gwUFNKbVlXeHpaU0lnYm1GdFpUMGlSR1YwWVdsc0lpQnpkSGxzWlQwaVFtRnpaU0l2UGcwS0NRa0pQSE4wZVd4bElHWnZiblJUYVhwbFBTSTVJaUJtYjNKbFkyOXNiM0k5SWlNd01EQXdNREFpSUdselJHVm1ZWFZzZEQwaVptRnNjMlVpSUc1aGJXVTlJbEJoWjJVZ1ptOXZkR1Z5SWcwS0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lITjBlV3hsUFNKQ1lYTmxJaTgrRFFvSkNUd3ZhbUZ6Y0dWeVZHVnRjR3hoZEdVKw== - landscape + + UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQWdJQ0FnQ1R4emRIbHNaU0JtYjI1MFRtRnRaVDBpUkdWcVlWWjFJRk5oYm5NaUlHWnZiblJUYVhwbFBTSXhNQ0lnYUVGc2FXZHVQU0pNWldaMElpQnBjMFJsWm1GMWJIUTlJblJ5ZFdVaUlHbHpVR1JtUlcxaVpXUmtaV1E5SW5SeWRXVWlJQTBLQ1FrSkNTQWdJRzVoYldVOUlrSmhjMlVpSUhCa1prVnVZMjlrYVc1blBTSkpaR1Z1ZEdsMGVTMUlJaUJ3WkdaR2IyNTBUbUZ0WlQwaVJHVnFZVloxVTJGdWN5NTBkR1lpSUhaQmJHbG5iajBpVFdsa1pHeGxJajROQ2drSkNUd3ZjM1I1YkdVK0RRb0pDUWs4YzNSNWJHVWdZbUZqYTJOdmJHOXlQU0lqTWpZM09UazBJaUJtYjI1MFUybDZaVDBpTWpZaUlHWnZjbVZqYjJ4dmNqMGlJMFpHUmtaR1JpSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0J0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWxScGRHeGxJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBpQU5DZ2tKQ1R4emRIbHNaU0JtYjI1MFUybDZaVDBpTVRJaUlHWnZjbVZqYjJ4dmNqMGlJekF3TURBd01DSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSWdibUZ0WlQwaVVHRm5aU0JvWldGa1pYSWlEUW9nSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnYzNSNWJHVTlJa0poYzJVaUx6NE5DZ2tKQ1R4emRIbHNaU0JpWVdOclkyOXNiM0k5SWlNek16TXpNek1pSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqUmtaR1JrWkdJaUJvUVd4cFoyNDlJa05sYm5SbGNpSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0JwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWtOdmJIVnRiaUJvWldGa1pYSWlJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdhWE5DYjJ4a1BTSm1ZV3h6WlNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpUkdWMFlXbHNJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBnMEtJQ0FnSUNBZ0lDQWdJQ0FnUEhOMGVXeGxJR2x6UW05c1pEMGlabUZzYzJVaUlHbHpSR1ZtWVhWc2REMGlabUZzYzJVaUlHNWhiV1U5SWtOdlpHVWlJSE4wZVd4bFBTSkNZWE5sSWlCbWIyNTBVMmw2WlQwaU9TSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJNUlpQm1iM0psWTI5c2IzSTlJaU13TURBd01EQWlJR2x6UkdWbVlYVnNkRDBpWm1Gc2MyVWlJRzVoYldVOUlsQmhaMlVnWm05dmRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUhOMGVXeGxQU0pDWVhObElpOCtEUW9KQ1R3dmFtRnpjR1Z5VkdWdGNHeGhkR1Ur pdf - \ No newline at end of file + \ No newline at end of file diff --git a/gui/admin-gui/src/main/resources/initial-objects/110-report-user-list.xml b/gui/admin-gui/src/main/resources/initial-objects/110-report-user-list.xml index cd27b61fb12..ed662d6d82e 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/110-report-user-list.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/110-report-user-list.xml @@ -1,5 +1,21 @@ - + + Users in MidPoint Users listed in MidPoint. true - - UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQUpDVHh6ZEhsc1pTQm1iMjUwVTJsNlpUMGlNVEFpSUdoQmJHbG5iajBpVEdWbWRDSWdhWE5FWldaaGRXeDBQU0owY25WbElpQnBjMUJrWmtWdFltVmtaR1ZrUFNKbVlXeHpaU0lnYm1GdFpUMGlRbUZ6WlNJTkNna0pDUWtnSUNCd1pHWkZibU52WkdsdVp6MGlRM0F4TWpVeUlnMEtDUWtKQ1NBZ0lIQmtaa1p2Ym5ST1lXMWxQU0pJWld4MlpYUnBZMkVpRFFvZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ2RrRnNhV2R1UFNKTmFXUmtiR1VpTHo0TkNna0pDVHh6ZEhsc1pTQmlZV05yWTI5c2IzSTlJaU15TmpjNU9UUWlJR1p2Ym5SVGFYcGxQU0l5TmlJZ1ptOXlaV052Ykc5eVBTSWpSa1pHUmtaR0lpQnBjMFJsWm1GMWJIUTlJbVpoYkhObElnMEtJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJRzF2WkdVOUlrOXdZWEYxWlNJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnVZVzFsUFNKVWFYUnNaU0lOQ2lBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNCemRIbHNaVDBpUW1GelpTSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqTURBd01EQXdJaUJwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ1WVcxbFBTSlFZV2RsSUdobFlXUmxjaUlOQ2lBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNCemRIbHNaVDBpUW1GelpTSXZQZzBLQ1FrSlBITjBlV3hsSUdKaFkydGpiMnh2Y2owaUl6TXpNek16TXlJZ1ptOXVkRk5wZW1VOUlqRXlJaUJtYjNKbFkyOXNiM0k5SWlOR1JrWkdSa1lpSUdoQmJHbG5iajBpUTJWdWRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUdselJHVm1ZWFZzZEQwaVptRnNjMlVpRFFvZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ2JXOWtaVDBpVDNCaGNYVmxJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUc1aGJXVTlJa052YkhWdGJpQm9aV0ZrWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pDVHh6ZEhsc1pTQnBjMEp2YkdROUltWmhiSE5sSWlCcGMwUmxabUYxYkhROUltWmhiSE5sSWlCdVlXMWxQU0pFWlhSaGFXd2lJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdabTl1ZEZOcGVtVTlJamtpSUdadmNtVmpiMnh2Y2owaUl6QXdNREF3TUNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpVUdGblpTQm1iMjkwWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pQQzlxWVhOd1pYSlVaVzF3YkdGMFpUND0= - landscape + + UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQWdJQ0FnQ1R4emRIbHNaU0JtYjI1MFRtRnRaVDBpUkdWcVlWWjFJRk5oYm5NaUlHWnZiblJUYVhwbFBTSXhNQ0lnYUVGc2FXZHVQU0pNWldaMElpQnBjMFJsWm1GMWJIUTlJblJ5ZFdVaUlHbHpVR1JtUlcxaVpXUmtaV1E5SW5SeWRXVWlJQTBLQ1FrSkNTQWdJRzVoYldVOUlrSmhjMlVpSUhCa1prVnVZMjlrYVc1blBTSkpaR1Z1ZEdsMGVTMUlJaUJ3WkdaR2IyNTBUbUZ0WlQwaVJHVnFZVloxVTJGdWN5NTBkR1lpSUhaQmJHbG5iajBpVFdsa1pHeGxJajROQ2drSkNUd3ZjM1I1YkdVK0RRb0pDUWs4YzNSNWJHVWdZbUZqYTJOdmJHOXlQU0lqTWpZM09UazBJaUJtYjI1MFUybDZaVDBpTWpZaUlHWnZjbVZqYjJ4dmNqMGlJMFpHUmtaR1JpSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0J0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWxScGRHeGxJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBpQU5DZ2tKQ1R4emRIbHNaU0JtYjI1MFUybDZaVDBpTVRJaUlHWnZjbVZqYjJ4dmNqMGlJekF3TURBd01DSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSWdibUZ0WlQwaVVHRm5aU0JvWldGa1pYSWlEUW9nSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnYzNSNWJHVTlJa0poYzJVaUx6NE5DZ2tKQ1R4emRIbHNaU0JpWVdOclkyOXNiM0k5SWlNek16TXpNek1pSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqUmtaR1JrWkdJaUJvUVd4cFoyNDlJa05sYm5SbGNpSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0JwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWtOdmJIVnRiaUJvWldGa1pYSWlJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdhWE5DYjJ4a1BTSm1ZV3h6WlNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpUkdWMFlXbHNJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBnMEtJQ0FnSUNBZ0lDQWdJQ0FnUEhOMGVXeGxJR2x6UW05c1pEMGlabUZzYzJVaUlHbHpSR1ZtWVhWc2REMGlabUZzYzJVaUlHNWhiV1U5SWtOdlpHVWlJSE4wZVd4bFBTSkNZWE5sSWlCbWIyNTBVMmw2WlQwaU9TSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJNUlpQm1iM0psWTI5c2IzSTlJaU13TURBd01EQWlJR2x6UkdWbVlYVnNkRDBpWm1Gc2MyVWlJRzVoYldVOUlsQmhaMlVnWm05dmRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUhOMGVXeGxQU0pDWVhObElpOCtEUW9KQ1R3dmFtRnpjR1Z5VkdWdGNHeGhkR1Ur xls - \ No newline at end of file + diff --git a/gui/admin-gui/src/main/resources/initial-objects/111-report-reconciliation-shadow-owner.xml b/gui/admin-gui/src/main/resources/initial-objects/111-report-reconciliation-shadow-owner.xml deleted file mode 100644 index f8bd7ecf4f7..00000000000 --- a/gui/admin-gui/src/main/resources/initial-objects/111-report-reconciliation-shadow-owner.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - Shadow owner subreport - Shadow owner subreport for reconciliation report - false - - landscape - pdf - diff --git a/gui/pom.xml b/gui/pom.xml index 5fe24b78b0e..8bc1b3eaf64 100644 --- a/gui/pom.xml +++ b/gui/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/icf-connectors/dummy-connector-fake/pom.xml b/icf-connectors/dummy-connector-fake/pom.xml index 09cccf07b75..58c415f9ff6 100644 --- a/icf-connectors/dummy-connector-fake/pom.xml +++ b/icf-connectors/dummy-connector-fake/pom.xml @@ -20,12 +20,12 @@ Dummy Connector Fake com.evolveum.icf dummy-connector-fake - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar icf-connectors com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git diff --git a/icf-connectors/dummy-connector/pom.xml b/icf-connectors/dummy-connector/pom.xml index cf91ed9e215..afee1f17670 100644 --- a/icf-connectors/dummy-connector/pom.xml +++ b/icf-connectors/dummy-connector/pom.xml @@ -20,12 +20,12 @@ Dummy Connector com.evolveum.icf dummy-connector - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar icf-connectors com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -44,7 +44,7 @@ com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.testng diff --git a/icf-connectors/dummy-resource/pom.xml b/icf-connectors/dummy-resource/pom.xml index 3d9860e17cd..0b5984feba1 100644 --- a/icf-connectors/dummy-resource/pom.xml +++ b/icf-connectors/dummy-resource/pom.xml @@ -20,12 +20,12 @@ Dummy Resource com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar icf-connectors com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,7 +36,7 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.testng diff --git a/icf-connectors/pom.xml b/icf-connectors/pom.xml index e7b7eff1e10..0968680ccd8 100644 --- a/icf-connectors/pom.xml +++ b/icf-connectors/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml @@ -55,7 +55,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/infra/common/pom.xml b/infra/common/pom.xml index 0afdaea9da7..681b0000307 100644 --- a/infra/common/pom.xml +++ b/infra/common/pom.xml @@ -24,7 +24,7 @@ infra com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,12 +35,12 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT commons-beanutils @@ -100,13 +100,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/infra/pom.xml b/infra/pom.xml index 6696a55ee00..a9f7c2f4f48 100644 --- a/infra/pom.xml +++ b/infra/pom.xml @@ -22,7 +22,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/infra/prism-maven-plugin/pom.xml b/infra/prism-maven-plugin/pom.xml index b071a88758e..059e7a258e6 100644 --- a/infra/prism-maven-plugin/pom.xml +++ b/infra/prism-maven-plugin/pom.xml @@ -20,13 +20,13 @@ 4.0.0 com.evolveum.midpoint.infra prism-maven-plugin - 3.2-SNAPSHOT + 3.3-SNAPSHOT maven-plugin midPoint Infrastructure - prism maven plugin infra com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -52,7 +52,7 @@ com.evolveum.midpoint.infra prism - 3.2-SNAPSHOT + 3.3-SNAPSHOT commons-lang diff --git a/infra/prism/pom.xml b/infra/prism/pom.xml index 38d32466def..12b62ed0ad3 100644 --- a/infra/prism/pom.xml +++ b/infra/prism/pom.xml @@ -20,12 +20,12 @@ 4.0.0 com.evolveum.midpoint.infra prism - 3.2-SNAPSHOT + 3.3-SNAPSHOT midPoint Infrastructure - prism infra com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,7 +36,7 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -109,7 +109,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -139,13 +139,13 @@ com.evolveum.midpoint.infra prism - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar @@ -291,7 +291,7 @@ com.evolveum.midpoint.tools xjc-plugin - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/model/model-common/pom.xml b/model/model-common/pom.xml index 2a2b30511d2..3830de13f30 100644 --- a/model/model-common/pom.xml +++ b/model/model-common/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT Evolveum @@ -50,22 +50,22 @@ com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT commons-collections @@ -92,13 +92,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java index 31924347e05..1a53d7388cb 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java @@ -44,6 +44,7 @@ import java.io.IOException; import java.util.Collection; +import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; @@ -345,16 +346,16 @@ public void testFormatDateTime() throws Exception { // GIVEN BasicExpressionFunctions f = createBasicFunctions(); - XMLGregorianCalendar xmlCal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0); + XMLGregorianCalendar xmlCal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 22, 30, 0, 0, DatatypeConstants.FIELD_UNDEFINED); // don't use GMT (offset 0) because serialized value is then in local time // WHEN - String resultValue = f.formatDateTime("yyyy MM dd HH:mm:ss.SSS zzzz", xmlCal); + String resultValue = f.formatDateTime("yyyy MM dd HH:mm:ss.SSS", xmlCal); // don't include timezone in the format string, it is hard to check then // THEN assertNotNull("Result value is null", resultValue); System.out.println("Resulting value: "+resultValue); - assertEquals("Wrong result value", "1975 05 30 22:30:00.000 Central European Time", resultValue); + assertEquals("Wrong result value", "1975 05 30 22:30:00.000", resultValue); } @Test diff --git a/model/model-impl/pom.xml b/model/model-impl/pom.xml index cf9cf551927..04685858fcf 100644 --- a/model/model-impl/pom.xml +++ b/model/model-impl/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT Evolveum @@ -49,47 +49,47 @@ com.evolveum.midpoint.model report-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model workflow-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.apache.cxf @@ -141,67 +141,67 @@ com.evolveum.icf dummy-connector - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.icf dummy-connector-fake - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -234,7 +234,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -250,7 +250,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java index 75410525729..ac386437924 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java @@ -106,7 +106,7 @@ public class ModelCrudService { @Autowired(required = true) private ChangeNotificationDispatcher dispatcher; - + public PrismObject getObject(Class clazz, String oid, Collection> options, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { @@ -516,31 +516,31 @@ public OperationResult testResource(String resourceOid, Task task) throws Object //TASK AREA - public boolean suspendTasks(Collection taskOids, long waitForStop, OperationResult parentResult) { + public boolean suspendTasks(Collection taskOids, long waitForStop, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { return modelController.suspendTasks(taskOids, waitForStop, parentResult); } - public void suspendAndDeleteTasks(Collection taskOids, long waitForStop, boolean alsoSubtasks, OperationResult parentResult) { + public void suspendAndDeleteTasks(Collection taskOids, long waitForStop, boolean alsoSubtasks, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { modelController.suspendAndDeleteTasks(taskOids, waitForStop, alsoSubtasks, parentResult); } - public void resumeTasks(Collection taskOids, OperationResult parentResult) { + public void resumeTasks(Collection taskOids, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { modelController.resumeTasks(taskOids, parentResult); } - public void scheduleTasksNow(Collection taskOids, OperationResult parentResult) { + public void scheduleTasksNow(Collection taskOids, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { modelController.scheduleTasksNow(taskOids, parentResult); } - public PrismObject getTaskByIdentifier(String identifier, Collection> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException { + public PrismObject getTaskByIdentifier(String identifier, Collection> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException { return modelController.getTaskByIdentifier(identifier, options, parentResult); } - public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult) { + public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult) throws SchemaException, SecurityViolationException { return modelController.deactivateServiceThreads(timeToWait, parentResult); } - public void reactivateServiceThreads(OperationResult parentResult) { + public void reactivateServiceThreads(OperationResult parentResult) throws SchemaException, SecurityViolationException { modelController.reactivateServiceThreads(parentResult); } @@ -548,19 +548,19 @@ public boolean getServiceThreadsActivationState() { return modelController.getServiceThreadsActivationState(); } - public void stopSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { + public void stopSchedulers(Collection nodeIdentifiers, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { modelController.stopSchedulers(nodeIdentifiers, parentResult); } - public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, OperationResult parentResult) { + public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { return modelController.stopSchedulersAndTasks(nodeIdentifiers, waitTime, parentResult); } - public void startSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { + public void startSchedulers(Collection nodeIdentifiers, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { modelController.startSchedulers(nodeIdentifiers, parentResult); } - public void synchronizeTasks(OperationResult parentResult) { + public void synchronizeTasks(OperationResult parentResult) throws SchemaException, SecurityViolationException { modelController.synchronizeTasks(parentResult); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java index f3a9765c88e..1cd221d9c26 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java @@ -535,16 +535,21 @@ public Response suspendTasks(@PathParam("oid") String taskOid, @Context MessageC Response response; Collection taskOids = MiscUtil.createCollection(taskOid); - boolean suspended = model.suspendTasks(taskOids, WAIT_FOR_TASK_STOP, parentResult); - - parentResult.computeStatus(); - - if (parentResult.isSuccess()){ - response = Response.noContent().build(); - } else { - response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); - } - + try { + model.suspendTasks(taskOids, WAIT_FOR_TASK_STOP, parentResult); + parentResult.computeStatus(); + if (parentResult.isSuccess()){ + response = Response.noContent().build(); + } else { + response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); + } + } catch (ObjectNotFoundException e) { + response = Response.status(Status.NOT_FOUND).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SchemaException e) { + response = Response.status(Status.CONFLICT).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SecurityViolationException e) { + response = Response.status(Status.FORBIDDEN).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } auditLogout(task); return response; } @@ -558,14 +563,22 @@ public Response suspendAndDeleteTasks(@PathParam("oid") String taskOid, @Context Response response; Collection taskOids = MiscUtil.createCollection(taskOid); - model.suspendAndDeleteTasks(taskOids, WAIT_FOR_TASK_STOP, true, parentResult); - - parentResult.computeStatus(); - if (parentResult.isSuccess()){ - response = Response.accepted().build(); - } else { - response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); - } + try { + model.suspendAndDeleteTasks(taskOids, WAIT_FOR_TASK_STOP, true, parentResult); + + parentResult.computeStatus(); + if (parentResult.isSuccess()) { + response = Response.accepted().build(); + } else { + response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); + } + } catch (ObjectNotFoundException e) { + response = Response.status(Status.NOT_FOUND).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SchemaException e) { + response = Response.status(Status.CONFLICT).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SecurityViolationException e) { + response = Response.status(Status.FORBIDDEN).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } auditLogout(task); return response; @@ -581,16 +594,23 @@ public Response resumeTasks(@PathParam("oid") String taskOid, @Context MessageCo Response response; Collection taskOids = MiscUtil.createCollection(taskOid); - model.resumeTasks(taskOids, parentResult); - - parentResult.computeStatus(); - - if (parentResult.isSuccess()){ - response = Response.accepted().build(); - } else { - response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); - } - + try { + model.resumeTasks(taskOids, parentResult); + + parentResult.computeStatus(); + + if (parentResult.isSuccess()) { + response = Response.accepted().build(); + } else { + response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); + } + } catch (ObjectNotFoundException e) { + response = Response.status(Status.NOT_FOUND).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SchemaException e) { + response = Response.status(Status.CONFLICT).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SecurityViolationException e) { + response = Response.status(Status.FORBIDDEN).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } auditLogout(task); return response; } @@ -598,70 +618,74 @@ public Response resumeTasks(@PathParam("oid") String taskOid, @Context MessageCo @POST @Path("tasks/{oid}/run") - public Response scheduleTasksNow(@PathParam("oid") String taskOid) { - OperationResult parentResult = new OperationResult("suspend task."); + public Response scheduleTasksNow(@PathParam("oid") String taskOid, @Context MessageContext mc) { + Task task = taskManager.createTaskInstance("scheduleTasksNow"); + initRequest(task, mc); + OperationResult parentResult = task.getResult(); Collection taskOids = MiscUtil.createCollection(taskOid); - - model.scheduleTasksNow(taskOids, parentResult); - - parentResult.computeStatus(); - - if (parentResult.isSuccess()){ - return Response.accepted().build(); - } - - return Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); - - - } - -// @GET -// @Path("tasks/{oid}") - public Response getTaskByIdentifier(@PathParam("oid") String identifier) throws SchemaException, ObjectNotFoundException { - OperationResult parentResult = new OperationResult("suspend task."); - PrismObject task = model.getTaskByIdentifier(identifier, null, parentResult); - - return Response.ok(task).build(); - } - - - public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult) { - return model.deactivateServiceThreads(timeToWait, parentResult); - } - - public void reactivateServiceThreads(OperationResult parentResult) { - model.reactivateServiceThreads(parentResult); - } - - public boolean getServiceThreadsActivationState() { - return model.getServiceThreadsActivationState(); - } - public void stopSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { - model.stopSchedulers(nodeIdentifiers, parentResult); - } + Response response; + try { + model.scheduleTasksNow(taskOids, parentResult); - public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, OperationResult parentResult) { - return model.stopSchedulersAndTasks(nodeIdentifiers, waitTime, parentResult); - } + parentResult.computeStatus(); - public void startSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { - model.startSchedulers(nodeIdentifiers, parentResult); - } + if (parentResult.isSuccess()) { + response = Response.accepted().build(); + } else { + response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build(); + } + } catch (ObjectNotFoundException e) { + response = Response.status(Status.NOT_FOUND).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SchemaException e) { + response = Response.status(Status.CONFLICT).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (SecurityViolationException e) { + response = Response.status(Status.FORBIDDEN).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } - public void synchronizeTasks(OperationResult parentResult) { - model.synchronizeTasks(parentResult); + auditLogout(task); + return response; } + +// @GET +// @Path("tasks/{oid}") +// public Response getTaskByIdentifier(@PathParam("oid") String identifier) throws SchemaException, ObjectNotFoundException { +// OperationResult parentResult = new OperationResult("getTaskByIdentifier"); +// PrismObject task = model.getTaskByIdentifier(identifier, null, parentResult); +// +// return Response.ok(task).build(); +// } +// +// +// public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult) { +// return model.deactivateServiceThreads(timeToWait, parentResult); +// } +// +// public void reactivateServiceThreads(OperationResult parentResult) { +// model.reactivateServiceThreads(parentResult); +// } +// +// public boolean getServiceThreadsActivationState() { +// return model.getServiceThreadsActivationState(); +// } +// +// public void stopSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { +// model.stopSchedulers(nodeIdentifiers, parentResult); +// } +// +// public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, OperationResult parentResult) { +// return model.stopSchedulersAndTasks(nodeIdentifiers, waitTime, parentResult); +// } +// +// public void startSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { +// model.startSchedulers(nodeIdentifiers, parentResult); +// } +// +// public void synchronizeTasks(OperationResult parentResult) { +// model.synchronizeTasks(parentResult); +// } - public List getAllTaskCategories() { - return model.getAllTaskCategories(); - } - public String getHandlerUriForCategory(String category) { - return model.getHandlerUriForCategory(category); - } - - private ModelExecuteOptions getOptions(UriInfo uriInfo){ List options = uriInfo.getQueryParameters().get(OPTIONS); return ModelExecuteOptions.fromRestOptions(options); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java index bed6c988a5f..6627989b466 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java @@ -43,12 +43,14 @@ import com.evolveum.midpoint.prism.ConsistencyCheckScope; import com.evolveum.midpoint.prism.parser.XNodeSerializer; import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.wf.api.WorkflowManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDecisionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType; import com.evolveum.midpoint.xml.ns._public.model.model_context_3.LensContextType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionType; @@ -400,7 +402,7 @@ public void visit(Visitable visitable) { // TODO what about security here?! // TODO use some minimalistic get options (e.g. retrieve name only) refObject = objectResolver.resolve(refVal, "", rootOptionsNoResolve, task, result); - if (refObject == null) { // will be used with AllowNotFound above + if (refObject == null) { // will be used with AllowNotFound above name = "(object not found)"; } } catch (ObjectNotFoundException e) { @@ -534,7 +536,19 @@ public void run() { auditService.audit(auditRecord, task); for(ObjectDelta delta: deltas) { OperationResult result1 = result.createSubresult(EXECUTE_CHANGE); - try { + + // MID-2486 + if (delta.getObjectTypeClass() == ShadowType.class || delta.getObjectTypeClass() == ResourceType.class) { + try { + provisioning.applyDefinition(delta, result1); + } catch (SchemaException|ObjectNotFoundException|CommunicationException|ConfigurationException|RuntimeException e) { + // we can tolerate this - if there's a real problem with definition, repo call below will fail + LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't apply definition on shadow/resource raw-mode delta {} -- continuing the operation.", e, delta); + result1.muteLastSubresultError(); + } + } + + try { if (delta.isAdd()) { RepoAddOptions repoOptions = new RepoAddOptions(); if (ModelExecuteOptions.isNoCrypt(options)) { @@ -1653,7 +1667,7 @@ public PrismObject findShadowOwner(String accountOid, Task task, Opera PrismObject user = null; - LOGGER.trace("Listing account shadow owner for account with oid {}.", new Object[] { accountOid }); + LOGGER.trace("Listing account shadow owner for account with oid {}.", new Object[]{accountOid}); OperationResult result = parentResult.createSubresult(LIST_ACCOUNT_SHADOW_OWNER); result.addParams(new String[] { "accountOid" }, accountOid); @@ -2247,37 +2261,46 @@ private ObjectQuery preProcessQuerySecurity(Class obje //region Task-related operations @Override - public boolean suspendTasks(Collection taskOids, long waitForStop, OperationResult parentResult) { + public boolean suspendTasks(Collection taskOids, long waitForStop, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeTaskCollectionOperation(ModelAuthorizationAction.SUSPEND_TASK, taskOids, parentResult); return taskManager.suspendTasks(taskOids, waitForStop, parentResult); } - @Override - public void suspendAndDeleteTasks(Collection taskOids, long waitForStop, boolean alsoSubtasks, OperationResult parentResult) { + @Override + public void suspendAndDeleteTasks(Collection taskOids, long waitForStop, boolean alsoSubtasks, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeTaskCollectionOperation(ModelAuthorizationAction.DELETE, taskOids, parentResult); taskManager.suspendAndDeleteTasks(taskOids, waitForStop, alsoSubtasks, parentResult); } @Override - public void resumeTasks(Collection taskOids, OperationResult parentResult) { + public void resumeTasks(Collection taskOids, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeTaskCollectionOperation(ModelAuthorizationAction.RESUME_TASK, taskOids, parentResult); taskManager.resumeTasks(taskOids, parentResult); } @Override - public void scheduleTasksNow(Collection taskOids, OperationResult parentResult) { + public void scheduleTasksNow(Collection taskOids, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeTaskCollectionOperation(ModelAuthorizationAction.RUN_TASK_IMMEDIATELY, taskOids, parentResult); taskManager.scheduleTasksNow(taskOids, parentResult); } @Override - public PrismObject getTaskByIdentifier(String identifier, Collection> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException { - return taskManager.getTaskTypeByIdentifier(identifier, options, parentResult); + public PrismObject getTaskByIdentifier(String identifier, Collection> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ConfigurationException, SecurityViolationException { + PrismObject task = taskManager.getTaskTypeByIdentifier(identifier, options, parentResult); + GetOperationOptions rootOptions = SelectorOptions.findRootOptions(options); + applySchemasAndSecurity(task, rootOptions, null, null, parentResult); + return task; } @Override - public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult) { + public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult) throws SchemaException, SecurityViolationException { + securityEnforcer.authorize(ModelAuthorizationAction.STOP_SERVICE_THREADS.getUrl(), null, null, null, null, null, parentResult); return taskManager.deactivateServiceThreads(timeToWait, parentResult); } @Override - public void reactivateServiceThreads(OperationResult parentResult) { + public void reactivateServiceThreads(OperationResult parentResult) throws SchemaException, SecurityViolationException { + securityEnforcer.authorize(ModelAuthorizationAction.START_SERVICE_THREADS.getUrl(), null, null, null, null, null, parentResult); taskManager.reactivateServiceThreads(parentResult); } @@ -2287,23 +2310,27 @@ public boolean getServiceThreadsActivationState() { } @Override - public void stopSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { + public void stopSchedulers(Collection nodeIdentifiers, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeNodeCollectionOperation(ModelAuthorizationAction.STOP_TASK_SCHEDULER, nodeIdentifiers, parentResult); taskManager.stopSchedulers(nodeIdentifiers, parentResult); } @Override - public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, OperationResult parentResult) { + public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeNodeCollectionOperation(ModelAuthorizationAction.STOP_TASK_SCHEDULER, nodeIdentifiers, parentResult); return taskManager.stopSchedulersAndTasks(nodeIdentifiers, waitTime, parentResult); } @Override - public void startSchedulers(Collection nodeIdentifiers, OperationResult parentResult) { + public void startSchedulers(Collection nodeIdentifiers, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException { + authorizeNodeCollectionOperation(ModelAuthorizationAction.START_TASK_SCHEDULER, nodeIdentifiers, parentResult); taskManager.startSchedulers(nodeIdentifiers, parentResult); } @Override - public void synchronizeTasks(OperationResult parentResult) { - taskManager.synchronizeTasks(parentResult); + public void synchronizeTasks(OperationResult parentResult) throws SchemaException, SecurityViolationException { + securityEnforcer.authorize(ModelAuthorizationAction.SYNCHRONIZE_TASKS.getUrl(), null, null, null, null, null, parentResult); + taskManager.synchronizeTasks(parentResult); } @Override @@ -2315,7 +2342,45 @@ public List getAllTaskCategories() { public String getHandlerUriForCategory(String category) { return taskManager.getHandlerUriForCategory(category); } - //endregion + + private void authorizeTaskCollectionOperation(ModelAuthorizationAction action, Collection oids, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException { + if (securityEnforcer.isAuthorized(AuthorizationConstants.AUTZ_ALL_URL, null, null, null, null, null)) { + return; + } + for (String oid : oids) { + PrismObject existingObject = null; + try { + existingObject = cacheRepositoryService.getObject(TaskType.class, oid, null, parentResult); + } catch (ObjectNotFoundException|SchemaException e) { + throw e; + } + securityEnforcer.authorize(action.getUrl(), null, existingObject, null, null, null, parentResult); + } + } + + private void authorizeNodeCollectionOperation(ModelAuthorizationAction action, Collection identifiers, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException { + if (securityEnforcer.isAuthorized(AuthorizationConstants.AUTZ_ALL_URL, null, null, null, null, null)) { + return; + } + for (String identifier : identifiers) { + PrismObject existingObject = null; + try { + ObjectQuery q = ObjectQueryUtil.createNameQuery(NodeType.class, prismContext, identifier); + List> nodes = cacheRepositoryService.searchObjects(NodeType.class, q, null, parentResult); + if (nodes.isEmpty()) { + throw new ObjectNotFoundException("Node with identifier '" + identifier + "' couldn't be found."); + } else if (nodes.size() > 1) { + throw new SystemException("Multiple nodes with identifier '" + identifier + "'"); + } + existingObject = nodes.get(0); + } catch (ObjectNotFoundException|SchemaException e) { + throw e; + } + securityEnforcer.authorize(action.getUrl(), null, existingObject, null, null, null, parentResult); + } + } + + //endregion //region Workflow-related operations @Override diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java index 37b6e667e56..42ce706bfb1 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java @@ -742,7 +742,7 @@ public void recompute() throws SchemaException { } public void clearIntermediateResults() { - constructionDeltaSetTriple = null; + //constructionDeltaSetTriple = null; outboundConstruction = null; squeezedAttributes = null; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java index 7b1deca660a..b5999d4e50e 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java @@ -201,6 +201,7 @@ private void processProjections(LensContext context, // people during debugging and unecessarily clutter the debug output. projContext.setOutboundConstruction(null); projContext.setSqueezedAttributes(null); + projContext.setSqueezedAssociations(null); LOGGER.trace("Projection values iteration {}, token '{}' for {}", new Object[]{iteration, iterationToken, projContext.getHumanReadableName()}); diff --git a/model/model-intest/pom.xml b/model/model-intest/pom.xml index 9a65dd93d4a..a0bfa29dea4 100644 --- a/model/model-intest/pom.xml +++ b/model/model-intest/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT Evolveum @@ -51,127 +51,127 @@ com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.icf dummy-connector - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.icf dummy-connector-fake - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model notifications-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -203,7 +203,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -219,7 +219,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java index 193ff97f3b7..48b8ee2bcae 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java @@ -26,10 +26,24 @@ import java.util.Collection; import java.util.List; +import com.evolveum.icf.dummy.connector.DummyConnector; import com.evolveum.midpoint.model.api.PolicyViolationException; +import com.evolveum.midpoint.prism.delta.ContainerDelta; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import com.evolveum.prism.xml.ns._public.types_3.RawType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -304,7 +318,23 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { repoAddObject(ShadowType.class, createShadow(resourceDummyPink, ACCOUNT_JACK_DUMMY_USERNAME), result); Collection> deltas = new ArrayList>(); - ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_PINK_OID, null, true); + + // assignment with weapon := 'pistol' (test for + Collection> modifications = new ArrayList<>(); + AssignmentType assignmentType = createAssignment(RESOURCE_DUMMY_PINK_OID, ShadowKindType.ACCOUNT, null); + ConstructionType constructionType = assignmentType.getConstruction(); + ResourceAttributeDefinitionType attributeDefinitionType = new ResourceAttributeDefinitionType(); + attributeDefinitionType.setRef(new ItemPathType(new ItemPath(dummyResourceCtlPink.getAttributeWeaponQName()))); + MappingType mappingType = new MappingType(); + mappingType.setStrength(MappingStrengthType.STRONG); + ExpressionType expressionType = new ExpressionType(); + expressionType.getExpressionEvaluator().add(new ObjectFactory().createValue(RawType.create("pistol", prismContext))); + mappingType.setExpression(expressionType); + attributeDefinitionType.setOutbound(mappingType); + constructionType.getAttribute().add(attributeDefinitionType); + modifications.add(createAssignmentModification(assignmentType, true)); + ObjectDelta accountAssignmentUserDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); + deltas.add(accountAssignmentUserDelta); // WHEN @@ -332,7 +362,10 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { // Check account PrismObject accountPinkModel = modelService.getObject(ShadowType.class, accountPinkOid, null, task, result); assertAccountShadowModel(accountPinkModel, accountPinkOid, "jack1", resourceDummyPinkType); - + display("accountPinkModel", accountPinkModel); + PrismAsserts.assertPropertyValue(accountPinkModel, dummyResourceCtlPink.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME), + "pistol"); + // Check account in dummy resource assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true); // The original conflicting account should still remain diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiConnector.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiConnector.java index 57360d8ffa7..ec66639451e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiConnector.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiConnector.java @@ -114,7 +114,7 @@ public void test010ListConnectors() throws Exception { result.computeStatus(); TestUtil.assertSuccess("getObject result", result); - assertEquals("Unexpected number of connectors", 5, connectors.size()); + assertEquals("Unexpected number of connectors", 6, connectors.size()); for(PrismObject connector: connectors) { display("Connector", connector); ConnectorType connectorType = connector.asObjectable(); diff --git a/model/model-intest/testng.xml b/model/model-intest/testng.xml index 5a55fa45a5b..e20a980ae8a 100644 --- a/model/model-intest/testng.xml +++ b/model/model-intest/testng.xml @@ -16,6 +16,9 @@ --> + + + diff --git a/model/model-test/pom.xml b/model/model-test/pom.xml index 4ff383ace43..548cf0a656c 100644 --- a/model/model-test/pom.xml +++ b/model/model-test/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT Evolveum @@ -50,62 +50,62 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model notifications-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.icf dummy-connector - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.icf dummy-connector-fake - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.testng @@ -123,25 +123,25 @@ com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -168,7 +168,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -179,7 +179,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 24f150c8561..5d389c91e23 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -548,7 +548,7 @@ protected PropertyDelta createAttributeReplaceDelta(PrismObject PropertyDelta createAttributeAddDelta(PrismObject resource, String attributeLocalName, T... newRealValue) throws SchemaException { @@ -574,7 +574,7 @@ protected PropertyDelta createAttributeDeleteDelta(PrismObject resource, QName attributeName) throws SchemaException { @@ -710,7 +710,7 @@ protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundE protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignRole(userOid, roleOid, (ActivationType)null, task, result); + assignRole(userOid, roleOid, (ActivationType) null, task, result); } protected void assignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, @@ -826,7 +826,7 @@ protected void unassignAll(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = ObjectDelta.createModificationReplaceContainer(UserType.class, userOid, + ObjectDelta userDelta = ObjectDelta.createModificationReplaceContainer(UserType.class, userOid, UserType.F_ASSIGNMENT, prismContext, new PrismContainerValue[0]); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); modelService.executeChanges(deltas, null, task, result); @@ -874,19 +874,22 @@ protected PropertyDelta createUserPropertyReplaceModification(QName prope protected ContainerDelta createAssignmentModification(String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { + AssignmentType assignmentType = createAssignment(resourceOid, kind, intent); + return createAssignmentModification(assignmentType, add); + } + + protected ContainerDelta createAssignmentModification(AssignmentType assignmentType, boolean add) throws SchemaException { ContainerDelta assignmentDelta = ContainerDelta.createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - AssignmentType assignmentType = createAssignment(resourceOid, kind, intent); - if (add) { assignmentDelta.addValueToAdd(assignmentType.asPrismContainerValue()); } else { assignmentDelta.addValueToDelete(assignmentType.asPrismContainerValue()); } - + PrismContainerDefinition assignmentDef = getUserDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); assignmentDelta.applyDefinition(assignmentDef); - + return assignmentDelta; } diff --git a/model/notifications-api/pom.xml b/model/notifications-api/pom.xml index f48d59eeb79..9bbc5b7faad 100644 --- a/model/notifications-api/pom.xml +++ b/model/notifications-api/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,42 +35,42 @@ com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model workflow-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/notifications-impl/pom.xml b/model/notifications-impl/pom.xml index 671749b1feb..764a4bac429 100644 --- a/model/notifications-impl/pom.xml +++ b/model/notifications-impl/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,57 +35,57 @@ com.evolveum.midpoint.model notifications-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model workflow-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model certification-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.apache.commons @@ -100,43 +100,43 @@ com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -147,7 +147,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/pom.xml b/model/pom.xml index fdcb9f89a93..c886f3e13be 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/model/report-api/pom.xml b/model/report-api/pom.xml index 8f4ffba1798..0bb6fa1636c 100644 --- a/model/report-api/pom.xml +++ b/model/report-api/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT Evolveum @@ -50,12 +50,12 @@ com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/report-ds-impl/pom.xml b/model/report-ds-impl/pom.xml index 656e3024bef..ea365b33fca 100644 --- a/model/report-ds-impl/pom.xml +++ b/model/report-ds-impl/pom.xml @@ -3,11 +3,11 @@ com.evolveum.midpoint model - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model report-ds-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT midPoint Report DataSource 1.7 @@ -105,7 +105,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -117,12 +117,12 @@ com.evolveum.midpoint.infra prism - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model report-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointDataSource.java b/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointDataSource.java index d459c8bd4eb..9cf70ca92e5 100644 --- a/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointDataSource.java +++ b/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointDataSource.java @@ -22,6 +22,7 @@ import com.evolveum.midpoint.prism.PrismReference; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.Referencable; +import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; @@ -73,7 +74,11 @@ public Object getFieldValue(JRField jrField) throws JRException { if (i instanceof PrismProperty){ if (i.isSingleValue()){ - return ((PrismProperty) i).getRealValue(); + return normalize(((PrismProperty) i).getRealValue(), jrField.getValueClass()); + } + List normalized = new ArrayList<>(); + for (Object real : ((PrismProperty) i).getRealValues()){ + normalized.add(normalize(real, jrField.getValueClass())); } return ((PrismProperty) i).getRealValues(); } else if (i instanceof PrismReference){ @@ -103,5 +108,13 @@ public Object getFieldValue(JRField jrField) throws JRException { // return // throw new UnsupportedOperationException("dataSource.getFiledValue() not supported"); } + + private Object normalize(Object realValue, Class fieldClass){ + if (realValue instanceof PolyString && fieldClass.equals(String.class)){ + return ((PolyString)realValue).getOrig(); + } + + return realValue; + } } diff --git a/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointQueryExecutor.java b/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointQueryExecutor.java index 062fe11c168..f6609d3cece 100644 --- a/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointQueryExecutor.java +++ b/model/report-ds-impl/src/main/java/com/evolveum/midpoint/report/ds/impl/MidPointQueryExecutor.java @@ -35,6 +35,7 @@ import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; public abstract class MidPointQueryExecutor extends JRAbstractQueryExecuter{ @@ -155,8 +156,13 @@ public JRDataSource createDatasource() throws JRException { results = searchObjects(query, SelectorOptions.createCollection(GetOperationOptions.createRaw())); } else { if (script.contains("AuditEventRecord")){ - Collection audtiEventRecords = searchAuditRecords(script, getPromptingParameters()); - return new JRBeanCollectionDataSource(audtiEventRecords); + Collection audtiEventRecords = searchAuditRecords(script, getPromptingParameters()); + Collection auditEventRecordsType = new ArrayList<>(); + for (AuditEventRecord aer : audtiEventRecords){ + AuditEventRecordType aerType = aer.createAuditEventRecordType(); + auditEventRecordsType.add(aerType); + } + return new JRBeanCollectionDataSource(auditEventRecordsType); } else { results = evaluateScript(script, getParameters()); } diff --git a/model/report-impl/pom.xml b/model/report-impl/pom.xml index d3f5cff0de6..fb0cd7a438e 100644 --- a/model/report-impl/pom.xml +++ b/model/report-impl/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT Evolveum @@ -51,27 +51,27 @@ com.evolveum.midpoint.model report-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra prism - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-common - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -106,61 +106,61 @@ com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -171,7 +171,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -187,7 +187,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/DataSourceReport.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/DataSourceReport.java index 359e2fee8d2..dd78c2c3b2a 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/DataSourceReport.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/DataSourceReport.java @@ -65,25 +65,25 @@ public DataSourceReport(Map params, PrismContext prismContext, ModelService mode initialize(); } - private void initialize() - { clazz = ReportUtils.getObjectTypeClass(params); - objectQuery = ReportUtils.getObjectQuery(params, clazz, prismContext); - result = ReportUtils.getOperationResult(params); - try - { - reportType = ReportUtils.getReport(params, modelService, prismContext); - } catch (Exception ex) - { - LOGGER.error("Report doesn't correct in datasource. {}", ex.getMessage()); - } - subResult = result.createSubresult("Initialize datasource"); - paging = ObjectPaging.createPaging(0, 50); - objectQuery.setPaging(paging); - rowCount = paging.getMaxSize(); - rowCounter = rowCount - 1; - fieldsPair = getFieldsPair(); - subResult.computeStatus(); - } + private void initialize(){} +// { clazz = ReportUtils.getObjectTypeClass(params); +// objectQuery = ReportUtils.getObjectQuery(params, clazz, prismContext); +// result = ReportUtils.getOperationResult(params); +// try +// { +// reportType = ReportUtils.getReport(params, modelService, prismContext); +// } catch (Exception ex) +// { +// LOGGER.error("Report doesn't correct in datasource. {}", ex.getMessage()); +// } +// subResult = result.createSubresult("Initialize datasource"); +// paging = ObjectPaging.createPaging(0, 50); +// objectQuery.setPaging(paging); +// rowCount = paging.getMaxSize(); +// rowCounter = rowCount - 1; +// fieldsPair = getFieldsPair(); +// subResult.computeStatus(); +// } private LinkedHashMap getFieldsPair() { diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java index c03d274d854..0212937a800 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java @@ -235,24 +235,28 @@ public HookOperationMode invoke(ModelContext context, Task task, OperationResult try { ReportType reportType = (ReportType) object.asObjectable(); JasperDesign jasperDesign = null; - if (reportType.getTemplate() == null) - { - PrismSchema reportSchema = null; - PrismContainer parameterConfiguration = null; - try - { - reportSchema = ReportUtils.getParametersSchema(reportType, prismContext); - parameterConfiguration = ReportUtils.getParametersContainer(reportType, reportSchema); - - } catch (Exception ex){ - String message = "Cannot create parameter configuration: " + ex.getMessage(); - LOGGER.error(message); - result.recordFatalError(message, ex); - } - - jasperDesign = ReportUtils.createJasperDesign(reportType, parameterConfiguration, reportSchema) ; - LOGGER.trace("create jasper design : {}", jasperDesign); + if (reportType.getTemplate() == null){ + String message = "Report template must not be null"; + LOGGER.error(message); + result.recordFatalError(message, new SystemException()); } +// { +// PrismSchema reportSchema = null; +// PrismContainer parameterConfiguration = null; +// try +// { +// reportSchema = ReportUtils.getParametersSchema(reportType, prismContext); +// parameterConfiguration = ReportUtils.getParametersContainer(reportType, reportSchema); +// +// } catch (Exception ex){ +// String message = "Cannot create parameter configuration: " + ex.getMessage(); +// LOGGER.error(message); +// result.recordFatalError(message, ex); +// } +// +// jasperDesign = ReportUtils.createJasperDesign(reportType, parameterConfiguration, reportSchema) ; +// LOGGER.trace("create jasper design : {}", jasperDesign); +// } else { byte[] reportTemplateBase64 = reportType.getTemplate(); diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java index 5a8c32137b3..37f2fbdfbe0 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java @@ -15,530 +15,59 @@ */ package com.evolveum.midpoint.report.impl; -import java.awt.Color; -import java.io.ByteArrayInputStream; import java.io.File; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.sql.Timestamp; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import java.util.ResourceBundle; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.parser.DomParser; -import com.evolveum.midpoint.prism.parser.QueryConvertor; -import com.evolveum.midpoint.prism.parser.XNodeProcessor; -import com.evolveum.midpoint.prism.parser.XNodeSerializer; - -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JRExpression; -import net.sf.jasperreports.engine.JRParameter; -import net.sf.jasperreports.engine.JRStyle; -import net.sf.jasperreports.engine.JRTemplate; -import net.sf.jasperreports.engine.JasperCompileManager; -import net.sf.jasperreports.engine.JasperReport; -import net.sf.jasperreports.engine.base.JRBasePen; -import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; -import net.sf.jasperreports.engine.design.JRDesignBand; -import net.sf.jasperreports.engine.design.JRDesignExpression; -import net.sf.jasperreports.engine.design.JRDesignField; -import net.sf.jasperreports.engine.design.JRDesignFrame; -import net.sf.jasperreports.engine.design.JRDesignImage; -import net.sf.jasperreports.engine.design.JRDesignLine; -import net.sf.jasperreports.engine.design.JRDesignParameter; -import net.sf.jasperreports.engine.design.JRDesignReportTemplate; -import net.sf.jasperreports.engine.design.JRDesignSection; -import net.sf.jasperreports.engine.design.JRDesignStaticText; -import net.sf.jasperreports.engine.design.JRDesignStyle; -import net.sf.jasperreports.engine.design.JRDesignTextField; -import net.sf.jasperreports.engine.design.JasperDesign; -import net.sf.jasperreports.engine.type.EvaluationTimeEnum; -import net.sf.jasperreports.engine.type.HorizontalAlignEnum; -import net.sf.jasperreports.engine.type.ModeEnum; -import net.sf.jasperreports.engine.type.OrientationEnum; -import net.sf.jasperreports.engine.type.PositionTypeEnum; -import net.sf.jasperreports.engine.type.SplitTypeEnum; -import net.sf.jasperreports.engine.type.VerticalAlignEnum; -import net.sf.jasperreports.engine.type.WhenNoDataTypeEnum; -import net.sf.jasperreports.engine.util.JRReportUtils; -import net.sf.jasperreports.engine.xml.JRXmlLoader; -import net.sf.jasperreports.engine.xml.JRXmlTemplateLoader; -import net.sf.jasperreports.olap.JRMondrianQueryExecuterFactory; - -import org.apache.commons.codec.binary.Base64; -import org.w3c.dom.Element; -import org.w3c.dom.Node; +import org.apache.commons.lang.StringUtils; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.common.expression.ExpressionSyntaxException; -import com.evolveum.midpoint.model.common.expression.ExpressionUtil; -import com.evolveum.midpoint.model.common.expression.ExpressionVariables; -import com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary; -import com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.Item; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.PrismReference; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.PrismValue; -import com.evolveum.midpoint.prism.delta.ChangeType; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.path.ItemPathSegment; -import com.evolveum.midpoint.prism.path.NameItemPathSegment; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.prism.schema.SchemaRegistry; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.prism.xml.XsdTypeMapper; -import com.evolveum.midpoint.prism.xnode.MapXNode; -import com.evolveum.midpoint.prism.xnode.PrimitiveXNode; -import com.evolveum.midpoint.prism.xnode.RootXNode; -import com.evolveum.midpoint.prism.xnode.XNode; -import com.evolveum.midpoint.schema.DeltaConvertor; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ObjectDeltaOperation; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.constants.ObjectTypes; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ObjectResolver; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportFieldConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; -import com.evolveum.prism.xml.ns._public.query_3.QueryType; -import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; -import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; +import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.xml.XMLConstants; -import org.springframework.beans.factory.annotation.Autowired; +import com.evolveum.prism.xml.ns._public.types_3.RawType; + +/** + * Utility methods for report. Mostly pretty print functions. Do not use any + * "prism" object and anything related to them. Methods has to work with both, + * common schema types and extended schema types (prism) + * + * @author Katarina Valalikova + * @author Martin Lizner + * + */ public class ReportUtils { private static String MIDPOINT_HOME = System.getProperty("midpoint.home"); private static String EXPORT_DIR = MIDPOINT_HOME + "export/"; - // parameters define objectQuery - private static String PARAMETER_OBJECT_TYPE = "type"; - private static String PARAMETER_QUERY_FILTER = "filter"; - - // parameters define datasource - private static String PARAMETER_REPORT_OID = "reportOid"; - private static String PARAMETER_OPERATION_RESULT = "operationResult"; - - // parameter for design - private static String PARAMETER_LOGO = "logoPath"; - private static String PARAMETER_TEMPLATE_STYLES = "baseTemplateStyles"; - private static String TEMPLATE_STYLE_SCHEMA = ""; - + private static final Trace LOGGER = TraceManager .getTrace(ReportUtils.class); - @Autowired(required = true) - private static ModelService modelService; - - //new -// public static JasperDesign loadJasperDesign(byte[] template) throws SchemaException{ -// try { -// byte[] reportTemplate = Base64.decodeBase64(template); -// -// InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate); -// JasperDesign jasperDesign = JRXmlLoader.load(inputStreamJRXML); -// LOGGER.trace("load jasper design : {}", jasperDesign); -// return jasperDesign; -// } catch (JRException ex){ -// throw new SchemaException(ex.getMessage(), ex.getCause()); -// } -// } -// -//public static JasperReport loadJasperReport(ReportType reportType) throws SchemaException{ -// -// if (reportType.getTemplate() == null) { -// throw new IllegalStateException("Could not create report. No jasper template defined."); -// } -// try { -//// byte[] reportTemplate = Base64.decodeBase64(reportType.getTemplate()); -//// -//// InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate); -// JasperDesign jasperDesign = loadJasperDesign(reportType.getTemplate());//JRXmlLoader.load(inputStreamJRXML); -//// LOGGER.trace("load jasper design : {}", jasperDesign); -// -// if (reportType.getTemplateStyle() != null){ -// JRDesignReportTemplate templateStyle = new JRDesignReportTemplate(new JRDesignExpression("$P{" + PARAMETER_TEMPLATE_STYLES + "}")); -// jasperDesign.addTemplate(templateStyle); -// JRDesignParameter parameter = new JRDesignParameter(); -// parameter.setName(PARAMETER_TEMPLATE_STYLES); -// parameter.setValueClass(JRTemplate.class); -// parameter.setForPrompting(false); -// jasperDesign.addParameter(parameter); -// } -// JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); -// return jasperReport; -// } catch (JRException ex){ -// LOGGER.error("Couldn't create jasper report design {}", ex.getMessage()); -// throw new SchemaException(ex.getMessage(), ex.getCause()); -// } -// -// -//} - public static List> getReportData(PrismContext prismContext, Task task, ReportFunctions reportFunctions, String script, ExpressionVariables variables, ObjectResolver objectResolver) throws ExpressionSyntaxException, ExpressionEvaluationException, ObjectNotFoundException { - List> results = new ArrayList<>(); - FunctionLibrary functionLib = ExpressionUtil.createBasicFunctionLibrary(prismContext, prismContext.getDefaultProtector()); - FunctionLibrary midPointLib = new FunctionLibrary(); - midPointLib.setVariableName("report"); - midPointLib.setNamespace("http://midpoint.evolveum.com/xml/ns/public/function/report-3"); -// ReportFunctions reportFunctions = new ReportFunctions(prismContext, model, taskManager, auditService); - midPointLib.setGenericFunctions(reportFunctions); - - Collection functions = new ArrayList<>(); - functions.add(functionLib); - - functions.add(midPointLib); - Jsr223ScriptEvaluator scripts = new Jsr223ScriptEvaluator("Groovy", prismContext, prismContext.getDefaultProtector()); - Object o = scripts.evaluateReportScript(script, variables, objectResolver, functions, "desc", task.getResult()); - if (o != null) { - - if (Collection.class.isAssignableFrom(o.getClass())) { - Collection resultSet = (Collection) o; - if (resultSet != null && !resultSet.isEmpty()) { - if (resultSet.iterator().next() instanceof PrismObject) { - results.addAll((Collection>) o); - } else { -// return new JRBeanCollectionDataSource(resultSet); - } - } - - } else { - results.add((PrismObject) o); - } - } - - return results; - - } - - public static List> getReportData(ModelService model, Class type, ObjectQuery query, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { - List> results = new ArrayList<>(); - - GetOperationOptions options = GetOperationOptions.createRaw(); - options.setResolveNames(true); - results = model.searchObjects(type, query, SelectorOptions.createCollection(options), task, parentResult);; - return results; - } - //end of new - - public static Class getClassType(QName clazz, String namespace) { - Class classType = String.class; - try { - classType = XsdTypeMapper.getXsdToJavaMapping(clazz); - if (classType == XMLGregorianCalendar.class) { - classType = Timestamp.class; - } - if (clazz.getNamespaceURI().equals(namespace)) { - classType = Integer.class; - } - classType = (classType == null) ? String.class : classType; - } catch (Exception ex) { - classType = String.class; - } - return classType; - - } - - public static Element getParametersXsdSchema(ReportType reportType) { - XmlSchemaType xmlSchemaType = reportType.getConfigurationSchema(); - if (xmlSchemaType == null) { - return null; - } - return ObjectTypeUtil.findXsdElement(xmlSchemaType); - } - - public static PrismSchema getParametersSchema(ReportType reportType, PrismContext prismContext) throws SchemaException { - Element parametersSchemaElement = getParametersXsdSchema(reportType); - if (parametersSchemaElement == null) { - return null; - } - - /*LOGGER.trace("Parameters schema element : {}", parametersSchemaElement.getElementsByTagName("simpleType")); - LOGGER.trace("Parameters schema attribut : {}", parametersSchemaElement.getAttributeNode("simpleType")); - NodeList childNodes = parametersSchemaElement.getChildNodes(); - for (int i=0; i< childNodes.getLength(); i++) - { - Node childNode = childNodes.item(i); - if (childNode.getNodeName().equals("xsd:simpleType")) - { - LOGGER.trace("Parameters schema child node : {}", childNode.toString()); - LOGGER.trace("Parameters schema child node name : {}", childNode.getNodeName()); - LOGGER.trace("Parameters schema child node local name : {}", childNode.getLocalName()); - LOGGER.trace("Parameters schema child node class : {}", childNode.getClass()); - LOGGER.trace("Parameters schema child node type : {}", childNode.getNodeType()); - LOGGER.trace("Parameters schema child node value : {}", childNode.getNodeValue()); - LOGGER.trace("Parameters schema child node text content : {}", childNode.getTextContent().split("\t")); - String enumValue = childNode.getTextContent().replaceAll("\t",""); - LOGGER.trace("Parameters schema enum value : {}", enumValue); - - LOGGER.trace("---------------------------------------------------------------------------------------"); - NamedNodeMap attributes = childNode.getAttributes(); - for (int j=0; j getParametersContainer(ReportType reportType, PrismSchema schema) - throws SchemaException, ObjectNotFoundException { - - PrismContainer configuration = reportType.asPrismObject().findContainer(ReportType.F_CONFIGURATION); - if (configuration == null) { - return null; -// throw new SchemaException("No configuration container in " + reportType); - } - - LOGGER.trace("Parameters container : {}", configuration.debugDump()); - if (schema == null) { - return null; - } - - QName configContainerQName = new QName(schema.getNamespace(), ReportType.F_CONFIGURATION.getLocalPart()); - PrismContainerDefinition configurationContainerDefinition = schema.findContainerDefinitionByElementName(configContainerQName); - - if (configurationContainerDefinition == null) { - throw new SchemaException("No configuration container definition in " + reportType); - } - - LOGGER.trace("Parameters configuration definition: {}", configurationContainerDefinition.debugDump()); - /*for(ItemDefinition item : configurationContainerDefinition.getDefinitions()) - { - LOGGER.trace("Item definition: {}", item.dump()); - LOGGER.trace("Display Name : {}", item.getDisplayName()); - LOGGER.trace("Name : {}", item.getName()); - LOGGER.trace("Definition - type class : {}", item.getTypeClass()); - LOGGER.trace("Definition - type name: {}", item.getTypeName()); - - } - - LOGGER.trace("---------------------------------------------------------------------------------------"); - >>>>>>> 48eec5fce88a117d5ce08aa60a36b9d09045780d - - for(PrismPropertyDefinition property : configurationContainerDefinition.getPropertyDefinitions()) - { - LOGGER.trace("PrismProperty definition: {}", property.dump()); - LOGGER.trace("Display Name : {}", property.getDisplayName()); - LOGGER.trace("Name : {}", property.getName()); - LOGGER.trace("Definition - type class : {}", property.getTypeClass()); - LOGGER.trace("Definition - type name: {}", property.getTypeName()); - LOGGER.trace("Values: {}", property.getAllowedValues()); - } - LOGGER.trace("---------------------------------------------------------------------------------------");*/ - configuration.applyDefinition(configurationContainerDefinition, true); - - LOGGER.trace("Parameters container with definitions : {}", configuration.debugDump()); - - return configuration; - } - - public static JasperReport getJasperReport(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema) throws JRException { - JasperDesign jasperDesign; - JasperReport jasperReport; - try { - if (reportType.getTemplate() == null) { - jasperDesign = createJasperDesign(reportType, parameterConfiguration, reportSchema); - LOGGER.trace("create jasper design : {}", jasperDesign); - } else { - byte[] reportTemplatebase64 = reportType.getTemplate(); - byte[] reportTemplate = Base64.decodeBase64(reportTemplatebase64); - - InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate); - jasperDesign = JRXmlLoader.load(inputStreamJRXML); - LOGGER.trace("load jasper design : {}", jasperDesign); - } - - if (reportType.getTemplateStyle() != null) { - JRDesignReportTemplate templateStyle = new JRDesignReportTemplate(new JRDesignExpression("$P{" + PARAMETER_TEMPLATE_STYLES + "}")); - jasperDesign.addTemplate(templateStyle); - JRDesignParameter parameter = new JRDesignParameter(); - parameter.setName(PARAMETER_TEMPLATE_STYLES); - parameter.setValueClass(JRTemplate.class); - parameter.setForPrompting(false); - jasperDesign.addParameter(parameter); - } - jasperReport = JasperCompileManager.compileReport(jasperDesign); - - } catch (JRException ex) { - LOGGER.error("Couldn't create jasper report design {}", ex.getMessage()); - throw ex; - } - - return jasperReport; - } - - public static Map getReportParameters(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema, OperationResult parentResult) { - Map params = new HashMap(); - if (reportType.getTemplateStyle() != null) { - byte[] reportTemplateStyleBase64 = reportType.getTemplateStyle(); - byte[] reportTemplateStyle = Base64.decodeBase64(reportTemplateStyleBase64); - //TODO must be changed - //without replace strings, without xmlns namespace, with insert into schema special xml element DOCTYPE -// int first = reportTemplateStyle.indexOf(">"); -// int last = reportTemplateStyle.lastIndexOf("<"); -// reportTemplateStyle = "" + reportTemplateStyle.substring(first+1, last) + ""; -// StringBuilder templateStyleSb = new StringBuilder(TEMPLATE_STYLE_SCHEMA); - try { -// templateStyleSb.append("\n"); -// templateStyleSb.append(new String(reportTemplateStyle, "utf-8")); - //// - // reportTemplateStyle = TEMPLATE_STYLE_SCHEMA + "\n" + reportTemplateStyle; - LOGGER.trace("Style template string {}", new String(reportTemplateStyle)); - InputStream inputStreamJRTX = new ByteArrayInputStream(reportTemplateStyle); - JRTemplate templateStyle = JRXmlTemplateLoader.load(inputStreamJRTX); - params.put(PARAMETER_TEMPLATE_STYLES, templateStyle); - LOGGER.trace("Style template parameter {}", templateStyle); - - } catch (Exception ex) { - LOGGER.error("Error create style template parameter {}", ex.getMessage()); - throw new SystemException(ex); - } - - } - OperationResult subResult = parentResult.createSubresult("get report parameters"); - if (parameterConfiguration != null) { - for (PrismProperty parameter : parameterConfiguration.getValue().getProperties()) { - LOGGER.trace("parameter {}, {}, {} ", new Object[]{parameter.getElementName().getLocalPart(), parameter.getRealValue(), parameter.getValues()}); - - if (parameter.getDefinition().getTypeName().getNamespaceURI().equals(reportSchema.getNamespace())) { - com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl ccc = (com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl) parameter.getRealValue(com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl.class); - LOGGER.trace("Parameter simple type, text content : {}, {}", parameter.getDefinition().getTypeName().getLocalPart(), ccc.getTextContent()); - params.put(parameter.getElementName().getLocalPart(), Integer.decode(ccc.getTextContent())); - } else { - - Class classType = ReportUtils.getClassType(parameter.getDefinition().getTypeName(), reportSchema.getNamespace()); - if (classType == java.sql.Timestamp.class) { - params.put(parameter.getElementName().getLocalPart(), ReportUtils.convertDateTime((XMLGregorianCalendar) parameter.getRealValue(XMLGregorianCalendar.class))); - } else { - params.put(parameter.getElementName().getLocalPart(), parameter.getRealValue()); - } - } - - //LOGGER.trace("--------------------------------------------------------------------------------"); - //} - } - } - // for our special datasource - subResult.computeStatus(); - - return params; - } - - public static String resolveRefName(ObjectReferenceType ref) { - if (ref == null) { - return null; - } - PrismReferenceValue refValue = ref.asReferenceValue(); - Object name = refValue.getUserData(XNodeSerializer.USER_DATA_KEY_COMMENT); - if (!(name instanceof String)) { - LOGGER.error("Couldn't resolve object name"); - } - - return (String) name; - } - - /* - public static Class getObjectTypeClass(PrismContainer parameterConfiguration, String namespace) - { - - PrismProperty objectTypeProp = getParameter(PARAMETER_OBJECT_TYPE, parameterConfiguration, namespace); - return getObjectTypeClass(objectTypeProp.getRealValue()); - } - */ - public static Class getObjectTypeClass(Map params) { - - Object parameterClass = params.get(PARAMETER_OBJECT_TYPE); - return getObjectTypeClass(parameterClass); - } - - public static Class getObjectTypeClass(Object objectClass) { - Class clazz = ObjectType.class; - try { - QName objectType = (QName) objectClass; - LOGGER.trace("Parameter object type : {}", objectType); - clazz = ObjectTypes.getObjectTypeClass(objectType.getLocalPart()); - LOGGER.trace("Parameter class of object type : {}", clazz); - } catch (Exception ex) { - LOGGER.trace("Couldn't load object type parameter : {}", ex.getMessage()); - } - return clazz; - } - - public static PrismProperty getParameter(String parameterName, PrismContainer parameterConfiguration, String namespace) { - if (parameterConfiguration == null) { - return null; - } - PrismProperty property = parameterConfiguration.findProperty(new QName(namespace, parameterName)); - /*for(PrismProperty parameter : parameterConfiguration.getValue().getProperties()) - { - LOGGER.trace("Parameter : {} ", parameter.debugDump()); - LOGGER.trace("Display Name : {}", parameter.getDisplayName()); - LOGGER.trace("Real value : {}", parameter.getRealValue()); - LOGGER.trace("Element Name : {}", parameter.getElementName()); - LOGGER.trace("Definition - type name: {}", parameter.getDefinition().getTypeName()); - LOGGER.trace("--------------------------------------------------------------------------------"); - }*/ - return property; - } public static Timestamp convertDateTime(XMLGregorianCalendar dateTime) { Timestamp timestamp = new Timestamp(System.currentTimeMillis()); try { - timestamp = new Timestamp(XmlTypeConverter.toDate(dateTime).getTime()); + timestamp = new Timestamp(dateTime.toGregorianCalendar().getTimeInMillis()); } catch (Exception ex) { LOGGER.trace("Incorrect date time value {}", dateTime); } @@ -546,401 +75,7 @@ public static Timestamp convertDateTime(XMLGregorianCalendar dateTime) { return timestamp; } - private static JRDesignParameter createParameter(PrismProperty parameterConfig, PrismSchema reportSchema) { - JRDesignParameter parameter = new JRDesignParameter(); - parameter.setName(parameterConfig.getElementName().getLocalPart()); - parameter.setValueClass(getClassType(parameterConfig.getDefinition().getTypeName(), reportSchema.getNamespace())); - parameter.setForPrompting(false); - return parameter; - } - - private static JRDesignTextField createField(ReportFieldConfigurationType fieldRepo, int x, int width, int frameWidth) { - JRDesignTextField textField = new JRDesignTextField(); - textField.setX(x); - textField.setY(1); - textField.setWidth(width); - textField.setHeight(18); - textField.setStretchWithOverflow(true); - textField.setBlankWhenNull(true); - textField.setVerticalAlignment(VerticalAlignEnum.MIDDLE); - textField.setStyleNameReference("Detail"); - textField.setExpression(new JRDesignExpression("$F{" + fieldRepo.getNameReport() + "}")); - return textField; - } - - private static void setOrientation(JasperDesign jasperDesign, OrientationEnum orientation, int pageWidth, int pageHeight, int columnWidth) { - jasperDesign.setOrientation(orientation); - jasperDesign.setPageWidth(pageWidth); - jasperDesign.setPageHeight(pageHeight); - jasperDesign.setColumnWidth(columnWidth); - } - - private static JRDesignStyle createStyle(String name, boolean isDefault, boolean isBold, JRStyle parentStyle, Color backcolor, Color forecolor, ModeEnum mode, HorizontalAlignEnum hAlign, VerticalAlignEnum vAlign, int fontSize, String pdfFontName, String pdfEncoding, boolean isPdfEmbedded) { - JRDesignStyle style = new JRDesignStyle(); - style.setName(name); - style.setDefault(isDefault); - style.setBold(isBold); - if (parentStyle != null) { - style.setParentStyle(parentStyle); - } - style.setBackcolor(backcolor); - style.setForecolor(forecolor); - if (hAlign != null) { - style.setHorizontalAlignment(hAlign); - } - if (vAlign != null) { - style.setVerticalAlignment(vAlign); - } - if (fontSize != 0) { - style.setFontSize(fontSize); - } - if (mode != null) { - style.setMode(mode); - } - if (!pdfFontName.isEmpty()) { - style.setPdfFontName(pdfFontName); - style.setPdfEncoding(pdfEncoding); - style.setPdfEmbedded(isPdfEmbedded); - } - return style; - } - - private static JRDesignStyle createStyle(String name, boolean isBold, JRStyle parentStyle, Color backcolor, Color forecolor, ModeEnum mode, HorizontalAlignEnum hAlign, int fontSize) { - JRDesignStyle style = createStyle(name, false, isBold, parentStyle, backcolor, forecolor, mode, hAlign, null, fontSize, "", "", false); - return style; - } - - private static JRDesignStyle createStyle(String name, boolean isBold, JRStyle parentStyle, Color backcolor, Color forecolor, ModeEnum mode, int fontSize) { - JRDesignStyle style = createStyle(name, false, isBold, parentStyle, backcolor, forecolor, mode, null, null, fontSize, "", "", false); - return style; - } - - private static JRDesignStyle createStyle(String name, boolean isBold, JRStyle parentStyle, int fontSize) { - JRDesignStyle style = createStyle(name, false, isBold, parentStyle, null, null, null, null, null, fontSize, "", "", false); - return style; - } - - private static JRDesignStyle createStyle(String name, boolean isBold, JRStyle parentStyle) { - JRDesignStyle style = createStyle(name, false, isBold, parentStyle, null, null, null, null, null, 0, "", "", false); - return style; - } - - private static JRDesignBand createBand(int height, SplitTypeEnum split) { - JRDesignBand band = new JRDesignBand(); - band.setHeight(height); - band.setSplitType(split); - return band; - } - - private static JRDesignBand createBand(int height) { - return createBand(height, SplitTypeEnum.STRETCH); - } - - private static JRDesignFrame createFrame(int x, int y, int height, int width, String styleName, ModeEnum mode) { - JRDesignFrame frame = new JRDesignFrame(); - frame.setX(x); - frame.setY(y); - frame.setHeight(height); - frame.setWidth(width); - frame.setStyleNameReference(styleName); - if (mode != null) { - frame.setMode(mode); - } - return frame; - } - - private static JRDesignFrame createFrame(int x, int y, int height, int width, String styleName) { - return createFrame(x, y, height, width, styleName, null); - } - - private static JRDesignStaticText createStaticText(int x, int y, int height, int width, String styleName, VerticalAlignEnum vAlign, String text) { - JRDesignStaticText staticText = new JRDesignStaticText(); - staticText.setX(x); - staticText.setY(y); - staticText.setHeight(height); - staticText.setWidth(width); - staticText.setStyleNameReference(styleName); - staticText.setVerticalAlignment(vAlign); - staticText.setText(text); - return staticText; - } - - private static JRDesignImage createImage(int x, int y, int height, int width, String styleName, JRExpression expression) { - JRDesignImage image = new JRDesignImage(new JRDesignStyle().getDefaultStyleProvider()); - image.setX(x); - image.setY(y); - image.setHeight(height); - image.setWidth(width); - image.setStyleNameReference(styleName); - image.setExpression(expression); - return image; - } - - private static JRDesignTextField createTextField(int x, int y, int height, int width, HorizontalAlignEnum hAlign, VerticalAlignEnum vAlign, String styleName, Boolean isBold, EvaluationTimeEnum evalution, Boolean blankWhenNull, JRExpression expression) { - JRDesignTextField textField = new JRDesignTextField(); - textField.setX(x); - textField.setY(y); - textField.setHeight(height); - textField.setWidth(width); - textField.setHorizontalAlignment(hAlign); - textField.setVerticalAlignment(vAlign); - textField.setStyleNameReference(styleName); - if (isBold != null) { - textField.setBold(isBold); - } - textField.setEvaluationTime(evalution); - if (blankWhenNull != null) { - textField.setBlankWhenNull(blankWhenNull); - } - textField.setExpression(expression); - return textField; - } - - private static JRDesignTextField createTextField(int x, int y, int height, int width, String styleName, Boolean isBold, JRExpression expression) { - return createTextField(x, y, height, width, HorizontalAlignEnum.RIGHT, VerticalAlignEnum.MIDDLE, styleName, isBold, EvaluationTimeEnum.NOW, null, expression); - } - - private static JRDesignTextField createTextField(int x, int y, int height, int width, String styleName, JRExpression expression) { - return createTextField(x, y, height, width, HorizontalAlignEnum.RIGHT, VerticalAlignEnum.MIDDLE, styleName, null, EvaluationTimeEnum.NOW, null, expression); - } - - private static JRDesignTextField createTextField(int x, int y, int height, int width, String styleName, Boolean isBold, EvaluationTimeEnum evalution, JRExpression expression) { - return createTextField(x, y, height, width, HorizontalAlignEnum.RIGHT, VerticalAlignEnum.MIDDLE, styleName, isBold, evalution, null, expression); - } - - private static JRDesignTextField createTextField(int x, int y, int height, int width, String styleName, EvaluationTimeEnum evalution, JRExpression expression) { - return createTextField(x, y, height, width, HorizontalAlignEnum.RIGHT, VerticalAlignEnum.MIDDLE, styleName, null, evalution, null, expression); - } - - private static JRDesignLine createLine(int x, int y, int height, int width, PositionTypeEnum position, float penLineWidth) { - JRDesignLine line = new JRDesignLine(); - line.setX(x); - line.setY(y); - line.setHeight(height); - line.setWidth(width); - line.setPositionType(position); - JRBasePen pen = new JRBasePen(line); - pen.setLineWidth(penLineWidth); - pen.setLineColor(Color.decode("#999999")); - return line; - } - - private static void createStyles(JasperDesign jasperDesign) throws JRException { - JRDesignStyle baseStyle = createStyle("Base", true, true, null, Color.decode("#FFFFFF"), Color.decode("#000000"), null, HorizontalAlignEnum.LEFT, VerticalAlignEnum.MIDDLE, 10, "Helvetica", "Cp1252", false); - jasperDesign.addStyle(baseStyle); - - JRDesignStyle titleStyle = createStyle("Title", true, baseStyle, Color.decode("#267994"), Color.decode("#FFFFFF"), ModeEnum.OPAQUE, 26); - jasperDesign.addStyle(titleStyle); - - JRDesignStyle pageHeaderStyle = createStyle("Page header", true, baseStyle, 12); - jasperDesign.addStyle(pageHeaderStyle); - - JRDesignStyle columnHeaderStyle = createStyle("Column header", true, baseStyle, Color.decode("#333333"), Color.decode("#FFFFFF"), ModeEnum.OPAQUE, HorizontalAlignEnum.CENTER, 12); - jasperDesign.addStyle(columnHeaderStyle); - - JRDesignStyle detailStyle = createStyle("Detail", false, baseStyle); - jasperDesign.addStyle(detailStyle); - - JRDesignStyle pageFooterStyle = createStyle("Page footer", true, baseStyle, 9); - jasperDesign.addStyle(pageFooterStyle); - } - - private static JRDesignBand createTitleBand(int height, int reportColumn, int secondColumn, PrismContainer parameterConfiguration, PrismSchema reportSchema) { - JRDesignBand titleBand = createBand(height); - JRDesignFrame frame = createFrame(0, 0, 70, reportColumn, "Title"); - titleBand.addElement(frame); - - JRDesignStaticText staticText = createStaticText(10, 15, 40, 266, "Title", VerticalAlignEnum.MIDDLE, "DataSource Report"); - frame.addElement(staticText); - if (getParameter(PARAMETER_LOGO, parameterConfiguration, reportSchema.getNamespace()) != null) { - JRDesignImage image = createImage(589, 15, 40, 203, "Title", new JRDesignExpression("$P{" + PARAMETER_LOGO + "}")); - frame.addElement(image); - } - staticText = createStaticText(secondColumn, 70, 20, 150, "Page header", VerticalAlignEnum.MIDDLE, "Report generated on:"); - titleBand.addElement(staticText); - - JRDesignTextField textField = createTextField(secondColumn + 150, 70, 20, 250, "Page header", false, new JRDesignExpression("new java.util.Date()")); - titleBand.addElement(textField); - - staticText = createStaticText(secondColumn, 90, 20, 150, "Page header", VerticalAlignEnum.MIDDLE, "Number of records:"); - titleBand.addElement(staticText); - - textField = createTextField(secondColumn + 150, 90, 20, 250, "Page header", false, EvaluationTimeEnum.REPORT, new JRDesignExpression("$V{REPORT_COUNT}")); - titleBand.addElement(textField); - - //remove parameters, which are not special for data - if (parameterConfiguration != null) { - int y = 70; - for (PrismProperty parameter : parameterConfiguration.getValue().getProperties()) {/* - LOGGER.trace("Parameter : {} ", parameter); - LOGGER.trace("Display Name : {}", parameter.getDisplayName()); - LOGGER.trace("Real value : {}", parameter.getRealValue()); - LOGGER.trace("Element Name : {}", parameter.getElementName()); - LOGGER.trace("Definition : {}", parameter.getDefinition()); - LOGGER.trace("--------------------------------------------------------------------------------"); - */ - - if (parameter.getDisplayName() != null) { - staticText = createStaticText(2, y, 20, 150, "Page header", VerticalAlignEnum.MIDDLE, parameter.getDisplayName() + ":"); - titleBand.addElement(staticText); - - textField = createTextField(160, y, 20, 240, "Page header", false, new JRDesignExpression("$P{" + parameter.getElementName().getLocalPart() + "}")); - titleBand.addElement(textField); - - y = y + 20; - } - } - } - return titleBand; - } - - private static JRDesignBand createColumnHeaderBand(int height, int reportColumn, List reportFields) { - JRDesignBand columnHeaderBand = createBand(height); - JRDesignFrame frame = createFrame(0, 5, 19, reportColumn, "Column header"); - - int x = 0; - int width = 0; - for (ReportFieldConfigurationType fieldRepo : reportFields) { - width = Math.round((float) ((frame.getWidth() / 100) * fieldRepo.getWidth())); - JRDesignStaticText staticText = createStaticText(x, 0, 18, width, "Column header", VerticalAlignEnum.MIDDLE, fieldRepo.getNameHeader()); - frame.addElement(staticText); - x = x + width; - } - - columnHeaderBand.addElement(frame); - return columnHeaderBand; - } - - private static JRDesignBand createDetailBand(int height, int reportColumn, List reportFields) { - JRDesignBand detailBand = createBand(height); - JRDesignFrame frame = createFrame(0, 1, 19, reportColumn, "Detail"); - - int x = 0; - int width = 0; - int frameWidth = frame.getWidth(); - for (ReportFieldConfigurationType fieldRepo : reportFields) { - width = Math.round((float) ((frameWidth / 100) * fieldRepo.getWidth())); - JRDesignTextField textField = createField(fieldRepo, x, width, frameWidth); - frame.addElement(textField); - x = x + width; - } - - JRDesignLine line = createLine(0, 3, 1, reportColumn, PositionTypeEnum.FIX_RELATIVE_TO_BOTTOM, (float) 0.5); - frame.addElement(line); - - detailBand.addElement(frame); - return detailBand; - } - - private static JRDesignBand createColumnFooterBand(int height, int reportColumn) { - JRDesignBand columnFooterBand = createBand(height); - - JRDesignLine line = createLine(0, 3, 1, reportColumn, PositionTypeEnum.FIX_RELATIVE_TO_BOTTOM, (float) 0.5); - columnFooterBand.addElement(line); - return columnFooterBand; - } - - private static JRDesignBand createPageFooterBand(int height, int reportColumn) { - JRDesignBand pageFooterBand = createBand(height); - JRDesignFrame frame = createFrame(0, 1, 24, reportColumn, "Page footer", ModeEnum.TRANSPARENT); - JRDesignTextField textField = createTextField(2, 1, 20, 197, "Page footer", new JRDesignExpression("new java.util.Date()")); - frame.addElement(textField); - - textField = createTextField(680, 1, 20, 80, "Page footer", new JRDesignExpression("\"Page \" + String.valueOf($V{PAGE_NUMBER}) + \" of\"")); - frame.addElement(textField); - - textField = createTextField(760, 1, 20, 40, "Page footer", EvaluationTimeEnum.REPORT, new JRDesignExpression("$V{PAGE_NUMBER}")); - frame.addElement(textField); - - pageFooterBand.addElement(frame); - return pageFooterBand; - } - - public static JasperDesign createJasperDesign(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema) throws JRException { - - //JasperDesign - JasperDesign jasperDesign = new JasperDesign(); - String reportName = reportType.getName().getOrig(); - jasperDesign.setName(reportName.replace("\\s", "")); - - switch (reportType.getOrientation()) { - case LANDSCAPE: - default: - setOrientation(jasperDesign, OrientationEnum.LANDSCAPE, 842, 595, 802); - break; - case PORTRAIT: - setOrientation(jasperDesign, OrientationEnum.PORTRAIT, 595, 842, 555); - break; - } - - jasperDesign.setColumnSpacing(0); - jasperDesign.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL); - jasperDesign.setLeftMargin(20); - jasperDesign.setRightMargin(20); - jasperDesign.setTopMargin(20); - jasperDesign.setBottomMargin(20); - - //Parameters - if (parameterConfiguration != null) { - for (PrismProperty parameterConfig : parameterConfiguration.getValue().getProperties()) { - JRDesignParameter parameter = createParameter(parameterConfig, reportSchema); - jasperDesign.addParameter(parameter); - - } -// jasperDesign.setLanguage(MidPointQueryExecutorFactory.PARAMETER_MIDPOINT_CONNECTION); -// jasperDesign.setProperty(MidPointQueryExecutorFactory.PARAMETER_PRISM_CONTEXT, parameterConfiguration.getPrismContext()); -// jasperDesign.addParameter(parameter); -// .PARAMETER_MIDPOINT_CONNECTION, model); - } - //Template Style or Styles - if (getParameter(PARAMETER_TEMPLATE_STYLES, parameterConfiguration, reportSchema.getNamespace()) != null) { - JRDesignReportTemplate templateStyle = new JRDesignReportTemplate(new JRDesignExpression("$P{" + PARAMETER_TEMPLATE_STYLES + "}")); - jasperDesign.addTemplate(templateStyle); - } else { - createStyles(jasperDesign); - } - - //Fields - for (ReportFieldConfigurationType fieldRepo : reportType.getField()) { - JRDesignField field = new JRDesignField(); - field.setName(fieldRepo.getNameReport()); - field.setValueClass(getClassType(fieldRepo.getClassType(), reportSchema.getNamespace())); - jasperDesign.addField(field); - } - - //Background - JRDesignBand bandBackground = createBand(30); - jasperDesign.setBackground(bandBackground); - - //Title - //band size depends on the number of parameters - int reportColumn = jasperDesign.getColumnWidth() - 2; - int secondColumn = Math.round(jasperDesign.getColumnWidth() / 2 - 1); - //int height = 70 + Math.max(40, parameters.size()*20); - int height = 70 + Math.max(40, 20); - - JRDesignBand titleBand = createTitleBand(height, reportColumn, secondColumn, parameterConfiguration, reportSchema); - jasperDesign.setTitle(titleBand); - - //Column header - JRDesignBand columnHeaderBand = createColumnHeaderBand(24, reportColumn, reportType.getField()); - jasperDesign.setColumnHeader(columnHeaderBand); - - //Detail - JRDesignBand detailBand = createDetailBand(20, reportColumn, reportType.getField()); - ((JRDesignSection) jasperDesign.getDetailSection()).addBand(detailBand); - - //Column footer - JRDesignBand columnFooterBand = createColumnFooterBand(7, reportColumn); - jasperDesign.setColumnFooter(columnFooterBand); - - //Page footer - JRDesignBand pageFooterBand = createPageFooterBand(32, reportColumn); - jasperDesign.setPageFooter(pageFooterBand); - - return jasperDesign; - } - + public static String getDateTime() { Date createDate = new Date(System.currentTimeMillis()); SimpleDateFormat formatDate = new SimpleDateFormat("dd-MM-yyyy hh-mm-ss"); @@ -1005,162 +140,8 @@ public static String getReportOutputFilePath(ReportType reportType) { return output; } - // TODO is this used? YES :) But it needs re-implementation (I hope, for now this one is quite good).. - public static String getDeltaAudit(String delta) { - String deltaAudit = "fixed value"; - try { -// SchemaRegistry schemaRegistry = new SchemaRegistry(); -// PrismContext prismContext = PrismContext.createEmptyContext(schemaRegistry); -// ObjectDeltaType xmlDelta = prismContext.getPrismJaxbProcessor().unmarshalObject(delta, ObjectDeltaType.class); -// deltaAudit = xmlDelta.getChangeType().toString() + " - " + xmlDelta.getObjectType().getLocalPart().toString(); - - DomParser domParser = new DomParser(null); - XNode xnode = domParser.parse(delta); - - MapXNode deltaXnode = null; - if (xnode instanceof RootXNode) { - RootXNode root = (RootXNode) xnode; - if (root.getSubnode() instanceof MapXNode) { - deltaXnode = (MapXNode) root.getSubnode(); - } else { - throw new IllegalStateException("Error parsing delta for audit report. Expected map after parsing, but was: " + root.getSubnode()); - } - } else if (xnode instanceof MapXNode) { - deltaXnode = (MapXNode) xnode; - } else { - throw new IllegalStateException("Error parsing delta for audit report " + xnode); - } - -// System.out.println("delta xnode : " + xnode.debugDump()); - QName objectTypeXnode = deltaXnode.getParsedPrimitiveValue(ObjectDeltaType.F_OBJECT_TYPE, DOMUtil.XSD_QNAME); - String changeTypeXnode = deltaXnode.getParsedPrimitiveValue(ObjectDeltaType.F_CHANGE_TYPE, DOMUtil.XSD_STRING); - StringBuilder sb = new StringBuilder(changeTypeXnode); - sb.append("-"); - sb.append(objectTypeXnode.getLocalPart()); - - deltaAudit = sb.toString(); - - } catch (Exception ex) { - return ex.getMessage(); - } - - return deltaAudit; - } - /* - public static ObjectQuery getObjectQuery(PrismContainer parameterConfiguration, String namespace, PrismContext prismContext) - {/* - PrismProperty filterProp = getParameter(PARAMETER_QUERY_FILTER, parameterConfiguration, namespace); - - PrismContainerDefinition def = parameterConfiguration.getDefinition(); - ObjectQuery objectQuery = new ObjectQuery(); - if (filterProp != null) - { - try - { - ObjectFilter objectFilter = QueryConvertor.parseFilter(def, (Node)filterProp.getRealValue()); - objectQuery = ObjectQuery.createObjectQuery(objectFilter); - } catch(SchemaException ex){ - LOGGER.error("Couldn't create object query : {}", ex.getMessage()); - throw ex; - } - } - *//* - PrismProperty filterProp = getParameter(PARAMETER_QUERY_FILTER, parameterConfiguration, namespace); - - ObjectQuery objectQuery = new ObjectQuery(); - try - { - Class clazz = getObjectTypeClass(parameterConfiguration, namespace); - QueryType queryType = filterProp.getRealValue(); - LOGGER.info(DOMUtil.serializeDOMToString(filterProp.asDomElements().get(0))); - - objectQuery = QueryConvertor.createObjectQuery(clazz, queryType, prismContext); - } catch(Exception ex){ - LOGGER.error("Couldn't create object query : {}", ex.getMessage()); - } - - return objectQuery; - } - */ - public static ObjectQuery getObjectQuery(Map params, Class clazz, PrismContext prismContext) { - ObjectQuery objectQuery = new ObjectQuery(); - try { - // TODO is this ok? - SearchFilterType filterType = (SearchFilterType) params.get(PARAMETER_QUERY_FILTER); - LOGGER.info("DataSource Query type : {}", filterType); - if (filterType != null) { - objectQuery.setFilter(QueryConvertor.parseFilter(filterType, (Class) clazz, prismContext)); - } - } catch (Exception ex) { - LOGGER.error("Couldn't create object query : {}", ex.getMessage()); - } - - return objectQuery; - } - - public static ReportType getReport(String reportOid, OperationResult parentResult, ModelService modelService) throws Exception { - parentResult.addContext("reportOid", reportOid); - - if (reportOid == null) { - throw new IllegalArgumentException("Report OID is missing in task extension"); - } - ReportType reportType = null; - try { - LOGGER.trace("get report : {}", reportOid); - reportType = modelService.getObject(ReportType.class, reportOid, null, null, parentResult).asObjectable();; - } catch (ObjectNotFoundException ex) { - LOGGER.error("Report does not exist: {}", ex.getMessage(), ex); - parentResult.recordFatalError("Report does not exist: " + ex.getMessage(), ex); - throw ex; - } catch (Exception ex) { - LOGGER.error("Create Report: {}", ex.getMessage(), ex); - parentResult.recordFatalError("Report: " + ex.getMessage(), ex); - throw ex; - } - - return reportType; - } - - public static ReportType getReport(Map params, ModelService modelService, PrismContext prismContext) throws Exception { - OperationResult parentResult = getOperationResult(params); - String reportOid = params.get(PARAMETER_REPORT_OID).toString(); - parentResult.addContext("reportOid", reportOid); - - if (reportOid == null) { - throw new IllegalArgumentException("Report OID is missing in datasource"); - } - ReportType reportType = null; - try { - LOGGER.trace("get report : {}", reportOid); - reportType = modelService.getObject(ReportType.class, reportOid, null, null, parentResult).asObjectable();; - } catch (ObjectNotFoundException ex) { - LOGGER.error("Report does not exist: {}", ex.getMessage(), ex); - parentResult.recordFatalError("Report does not exist: " + ex.getMessage(), ex); - throw ex; - } catch (Exception ex) { - LOGGER.error("Create Report: {}", ex.getMessage(), ex); - parentResult.recordFatalError("Report: " + ex.getMessage(), ex); - throw ex; - } - - return reportType; - } - - public static OperationResult getOperationResult(Map params) { - OperationResult result = new OperationResult("DataSource - create"); - try { - result = (OperationResult) params.get(PARAMETER_OPERATION_RESULT); - LOGGER.info("Datasource Operation result : {}", result); - - } catch (Exception ex) { - LOGGER.error("Couldn't create operation result : {}", ex.getMessage()); - } - - return result; - } - public static String getPropertyString(String key) { return getPropertyString(key, null); } @@ -1182,93 +163,10 @@ public static String prettyPrintForReport(QName qname) { return ret; } - public static String prettyPrintForReport(PrismProperty pp) { - StringBuilder sb = new StringBuilder(); - sb.append(pp.getPath()); - sb.append("="); - sb.append("{"); - List ppvList = pp.getValues(); - for (PrismPropertyValue ppv : ppvList) { - String ps = prettyPrintForReport(ppv); - if (!ps.isEmpty()) { - sb.append(ps); - sb.append(", "); - } - } - sb.setLength(Math.max(sb.length() - 2, 0)); // delete last delimiter - sb.append("}"); - return sb.toString(); - } - - public static String prettyPrintForReport(PrismReference pr) { - StringBuilder sb = new StringBuilder(); - sb.append(pr.getPath()); - sb.append("="); - sb.append("{"); - List prvList = pr.getValues(); - for (PrismReferenceValue ppv : prvList) { - String ps = prettyPrintForReport(ppv); - if (!ps.isEmpty()) { - sb.append(ps); - sb.append(", "); - } - } - sb.setLength(Math.max(sb.length() - 2, 0)); // delete last delimiter - sb.append("}"); - return sb.toString(); - } - - public static String prettyPrintForReport(PrismContainer pc) { - StringBuilder sb = new StringBuilder(); - if ("metadata".equalsIgnoreCase(pc.getElementName().getLocalPart())) { // skip metadata, still needed? - return ""; - } - sb.append(pc.getPath()); - sb.append("="); - sb.append("{"); - List prvList = pc.getValues(); - for (PrismContainerValue ppv : prvList) { - String ps = prettyPrintForReport(ppv); - if (!ps.isEmpty()) { - sb.append(ps); - sb.append(", "); - } - } - sb.setLength(Math.max(sb.length() - 2, 0)); // delete last delimiter - sb.append("}"); - return sb.toString(); - } - - public static String prettyPrintForReport(PrismContainerValue pcv) { - StringBuilder sb = new StringBuilder(); - for (Object it : pcv.getItems()) { - String ps = prettyPrintForReport(it); - if (!ps.isEmpty()) { - sb.append(ps); - sb.append(", "); - } - } - sb.setLength(Math.max(sb.length() - 2, 0)); // delete last delimiter - return sb.toString(); - } - - public static String prettyPrintForReport(PrismReferenceValue prv) { - // UNDER CONSTRUCTION - // TODO: Complete in 3.3 when PRV has business name stored in DB audit event. MID-2431 - return prv.toString(); - } - public static String prettyPrintForReport(ProtectedStringType pst) { return "*****"; } - public static String prettyPrintForReport(PrismPropertyValue ppv) { - if (ppv == null) { - return "null"; - } - return prettyPrintForReport(ppv.getValue()); - - } public static String prettyPrintForReport(OperationResultType ort) { StringBuilder sb = new StringBuilder(); @@ -1293,9 +191,9 @@ public static String prettyPrintForReport(byte[] ba) { return "[" + ((byte[]) ba).length + " bytes]"; //Jasper doesnt like byte[] } - public static String prettyPrintForReport(Collection prismValueList) { + public static String prettyPrintForReport(Collection prismValueList) { StringBuilder sb = new StringBuilder(); - for (PrismValue pv : prismValueList) { + for (Object pv : prismValueList) { String ps = prettyPrintForReport(pv); if (!ps.isEmpty()) { sb.append(ps); @@ -1312,75 +210,132 @@ public static String prettyPrintForReport(Collection prismValueList) - Credit goes to Evolveum */ public static String prettyPrintForReport(Object value) { - for (Method method : ReportUtils.class.getMethods()) { - if (method.getName().equals("prettyPrintForReport")) { - Class[] parameterTypes = method.getParameterTypes(); - if (parameterTypes.length == 1 && parameterTypes[0].equals(value.getClass())) { - try { - return (String) method.invoke(null, value); - } catch (IllegalArgumentException e) { - return "###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; prettyPrintForReport method for value " + value; - } catch (IllegalAccessException e) { - return "###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; prettyPrintForReport method for value " + value; - } catch (InvocationTargetException e) { - return "###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; prettyPrintForReport method for value " + value; - } catch (Throwable e) { - return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; prettyPrintForReport method for value " + value; - } - } - } - } - if (value.getClass().isArray()) { - Class cclass = value.getClass().getComponentType(); - if (cclass.isPrimitive()) { - if (cclass == byte.class) { - return prettyPrintForReport((byte[]) value); - } - } - } - - return value.toString(); + if (value == null){ + return ""; + } + + //special handling for byte[], some problems with jasper when printing + if (byte[].class.equals(value.getClass())){ + return prettyPrintForReport((byte[]) value); + } + + String str = PrettyPrinter.prettyPrint(value); + if (str.length() > 1000){ + return str.substring(0, 1000); + } + return str; + + } + + private static String printItemDeltaValues(ItemDeltaType itemDelta){ + List values = itemDelta.getValue(); + StringBuilder sb = new StringBuilder(); + for (Object value : values){ + String v = printItemDeltaValue(itemDelta.getPath(), value); + if (StringUtils.isNotBlank(v)){ + sb.append(v); + sb.append(", "); + } + } + sb.setLength(Math.max(sb.length() - 2, 0)); // delete last delimiter + return sb.toString(); + } + + private static String printItemDeltaValue(ItemPathType itemPath, Object value){ + if (value instanceof MetadataType){ + return ""; + } else if (value instanceof RawType){ + try { + + if (isMetadata(itemPath)){ + return ""; + } + return prettyPrintForReport(((RawType) value).getParsedRealValue(null, itemPath.getItemPath())); + } catch (SchemaException e) { + return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; prettyPrintForReport method for value " + value; + } catch (RuntimeException e){ + return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; prettyPrintForReport method for value " + value; + } + } else { + return prettyPrintForReport(value); + } + } - - public static String prettyPrintForReport(ItemDelta itemDelta) { + + private static String printItemDeltaOldValues(ItemPathType itemPath, List values){ + StringBuilder sb = new StringBuilder(); + for (Object value : values){ + String v = printItemDeltaValue(itemPath, value); + if (StringUtils.isNotBlank(v)){ + sb.append(v); + sb.append(", "); + } + } + sb.setLength(Math.max(sb.length() - 2, 0)); // delete last delimiter + return sb.toString(); + + } + + private static boolean isMetadata(ItemDeltaType itemDelta){ + List values = itemDelta.getValue(); + for (Object v : values){ + if (v instanceof MetadataType){ + return true; + } else if (v instanceof RawType){ + return isMetadata(itemDelta.getPath()); + } + } + + return false; + } + + private static boolean isMetadata(ItemPathType itemPath){ + return com.evolveum.midpoint.prism.path.ItemPath.getFirstName(itemPath.getItemPath()).getLocalPart().equals("metadata"); + } + + public static String prettyPrintForReport(ItemDeltaType itemDelta) { StringBuilder sb = new StringBuilder(); boolean displayNA = false; + + if (isMetadata(itemDelta)){ + return sb.toString(); + } sb.append(">>> "); sb.append(itemDelta.getPath()); sb.append("="); sb.append("{"); - if (itemDelta.getEstimatedOldValues() != null && !itemDelta.getEstimatedOldValues().isEmpty()) { + if (itemDelta.getEstimatedOldValue() != null && !itemDelta.getEstimatedOldValue().isEmpty()) { sb.append("Old: "); sb.append("{"); - sb.append(prettyPrintForReport(itemDelta.getEstimatedOldValues())); + sb.append(printItemDeltaOldValues(itemDelta.getPath(), itemDelta.getEstimatedOldValue())); sb.append("}"); sb.append(", "); displayNA = true; } - - if (itemDelta.getValuesToReplace() != null) { + + if (itemDelta.getModificationType() == ModificationTypeType.REPLACE){ sb.append("Replace: "); sb.append("{"); - sb.append(prettyPrintForReport(itemDelta.getValuesToReplace())); + sb.append(printItemDeltaValues(itemDelta)); sb.append("}"); sb.append(", "); displayNA = false; } - if (itemDelta.getValuesToDelete() != null) { + if (itemDelta.getModificationType() == ModificationTypeType.DELETE) { sb.append("Delete: "); sb.append("{"); - sb.append(prettyPrintForReport(itemDelta.getValuesToDelete())); + sb.append(printItemDeltaValues(itemDelta)); sb.append("}"); sb.append(", "); displayNA = false; } - if (itemDelta.getValuesToAdd() != null) { + if (itemDelta.getModificationType() == ModificationTypeType.ADD) { sb.append("Add: "); sb.append("{"); - sb.append(prettyPrintForReport(itemDelta.getValuesToAdd())); + sb.append(printItemDeltaValues(itemDelta)); sb.append("}"); sb.append(", "); displayNA = false; @@ -1396,11 +351,17 @@ public static String prettyPrintForReport(ItemDelta itemDelta) { return sb.toString(); } - private static String printChangeType(ObjectDelta delta, String opName) { + + public static String getBusinessDisplayName(ObjectReferenceType ort){ + return ort.getDescription(); + } + + + private static String printChangeType(ObjectDeltaType delta, String opName) { StringBuilder sb = new StringBuilder(); sb.append(opName); sb.append(" "); - sb.append(delta.getObjectTypeClass().getSimpleName()); + sb.append(delta.getObjectType().getLocalPart()); if (delta.getOid() != null) { sb.append(": "); sb.append(delta.getOid()); @@ -1409,33 +370,27 @@ private static String printChangeType(ObjectDelta delta, String opName) { return sb.toString(); } - public static String printDelta(ObjectDelta delta) { + + public static String printDelta(List delta) { + StringBuilder sb = new StringBuilder(); + for (ObjectDeltaType d : delta){ + sb.append(printDelta(d)); + sb.append("\n"); + } + return sb.toString(); + } + + public static String printDelta(ObjectDeltaType delta) { StringBuilder sb = new StringBuilder(); Boolean isMeta; switch (delta.getChangeType()) { case MODIFY: - Collection modificationDeltas = delta.getModifications(); + Collection modificationDeltas = delta.getItemDelta(); if (modificationDeltas != null && !modificationDeltas.isEmpty()) { sb.append(printChangeType(delta, "Modify")); } - for (ItemDelta itemDelta : modificationDeltas) { - isMeta = false; - try { - for (ItemPathSegment seg : itemDelta.getParentPath().getSegments()) { - if (seg instanceof NameItemPathSegment) { - if ("metadata".equals(((NameItemPathSegment) seg).getName().getLocalPart())) { - isMeta = true; - break; - } - } - } - if (isMeta) { - continue; //do not report metadata - } - } catch (NullPointerException npe) { - // silence exception as delta doesnt have parent - } + for (ItemDeltaType itemDelta : modificationDeltas) { sb.append(prettyPrintForReport(itemDelta)); sb.append("\n"); } @@ -1443,14 +398,14 @@ public static String printDelta(ObjectDelta delta) { break; case ADD: - PrismObject objectToAdd = delta.getObjectToAdd(); + ObjectType objectToAdd = (ObjectType) delta.getObjectToAdd(); if (objectToAdd != null) { sb.append(printChangeType(delta, "Add")); - sb.append(prettyPrintForReport(objectToAdd.getElementName())); + sb.append(prettyPrintForReport(objectToAdd.getClass().getSimpleName())); sb.append("="); - sb.append(objectToAdd.getBusinessDisplayName()); + sb.append(objectToAdd.getName().toString()); sb.append(" {"); - sb.append(prettyPrintForReport(objectToAdd.getValue())); + sb.append(prettyPrintForReport(objectToAdd)); sb.append("}"); } break; diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/BasicReportTest.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/BasicReportTest.java index 7d2982990b3..36ca073a2f8 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/BasicReportTest.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/BasicReportTest.java @@ -568,7 +568,7 @@ public void test001CreateReport() throws Exception { TestUtil.assertSuccess(result); AssertJUnit.assertEquals(REPORT_OID_001, objectDelta.getOid()); - reportType = ReportUtils.getReport(REPORT_OID_001, result, modelService); +// reportType = ReportUtils.getReport(REPORT_OID_001, result, modelService); // export xml structure of report type //String xmlReportType = prismContext.getPrismDomProcessor().serializeObjectToString(reportType.asPrismObject()); @@ -682,7 +682,7 @@ public void test002CreateReportFromFile() throws Exception { // AssertJUnit.assertTrue("Delta must be null", delta.isEmpty()); - PrismObject reportFromutils = ReportUtils.getReport(TEST_REPORT_OID, result, modelService).asPrismObject(); +// PrismObject reportFromutils = ReportUtils.getReport(TEST_REPORT_OID, result, modelService).asPrismObject(); // LOGGER.info("UTILS: " + reportFromutils.debugDump()); // LOGGER.info("report template: " + new String(Base64.decodeBase64(reportFromutils.asObjectable().getTemplate()))); // LOGGER.info("report template style: " + new String(Base64.decodeBase64(reportFromutils.asObjectable().getTemplateStyle()))); @@ -712,7 +712,7 @@ public void test003CopyReportWithoutDesign() throws Exception { Task task = taskManager.createTaskInstance(COPY_REPORT_WITHOUT_DESIGN); OperationResult result = task.getResult(); - ReportType reportType = ReportUtils.getReport(REPORT_OID_001, result, modelService); + ReportType reportType = null; //ReportUtils.getReport(REPORT_OID_001, result, modelService); reportType = reportType.clone(); reportType.setOid(REPORT_OID_002); @@ -746,7 +746,7 @@ public void test004RunReport() throws Exception { Task task = createTask(RUN_REPORT); OperationResult result = task.getResult(); importUsers(1,10); - ReportType reportType = ReportUtils.getReport(TEST_REPORT_OID, result, modelService); + ReportType reportType = null;//ReportUtils.getReport(TEST_REPORT_OID, result, modelService); LOGGER.info("jasper report: " + new String(Base64.decodeBase64(reportType.getTemplate()), "utf-8")); LOGGER.info("jasper report template: " + new String(Base64.decodeBase64(reportType.getTemplateStyle()))); //WHEN @@ -780,7 +780,7 @@ public void test005ParseOutputReport() throws Exception { ReportOutputType reportOutputType = searchReportOutput(TEST_REPORT_OID).get(0).asObjectable(); LOGGER.trace("read report output {}", reportOutputType); - ReportType reportType = ReportUtils.getReport(TEST_REPORT_OID, result, modelService); + ReportType reportType= null;// = ReportUtils.getReport(TEST_REPORT_OID, result, modelService); LOGGER.trace("read report {}", reportType); // String output = ReportUtils.getReportOutputFilePath(reportType); @@ -887,7 +887,7 @@ public void test006RunTask() throws Exception { TestUtil.displayWhen(TEST_NAME); importObjectFromFile(TEST_REPORT_WITHOUT_DESIGN_FILE); - ReportType reportType = ReportUtils.getReport(TEST_WITHOUT_DESIGN_REPORT_OID, result, modelService); + ReportType reportType = null; //ReportUtils.getReport(TEST_WITHOUT_DESIGN_REPORT_OID, result, modelService); LOGGER.trace("import report task {}", TASK_REPORT_FILE.getPath()); importObjectFromFile(TASK_REPORT_FILE); @@ -1017,7 +1017,7 @@ public void test009ModifyReport() throws Exception { Task task = taskManager.createTaskInstance(MODIFY_REPORT); OperationResult result = task.getResult(); - ReportType reportType = ReportUtils.getReport(REPORT_OID_001, result, modelService); + ReportType reportType = null; //ReportUtils.getReport(REPORT_OID_001, result, modelService); reportType.setExport(ExportType.CSV); @@ -1036,7 +1036,7 @@ public void test009ModifyReport() throws Exception { display(result); TestUtil.assertSuccess(result); - reportType = ReportUtils.getReport(REPORT_OID_001, result, modelService); +// reportType = ReportUtils.getReport(REPORT_OID_001, result, modelService); assertEquals("Unexpected export type", ExportType.CSV, reportType.getExport()); } @@ -1061,12 +1061,12 @@ public void test010DeleteReport() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - try { - ReportType report = ReportUtils.getReport(REPORT_OID_001, result, modelService); - AssertJUnit.fail("Report type was not deleted"); - } catch (ObjectNotFoundException e) { - // This is expected - } +// try { +// ReportType report = null; //ReportUtils.getReport(REPORT_OID_001, result, modelService); +// AssertJUnit.fail("Report type was not deleted"); +// } catch (ObjectNotFoundException e) { +// // This is expected +// } } @@ -1257,7 +1257,7 @@ public void test013CreateAuditLogsReportFromFile() throws Exception { display("Result after good import", result); TestUtil.assertSuccess("Import has failed (result)", result); - ReportType reportType = ReportUtils.getReport(AUDITLOGS_REPORT_OID, result, modelService); + ReportType reportType =null; // ReportUtils.getReport(AUDITLOGS_REPORT_OID, result, modelService); //WHEN TestUtil.displayWhen(TEST_NAME); @@ -1362,7 +1362,7 @@ public void test015CreateUserListReportFromFile() throws Exception { TestUtil.assertSuccess("Import has failed (result)", result); - ReportType reportType = ReportUtils.getReport(USERLIST_REPORT_OID, result, modelService); + ReportType reportType =null; // ReportUtils.getReport(USERLIST_REPORT_OID, result, modelService); //WHEN TestUtil.displayWhen(TEST_NAME); @@ -1428,7 +1428,7 @@ public void test015ACreateCustomDSReportFromFile() throws Exception { // TestUtil.assertSuccess("Import has failed (result)", result); - ReportType reportType = ReportUtils.getReport(USERLIST_REPORT_OID, result, modelService); + ReportType reportType = null; //ReportUtils.getReport(USERLIST_REPORT_OID, result, modelService); //WHEN TestUtil.displayWhen(TEST_NAME); @@ -1467,7 +1467,7 @@ public void test016CreateReconciliationReportFromFile() throws Exception { display("Result after good import", result); TestUtil.assertSuccess("Import has failed (result)", result); - ReportType reportType = ReportUtils.getReport(RECONCILIATION_REPORT_OID, result, modelService); + ReportType reportType =null; // ReportUtils.getReport(RECONCILIATION_REPORT_OID, result, modelService); //WHEN TestUtil.displayWhen(TEST_NAME); @@ -1499,7 +1499,7 @@ public void test017GetReportData() throws Exception { //WHEN TestUtil.displayWhen(TEST_NAME); - ReportType reportType = ReportUtils.getReport(USERLIST_REPORT_OID, result, modelService); + ReportType reportType = null; //ReportUtils.getReport(USERLIST_REPORT_OID, result, modelService); ReportOutputType reportOutputType = searchReportOutput(reportType.getOid()).get(0).asObjectable(); AssertJUnit.assertNotNull(reportOutputType); diff --git a/model/workflow-api/pom.xml b/model/workflow-api/pom.xml index 264cae92abe..9628cef3613 100644 --- a/model/workflow-api/pom.xml +++ b/model/workflow-api/pom.xml @@ -21,7 +21,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT 4.0.0 midPoint Workflow - api @@ -37,17 +37,17 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/model/workflow-impl/pom.xml b/model/workflow-impl/pom.xml index ef9ffce0ab8..219ce94adcc 100644 --- a/model/workflow-impl/pom.xml +++ b/model/workflow-impl/pom.xml @@ -24,7 +24,7 @@ model com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,47 +35,47 @@ com.evolveum.midpoint.model workflow-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model notifications-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.activiti @@ -89,33 +89,33 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT provided com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test-jar test com.evolveum.midpoint.model notifications-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model report-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model report-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -126,7 +126,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -152,37 +152,37 @@ com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 02c58258983..16990ca173f 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ midPoint Project com.evolveum.midpoint midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT pom Utility module to compile all of the maven based midPoint projects. diff --git a/provisioning/pom.xml b/provisioning/pom.xml index 1c10a7dcfab..8d367e0bb40 100644 --- a/provisioning/pom.xml +++ b/provisioning/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/provisioning/provisioning-api/pom.xml b/provisioning/provisioning-api/pom.xml index 8d458d0355b..5375f53a6a3 100644 --- a/provisioning/provisioning-api/pom.xml +++ b/provisioning/provisioning-api/pom.xml @@ -20,12 +20,12 @@ midPoint Provisioning - api com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar provisioning com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,12 +36,12 @@ com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/provisioning/provisioning-impl/pom.xml b/provisioning/provisioning-impl/pom.xml index 7a6eadeec8b..5365269990e 100644 --- a/provisioning/provisioning-impl/pom.xml +++ b/provisioning/provisioning-impl/pom.xml @@ -24,7 +24,7 @@ provisioning com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,33 +35,33 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.provisioning provisioning-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT commons-pool @@ -89,7 +89,7 @@ com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -100,19 +100,19 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -123,13 +123,13 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -172,13 +172,13 @@ com.evolveum.icf dummy-connector - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -199,7 +199,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java index baaf5fea20e..d10e2ad04a8 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java @@ -22,6 +22,7 @@ import javax.xml.namespace.QName; +import com.evolveum.midpoint.prism.Item; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; import org.identityconnectors.framework.spi.operations.CreateOp; @@ -569,7 +570,7 @@ public void applyDefinition(ObjectDelta delta, ShadowType shadowType } shadow = shadowTypeWhenNoOid.asPrismObject(); } else { - shadow = repositoryService.getObject(delta.getObjectTypeClass(), shadowOid, null, parentResult); + shadow = repositoryService.getObject(delta.getObjectTypeClass(), shadowOid, null, parentResult); // TODO consider fetching only when really necessary } } } else { @@ -1444,16 +1445,57 @@ private void applyAttributesDefinition(ProvisioningContext ctx, ObjectDelta itemDelta: delta.getModifications()) { - applyAttributeDefinition(ctx, delta, itemDelta); + if (SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { + applyAttributeDefinition(ctx, delta, itemDelta); + } else if (SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getPath())) { + if (itemDelta.isAdd()) { + for (PrismValue value : itemDelta.getValuesToAdd()) { + applyAttributeDefinition(ctx, value); + } + } + if (itemDelta.isReplace()) { + for (PrismValue value : itemDelta.getValuesToReplace()) { + applyAttributeDefinition(ctx, value); + } + } + } } - } } - + + // value should be a value of attributes container + private void applyAttributeDefinition(ProvisioningContext ctx, PrismValue value) + throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException { + if (!(value instanceof PrismContainerValue)) { + return; // should never occur + } + PrismContainerValue pcv = (PrismContainerValue) value; + for (Item item: pcv.getItems()) { + ItemDefinition itemDef = item.getDefinition(); + if (itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) { + QName attributeName = item.getElementName(); + ResourceAttributeDefinition attributeDefinition = ctx.getObjectClassDefinition().findAttributeDefinition(attributeName); + if (attributeDefinition == null) { + throw new SchemaException("No definition for attribute " + attributeName); + } + if (itemDef != null) { + // We are going to rewrite the definition anyway. Let's just do some basic checks first + if (!QNameUtil.match(itemDef.getTypeName(), attributeDefinition.getTypeName())) { + throw new SchemaException("The value of type " + itemDef.getTypeName() + " cannot be applied to attribute " + attributeName + " which is of type " + attributeDefinition.getTypeName()); + } + } + item.applyDefinition(attributeDefinition); + } + } + } + private void applyAttributeDefinition(ProvisioningContext ctx, ObjectDelta delta, ItemDelta itemDelta) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException { + if (!SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { // just to be sure + return; + } D itemDef = itemDelta.getDefinition(); - if ((itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) && SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { + if (itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) { QName attributeName = itemDelta.getElementName(); ResourceAttributeDefinition attributeDefinition = ctx.getObjectClassDefinition().findAttributeDefinition(attributeName); if (attributeDefinition == null) { diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java index aa53815aaad..8525a4d5a27 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java @@ -1308,6 +1308,10 @@ public Collection> addObject(PrismObject Filter interpret(ObjectFilter objectFilter, IcfNameMapper icfNameMapp OperationResult parentResult = new OperationResult("interpret"); ValueFilter valueFilter= (ValueFilter) objectFilter; - if (valueFilter.getParentPath() != null && !valueFilter.getParentPath().isEmpty() - && valueFilter.getParentPath().equivalent(new ItemPath(ShadowType.F_ATTRIBUTES))) { + if (valueFilter.getParentPath() == null || valueFilter.getParentPath().isEmpty()) { + throw new UnsupportedOperationException("Empty path is not supported (filter: " + objectFilter+")"); + } + if (valueFilter.getParentPath().equivalent(new ItemPath(ShadowType.F_ATTRIBUTES))) { try { QName propName = valueFilter.getDefinition().getName(); String icfName = icfNameMapper.convertAttributeNameToIcf(propName, getInterpreter() @@ -100,14 +107,45 @@ public Filter interpret(ObjectFilter objectFilter, IcfNameMapper icfNameMapp return FilterBuilder.contains(AttributeBuilder.build(icfName, convertedValues.iterator().next())); } } else { - throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter.debugDump()); + throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter); } } catch (SchemaException ex) { throw ex; } + } else if (valueFilter.getParentPath().equivalent(new ItemPath(ShadowType.F_ACTIVATION))) { + + if (objectFilter instanceof EqualFilter) { + QName propName = valueFilter.getDefinition().getName(); + EqualFilter eq = (EqualFilter) objectFilter; + List> values = eq.getValues(); + if (values.size() != 1) { + throw new SchemaException("Unexpected number of values in filter "+objectFilter); + } + PrismPropertyValue pval = values.get(0); + String icfName; + Object convertedValue; + if (propName.equals(ActivationType.F_ADMINISTRATIVE_STATUS)) { + icfName = OperationalAttributes.ENABLE_NAME; + convertedValue = pval.getValue() == ActivationStatusType.ENABLED; + } else if (propName.equals(ActivationType.F_LOCKOUT_STATUS)) { + icfName = OperationalAttributes.LOCK_OUT_NAME; + convertedValue = pval.getValue() == LockoutStatusType.LOCKED; + } else { + throw new UnsupportedOperationException("Unsupported activation property "+propName+" in filter: " + objectFilter); + } + Attribute attr = AttributeBuilder.build(icfName, convertedValue); + if (valueFilter.getDefinition().isSingleValue()) { + return FilterBuilder.equalTo(attr); + } else { + return FilterBuilder.containsAllValues(attr); + } + + } else { + throw new UnsupportedOperationException("Unsupported filter type in filter: " + objectFilter); + } } else { - throw new UnsupportedOperationException("Unsupported parent path "+valueFilter.getParentPath()+" in filter: " + objectFilter.debugDump()); + throw new UnsupportedOperationException("Unsupported parent path "+valueFilter.getParentPath()+" in filter: " + objectFilter); } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java index e0794c1e545..5a6fef2e6fc 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.net.ConnectException; +import java.net.URI; import java.util.Collection; import java.util.List; @@ -86,6 +87,8 @@ public class ProvisioningTestUtil { public static final String CONNECTOR_LDAP_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; public static final String CONNECTOR_LDAP_NS = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector"; + + public static final String DOT_JPG_FILENAME = "src/test/resources/dot.jpg"; public static void assertConnectorSchemaSanity(ConnectorType conn, PrismContext prismContext) throws SchemaException { XmlSchemaType xmlSchemaType = conn.getSchema(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java index 8c5e0825785..2910f4e281b 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java @@ -71,6 +71,7 @@ public abstract class AbstractOpenDJTest extends AbstractIntegrationTest { protected static final File ACCOUNT_JACK_FILE = new File(TEST_DIR, "account-jack.xml"); protected static final File ACCOUNT_JACK_REPO_FILE = new File(TEST_DIR, "account-jack-repo.xml"); protected static final String ACCOUNT_JACK_OID = "c0c010c0-d34d-b44f-f11d-333222444555"; + protected static final String ACCOUNT_JACK_NAME = "jack"; protected static final File ACCOUNT_JACK_CHANGE_FILE = new File(TEST_DIR, "account-jack-change.xml"); protected static final File ACCOUNT_MODIFY_PASSWORD_FILE = new File(TEST_DIR_NAME, "account-modify-password.xml"); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestConnectorDiscovery.java index 77f44e1341b..f13d00fa916 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestConnectorDiscovery.java @@ -95,7 +95,7 @@ public void test001Connectors() throws SchemaException { ProvisioningTestUtil.assertConnectorSchemaSanity(conn, prismContext); } - assertEquals("Unexpected number of connectors found", 4, connectors.size()); + assertEquals("Unexpected number of connectors found", 5, connectors.size()); } @Test @@ -115,7 +115,7 @@ public void testListConnectors() throws Exception{ System.out.println("-----\n"); } - assertEquals("Unexpected number of connectors found", 4, connectors.size()); + assertEquals("Unexpected number of connectors found", 5, connectors.size()); } @Test diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java index 1fa42d78201..16df82a3cbb 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java @@ -101,6 +101,7 @@ import com.evolveum.midpoint.schema.DeltaConvertor; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.ResultHandler; +import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; @@ -1980,7 +1981,7 @@ public void test135ExecuteScript() throws Exception { assertSteadyResource(); } - @Test + @Test public void test150DisableAccount() throws Exception { final String TEST_NAME = "test150DisableAccount"; TestUtil.displayTestTile(TEST_NAME); @@ -2024,54 +2025,85 @@ public void test150DisableAccount() throws Exception { assertSteadyResource(); } + + @Test + public void test151SearchDisabledAccounts() throws Exception { + final String TEST_NAME = "test151SearchDisabledAccounts"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + + Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType), prismContext); + ObjectQueryUtil.filterAnd(query.getFilter(), + EqualFilter.createEqual(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), getShadowDefinition(), ActivationStatusType.DISABLED)); - @Test - public void test151ActivationStatusUndefinedAccount() throws Exception { - final String TEST_NAME = "test151ActivationStatusUndefinedAccount"; - TestUtil.displayTestTile(TEST_NAME); - // GIVEN + syncServiceMock.reset(); - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); - OperationResult result = task.getResult(); + // WHEN + SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, result); - ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, - result).asObjectable(); - assertNotNull(accountType); - display("Retrieved account shadow", accountType); + // THEN + result.computeStatus(); + display(result); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected number of search results", 1, resultList.size()); + PrismObject shadow = resultList.get(0); + display("Shadow", shadow); + assertActivationAdministrativeStatus(shadow, ActivationStatusType.DISABLED); + + assertSteadyResource(); + } + + @Test + public void test152ActivationStatusUndefinedAccount() throws Exception { + final String TEST_NAME = "test152ActivationStatusUndefinedAccount"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + + Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, + result).asObjectable(); + assertNotNull(accountType); + display("Retrieved account shadow", accountType); + + DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); + assertFalse("Account is not disabled", dummyAccount.isEnabled()); + + syncServiceMock.reset(); + + ObjectDelta delta = ObjectDelta.createModificationDeleteProperty(ShadowType.class, + ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, prismContext, + ActivationStatusType.DISABLED); + display("ObjectDelta", delta); + delta.checkConsistence(); + + // WHEN + provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), + new OperationProvisioningScriptsType(), null, task, result); + + // THEN + result.computeStatus(); + display("modifyObject result", result); + TestUtil.assertSuccess(result); + + delta.checkConsistence(); + // check if activation was changed + dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); + assertFalse("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is enabled, expected disabled", dummyAccount.isEnabled()); + + syncServiceMock.assertNotifySuccessOnly(); + + assertSteadyResource(); + } - DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertFalse("Account is not disabled", dummyAccount.isEnabled()); - - syncServiceMock.reset(); - - ObjectDelta delta = ObjectDelta.createModificationDeleteProperty(ShadowType.class, - ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, prismContext, - ActivationStatusType.DISABLED); - display("ObjectDelta", delta); - delta.checkConsistence(); - - // WHEN - provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), - new OperationProvisioningScriptsType(), null, task, result); - - // THEN - result.computeStatus(); - display("modifyObject result", result); - TestUtil.assertSuccess(result); - - delta.checkConsistence(); - // check if activation was changed - dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertFalse("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is enabled, expected disabled", dummyAccount.isEnabled()); - - syncServiceMock.assertNotifySuccessOnly(); - - assertSteadyResource(); - } - @Test - public void test151EnableAccount() throws Exception { - final String TEST_NAME = "test151EnableAccount"; + public void test154EnableAccount() throws Exception { + final String TEST_NAME = "test154EnableAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2113,11 +2145,38 @@ public void test151EnableAccount() throws Exception { assertSteadyResource(); } + @Test + public void test155SearchDisabledAccounts() throws Exception { + final String TEST_NAME = "test155SearchDisabledAccounts"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + + Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType), prismContext); + ObjectQueryUtil.filterAnd(query.getFilter(), + EqualFilter.createEqual(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), getShadowDefinition(), ActivationStatusType.DISABLED)); + + syncServiceMock.reset(); + + // WHEN + SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, result); + + // THEN + result.computeStatus(); + display(result); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected number of search results", 0, resultList.size()); + + assertSteadyResource(); + } @Test - public void test152SetValidFrom() throws Exception { - final String TEST_NAME = "test152SetValidFrom"; + public void test156SetValidFrom() throws Exception { + final String TEST_NAME = "test156SetValidFrom"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2163,8 +2222,8 @@ public void test152SetValidFrom() throws Exception { } @Test - public void test153SetValidTo() throws Exception { - final String TEST_NAME = "test153SetValidTo"; + public void test157SetValidTo() throws Exception { + final String TEST_NAME = "test157SetValidTo"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2211,8 +2270,8 @@ public void test153SetValidTo() throws Exception { } @Test - public void test154DeleteValidToValidFrom() throws Exception { - final String TEST_NAME = "test154DeleteValidToValidFrom"; + public void test158DeleteValidToValidFrom() throws Exception { + final String TEST_NAME = "test158DeleteValidToValidFrom"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2262,8 +2321,8 @@ public void test154DeleteValidToValidFrom() throws Exception { } @Test - public void test155GetLockedoutAccount() throws Exception { - final String TEST_NAME = "test155GetLockedoutAccount"; + public void test159GetLockedoutAccount() throws Exception { + final String TEST_NAME = "test159GetLockedoutAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() @@ -2300,8 +2359,39 @@ public void test155GetLockedoutAccount() throws Exception { } @Test - public void test156UnlockAccount() throws Exception { - final String TEST_NAME = "test156UnlockAccount"; + public void test160SearchLockedAccounts() throws Exception { + final String TEST_NAME = "test160SearchLockedAccounts"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + + Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType), prismContext); + ObjectQueryUtil.filterAnd(query.getFilter(), + EqualFilter.createEqual(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), getShadowDefinition(), LockoutStatusType.LOCKED)); + + syncServiceMock.reset(); + + // WHEN + SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, result); + + // THEN + result.computeStatus(); + display(result); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected number of search results", 1, resultList.size()); + PrismObject shadow = resultList.get(0); + display("Shadow", shadow); + assertLockout(shadow, LockoutStatusType.LOCKED); + + assertSteadyResource(); + } + + @Test + public void test162UnlockAccount() throws Exception { + final String TEST_NAME = "test162UnlockAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2346,8 +2436,8 @@ public void test156UnlockAccount() throws Exception { } @Test - public void test159GetAccount() throws Exception { - final String TEST_NAME = "test159GetAccount"; + public void test163GetAccount() throws Exception { + final String TEST_NAME = "test163GetAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() @@ -2384,16 +2474,44 @@ public void test159GetAccount() throws Exception { } @Test - public void test160SearchNull() throws Exception { - final String TEST_NAME = "test160SearchNull"; + public void test163SearchLockedAccounts() throws Exception { + final String TEST_NAME = "test163SearchLockedAccounts"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + + Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType), prismContext); + ObjectQueryUtil.filterAnd(query.getFilter(), + EqualFilter.createEqual(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), getShadowDefinition(), LockoutStatusType.LOCKED)); + + syncServiceMock.reset(); + + // WHEN + SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, result); + + // THEN + result.computeStatus(); + display(result); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected number of search results", 0, resultList.size()); + + assertSteadyResource(); + } + + @Test + public void test170SearchNull() throws Exception { + final String TEST_NAME = "test170SearchNull"; TestUtil.displayTestTile(TEST_NAME); testSeachIterative(TEST_NAME, null, null, true, true, false, "meathook", "daemon", transformNameFromResource("morgan"), transformNameFromResource("Will")); } @Test - public void test161SearchShipSeaMonkey() throws Exception { - final String TEST_NAME = "test161SearchShipSeaMonkey"; + public void test171SearchShipSeaMonkey() throws Exception { + final String TEST_NAME = "test171SearchShipSeaMonkey"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey", null, true, @@ -2402,8 +2520,8 @@ public void test161SearchShipSeaMonkey() throws Exception { // See MID-1460 @Test(enabled=false) - public void test162SearchShipNull() throws Exception { - final String TEST_NAME = "test162SearchShipNull"; + public void test172SearchShipNull() throws Exception { + final String TEST_NAME = "test172SearchShipNull"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, null, null, true, @@ -2411,8 +2529,8 @@ public void test162SearchShipNull() throws Exception { } @Test - public void test163SearchWeaponCutlass() throws Exception { - final String TEST_NAME = "test163SearchWeaponCutlass"; + public void test173SearchWeaponCutlass() throws Exception { + final String TEST_NAME = "test173SearchWeaponCutlass"; TestUtil.displayTestTile(TEST_NAME); // Make sure there is an account on resource that the provisioning has @@ -2433,8 +2551,8 @@ public void test163SearchWeaponCutlass() throws Exception { } @Test - public void test165SearchUidExact() throws Exception { - final String TEST_NAME = "test165SearchUidExact"; + public void test175SearchUidExact() throws Exception { + final String TEST_NAME = "test175SearchUidExact"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_UID, willIcfUid, null, true, @@ -2442,8 +2560,8 @@ public void test165SearchUidExact() throws Exception { } @Test - public void test166SearchUidExactNoFetch() throws Exception { - final String TEST_NAME = "test166SearchUidExactNoFetch"; + public void test176SearchUidExactNoFetch() throws Exception { + final String TEST_NAME = "test176SearchUidExactNoFetch"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, @@ -2451,8 +2569,8 @@ public void test166SearchUidExactNoFetch() throws Exception { } @Test - public void test167SearchIcfNameRepoized() throws Exception { - final String TEST_NAME = "test167SearchIcfNameRepoized"; + public void test177SearchIcfNameRepoized() throws Exception { + final String TEST_NAME = "test177SearchIcfNameRepoized"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_NAME, getWillRepoIcfName(), null, true, @@ -2460,8 +2578,8 @@ ConnectorFactoryIcfImpl.ICFS_NAME, getWillRepoIcfName(), null, true, } @Test - public void test167aSearchIcfNameRepoizedNoFetch() throws Exception { - final String TEST_NAME = "test167aSearchIcfNameRepoizedNoFetch"; + public void test180SearchIcfNameRepoizedNoFetch() throws Exception { + final String TEST_NAME = "test180SearchIcfNameRepoizedNoFetch"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_NAME, getWillRepoIcfName(), GetOperationOptions.createNoFetch(), false, @@ -2469,8 +2587,8 @@ public void test167aSearchIcfNameRepoizedNoFetch() throws Exception { } @Test - public void test168SearchIcfNameExact() throws Exception { - final String TEST_NAME = "test168SearchIcfNameExact"; + public void test181SearchIcfNameExact() throws Exception { + final String TEST_NAME = "test181SearchIcfNameExact"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), null, true, @@ -2478,8 +2596,8 @@ ConnectorFactoryIcfImpl.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNA } @Test - public void test168aSearchIcfNameExactNoFetch() throws Exception { - final String TEST_NAME = "test168aSearchIcfNameExactNoFetch"; + public void test182SearchIcfNameExactNoFetch() throws Exception { + final String TEST_NAME = "test182SearchIcfNameExactNoFetch"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), GetOperationOptions.createNoFetch(), false, @@ -2488,8 +2606,8 @@ public void test168aSearchIcfNameExactNoFetch() throws Exception { // TEMPORARY todo move to more appropriate place (model-intest?) @Test - public void test168bSearchIcfNameAndUidExactNoFetch() throws Exception { - final String TEST_NAME = "test168bSearchIcfNameAndUidExactNoFetch"; + public void test183SearchIcfNameAndUidExactNoFetch() throws Exception { + final String TEST_NAME = "test183SearchIcfNameAndUidExactNoFetch"; TestUtil.displayTestTile(TEST_NAME); testSeachIterativeAlternativeAttrFilter(TEST_NAME, ConnectorFactoryIcfImpl.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), ConnectorFactoryIcfImpl.ICFS_UID, willIcfUid, @@ -2499,8 +2617,8 @@ public void test168bSearchIcfNameAndUidExactNoFetch() throws Exception { @Test - public void test170SearchNone() throws Exception { - final String TEST_NAME = "test170SearchNone"; + public void test190SearchNone() throws Exception { + final String TEST_NAME = "test190SearchNone"; TestUtil.displayTestTile(TEST_NAME); ObjectFilter attrFilter = NoneFilter.createNone(); testSeachIterative(TEST_NAME, attrFilter, null, true, true, false); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummyNoActivation.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummyNoActivation.java index 88877cc4863..a8fc3815bb7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummyNoActivation.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummyNoActivation.java @@ -127,8 +127,13 @@ public void test150DisableAccount() throws Exception { } @Override - public void test151ActivationStatusUndefinedAccount() throws Exception { - final String TEST_NAME = "test151EnableAccount"; + public void test151SearchDisabledAccounts() throws Exception { + // N/A + } + + @Override + public void test152ActivationStatusUndefinedAccount() throws Exception { + final String TEST_NAME = "test152ActivationStatusUndefinedAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -171,8 +176,8 @@ public void test151ActivationStatusUndefinedAccount() throws Exception { @Test @Override - public void test151EnableAccount() throws Exception { - final String TEST_NAME = "test151EnableAccount"; + public void test154EnableAccount() throws Exception { + final String TEST_NAME = "test154EnableAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -213,10 +218,15 @@ public void test151EnableAccount() throws Exception { assertSteadyResource(); } + @Override + public void test155SearchDisabledAccounts() throws Exception { + // N/A + } + @Test @Override - public void test152SetValidFrom() throws Exception { - final String TEST_NAME = "test152SetValidFrom"; + public void test156SetValidFrom() throws Exception { + final String TEST_NAME = "test156SetValidFrom"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -261,8 +271,8 @@ public void test152SetValidFrom() throws Exception { @Test @Override - public void test153SetValidTo() throws Exception { - final String TEST_NAME = "test153SetValidTo"; + public void test157SetValidTo() throws Exception { + final String TEST_NAME = "test157SetValidTo"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -306,8 +316,8 @@ public void test153SetValidTo() throws Exception { } @Override - public void test154DeleteValidToValidFrom() throws Exception { - final String TEST_NAME = "test153SetValidTo"; + public void test158DeleteValidToValidFrom() throws Exception { + final String TEST_NAME = "test158DeleteValidToValidFrom"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -356,14 +366,19 @@ public void test154DeleteValidToValidFrom() throws Exception { @Test @Override - public void test155GetLockedoutAccount() throws Exception { + public void test159GetLockedoutAccount() throws Exception { // Not relevant } + @Override + public void test160SearchLockedAccounts() throws Exception { + // N/A + } + @Test @Override - public void test156UnlockAccount() throws Exception { - final String TEST_NAME = "test156UnlockAccount"; + public void test162UnlockAccount() throws Exception { + final String TEST_NAME = "test162UnlockAccount"; TestUtil.displayTestTile(TEST_NAME); // GIVEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java index 5b3eb682710..01d571770d5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java @@ -27,7 +27,10 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -59,7 +62,9 @@ import com.evolveum.midpoint.prism.Objectable; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; @@ -87,6 +92,7 @@ import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; @@ -910,6 +916,60 @@ public void test140AddAndModifyAccountJack() throws Exception { assertShadows(2); } + + @Test + public void test145ModifyAccountJackJpegPhoto() throws Exception { + final String TEST_NAME = "test145ModifyAccountJackJpegPhoto"; + TestUtil.displayTestTile(TEST_NAME); + + OperationResult result = new OperationResult(TestOpenDJ.class.getName() + + "." + TEST_NAME); + + byte[] bytesIn = Files.readAllBytes(Paths.get(ProvisioningTestUtil.DOT_JPG_FILENAME)); + display("Bytes in", MiscUtil.binaryToHex(bytesIn)); + + QName jpegPhotoQName = new QName(RESOURCE_OPENDJ_NS, "jpegPhoto"); + PropertyDelta jpegPhotoDelta = new PropertyDelta<>(new ItemPath(ShadowType.F_ATTRIBUTES, jpegPhotoQName), + null , prismContext); + jpegPhotoDelta.setValueToReplace(new PrismPropertyValue(bytesIn)); + + Collection modifications = MiscSchemaUtil.createCollection(jpegPhotoDelta); + + display("Modifications",modifications); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, + modifications, null, null, taskManager.createTaskInstance(), result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + SearchResultEntry entry = openDJController.searchByUid("rename"); + display("LDAP Entry", entry); + byte[] jpegPhotoLdap = OpenDJController.getAttributeValueBinary(entry, "jpegPhoto"); + assertNotNull("No jpegPhoto in LDAP entry", jpegPhotoLdap); + assertEquals("Byte length changed (LDAP)", bytesIn.length, jpegPhotoLdap.length); + assertTrue("Bytes do not match (LDAP)", Arrays.equals(bytesIn, jpegPhotoLdap)); + + PrismObject shadow = provisioningService.getObject(ShadowType.class, + ACCOUNT_JACK_OID, null, taskManager.createTaskInstance(), result); + + display("Object after change",shadow); + + PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); + PrismProperty jpegPhotoAttr = attributesContainer.findProperty(jpegPhotoQName); + byte[] bytesOut = jpegPhotoAttr.getValues().get(0).getValue(); + + display("Bytes out", MiscUtil.binaryToHex(bytesOut)); + + assertEquals("Byte length changed (shadow)", bytesIn.length, bytesOut.length); + assertTrue("Bytes do not match (shadow)", Arrays.equals(bytesIn, bytesOut)); + + assertShadows(2); + } @Test public void test150ChangePassword() throws Exception { diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java index 3bccd2d831a..4d88fc3276d 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java @@ -116,7 +116,7 @@ public class TestUcfDummy extends AbstractTestNGSpringContextTests { private static final String ACCOUNT_JACK_USERNAME = "jack"; private static final String ACCOUNT_JACK_FULLNAME = "Jack Sparrow"; - private ConnectorFactory manager; + private ConnectorFactory connectorFactory; private PrismObject resource; private ResourceType resourceType; private ConnectorType connectorType; @@ -145,7 +145,7 @@ public void setup() throws SchemaException, SAXException, IOException { dummyResourceCtl.extendSchemaPirate(); dummyResource = dummyResourceCtl.getDummyResource(); - manager = connectorFactoryIcfImpl; + connectorFactory = connectorFactoryIcfImpl; resource = PrismTestUtil.parseObject(new File(FILENAME_RESOURCE_DUMMY)); resourceType = resource.asObjectable(); @@ -207,7 +207,7 @@ public void test001ResourceSanity() throws ObjectNotFoundException, SchemaExcept public void test002ConnectorSchema() throws ObjectNotFoundException, SchemaException { TestUtil.displayTestTile("test002ConnectorSchema"); - ConnectorInstance cc = manager.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), + ConnectorInstance cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector"); assertNotNull("Failed to instantiate connector", cc); PrismSchema connectorSchema = cc.generateConnectorSchema(); @@ -233,16 +233,17 @@ public void test002ConnectorSchema() throws ObjectNotFoundException, SchemaExcep */ @Test public void test010ListConnectors() throws CommunicationException { - TestUtil.displayTestTile("test004ListConnectors"); + final String TEST_NAME = "test010ListConnectors"; + TestUtil.displayTestTile(TEST_NAME); - OperationResult result = new OperationResult(TestUcfDummy.class+".testListConnectors"); - Set listConnectors = manager.listConnectors(null, result); + OperationResult result = new OperationResult(TestUcfDummy.class+"."+TEST_NAME); + Set connectors = connectorFactory.listConnectors(null, result); System.out.println("---------------------------------------------------------------------"); - assertNotNull(listConnectors); - assertFalse(listConnectors.isEmpty()); + assertNotNull(connectors); + assertFalse(connectors.isEmpty()); - for (ConnectorType connector : listConnectors) { + for (ConnectorType connector : connectors) { assertNotNull(connector.getName()); System.out.println("CONNECTOR OID=" + connector.getOid() + ", name=" + connector.getName() + ", version=" + connector.getConnectorVersion()); @@ -253,6 +254,7 @@ public void test010ListConnectors() throws CommunicationException { System.out.println("---------------------------------------------------------------------"); + assertEquals("Unexpected number of connectors discovered", 5, connectors.size()); } @Test @@ -261,7 +263,7 @@ public void test020CreateConfiguredConnector() throws FileNotFoundException, JAX GenericFrameworkException, SchemaException, ConfigurationException { TestUtil.displayTestTile("test004CreateConfiguredConnector"); - ConnectorInstance cc = manager.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), + ConnectorInstance cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector"); assertNotNull("Failed to instantiate connector", cc); OperationResult result = new OperationResult(TestUcfDummy.class.getName() + ".testCreateConfiguredConnector"); @@ -283,7 +285,7 @@ public void test030ResourceSchema() throws ObjectNotFoundException, SchemaExcept OperationResult result = new OperationResult(TestUcfDummy.class+".test030ResourceSchema"); - cc = manager.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), + cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector"); assertNotNull("Failed to instantiate connector", cc); @@ -319,7 +321,7 @@ public void test030ResourceSchemaAccountObjectClass() throws ObjectNotFoundExcep OperationResult result = new OperationResult(TestUcfDummy.class+".test030ResourceSchema"); - cc = manager.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector"); + cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector"); assertNotNull("Failed to instantiate connector", cc); PrismContainerValue configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue(); diff --git a/provisioning/provisioning-impl/src/test/resources/dot.jpg b/provisioning/provisioning-impl/src/test/resources/dot.jpg new file mode 100644 index 00000000000..4150fc04e75 Binary files /dev/null and b/provisioning/provisioning-impl/src/test/resources/dot.jpg differ diff --git a/provisioning/provisioning-impl/src/test/resources/ucf/connector-ldap.xml b/provisioning/provisioning-impl/src/test/resources/ucf/connector-ldap.xml index 64ea07b8769..c56ec631772 100644 --- a/provisioning/provisioning-impl/src/test/resources/ucf/connector-ldap.xml +++ b/provisioning/provisioning-impl/src/test/resources/ucf/connector-ldap.xml @@ -23,7 +23,7 @@ ICF com.evolveum.polygon.connector.ldap.LdapConnector http://midpoint.evolveum.com/xml/ns/public/connector/icf-1 com.evolveum.polygon.connector.ldap.LdapConnector - 1.4.1.23 + 1.4.2.0-SNAPSHOT com.evolveum.polygon.connector-ldap http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector diff --git a/repo/audit-api/pom.xml b/repo/audit-api/pom.xml index 59eb6d9749b..47bafb5379a 100644 --- a/repo/audit-api/pom.xml +++ b/repo/audit-api/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,18 +35,18 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditEventRecord.java b/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditEventRecord.java index ae6975a5d64..44a4989884c 100644 --- a/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditEventRecord.java +++ b/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditEventRecord.java @@ -25,6 +25,7 @@ import com.evolveum.midpoint.prism.PrismReference; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.schema.DeltaConvertor; import com.evolveum.midpoint.schema.ObjectDeltaOperation; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; @@ -33,9 +34,11 @@ import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; @@ -300,17 +303,30 @@ public AuditEventRecordType createAuditEventRecordType(){ auditRecordType.setEventStage(AuditEventStage.fromAuditEventStage(eventStage)); auditRecordType.setEventType(AuditEventType.fromAuditEventType(eventType)); auditRecordType.setHostIdentifier(hostIdentifier); - auditRecordType.setInitiatorRef(ObjectTypeUtil.createObjectRef(initiator)); + auditRecordType.setInitiatorRef(ObjectTypeUtil.createObjectRef(initiator, true)); auditRecordType.setMessage(message); auditRecordType.setOutcome(OperationResultStatus.createStatusType(outcome)); auditRecordType.setParameter(parameter); auditRecordType.setResult(result); auditRecordType.setSessionIdentifier(sessionIdentifier); - auditRecordType.setTargetOwnerRef(ObjectTypeUtil.createObjectRef(targetOwner)); - auditRecordType.setTargetRef(ObjectTypeUtil.createObjectRef(target)); + auditRecordType.setTargetOwnerRef(ObjectTypeUtil.createObjectRef(targetOwner, true)); + auditRecordType.setTargetRef(ObjectTypeUtil.createObjectRef(target, true)); auditRecordType.setTaskIdentifier(taskIdentifier); auditRecordType.setTaskOID(taskOID); auditRecordType.setTimestamp(MiscUtil.asXMLGregorianCalendar(timestamp)); + for (ObjectDeltaOperation delta : deltas){ + try { + ObjectDeltaOperationType odo = new ObjectDeltaOperationType(); + odo.setObjectDelta(DeltaConvertor.toObjectDeltaType(delta.getObjectDelta())); + if (delta.getExecutionResult() != null){ + odo.setExecutionResult(delta.getExecutionResult().createOperationResultType()); + } + auditRecordType.getDelta().add(odo); + } catch (SchemaException e) { + continue; + } + } + return auditRecordType; } diff --git a/repo/audit-impl/pom.xml b/repo/audit-impl/pom.xml index 43f55527798..0dc046a6a19 100644 --- a/repo/audit-impl/pom.xml +++ b/repo/audit-impl/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,17 +35,17 @@ com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT commons-pool @@ -60,7 +60,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -76,13 +76,13 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -93,7 +93,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/pom.xml b/repo/pom.xml index 0747ae3ef2d..b32c835a399 100644 --- a/repo/pom.xml +++ b/repo/pom.xml @@ -22,7 +22,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/repo/repo-api/pom.xml b/repo/repo-api/pom.xml index 4c4279d5ae3..d843f01746a 100644 --- a/repo/repo-api/pom.xml +++ b/repo/repo-api/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,17 +35,17 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/repo-cache/pom.xml b/repo/repo-cache/pom.xml index aa43b19b4c6..337d111df7b 100644 --- a/repo/repo-cache/pom.xml +++ b/repo/repo-cache/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,22 +35,22 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra schema - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -61,7 +61,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index b4a79e8b2f8..820f6f24842 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -25,7 +25,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,12 +36,12 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.testng @@ -80,7 +80,7 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/repo-sql-impl/pom.xml b/repo/repo-sql-impl/pom.xml index 0d0caf14b38..406e0be9ab7 100644 --- a/repo/repo-sql-impl/pom.xml +++ b/repo/repo-sql-impl/pom.xml @@ -25,7 +25,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,17 +36,17 @@ com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -96,7 +96,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/repo-test-util/pom.xml b/repo/repo-test-util/pom.xml index ef79a8e335d..b9c11604105 100644 --- a/repo/repo-test-util/pom.xml +++ b/repo/repo-test-util/pom.xml @@ -23,7 +23,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -34,42 +34,42 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-sql-impl-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.testng @@ -78,12 +78,12 @@ com.evolveum.icf dummy-resource - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index dc386b637a4..143bec6c60e 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -1023,4 +1023,29 @@ protected void assertShadows(int expected, OperationResult result) throws Schema assertEquals("Unexpected number of (repository) shadows", expected, actual); } + protected void assertActivationAdministrativeStatus(PrismObject shadow, ActivationStatusType expectedStatus) { + ActivationType activationType = shadow.asObjectable().getActivation(); + if (activationType == null) { + if (expectedStatus == null) { + return; + } else { + AssertJUnit.fail("Expected activation administrative status of "+shadow+" to be "+expectedStatus+", but there was no activation administrative status"); + } + } else { + assertEquals("Wrong activation administrative status of "+shadow, expectedStatus, activationType.getAdministrativeStatus()); + } + } + + protected void assertLockout(PrismObject shadow, LockoutStatusType expectedStatus) { + ActivationType activationType = shadow.asObjectable().getActivation(); + if (activationType == null) { + if (expectedStatus == null) { + return; + } else { + AssertJUnit.fail("Expected lockout status of "+shadow+" to be "+expectedStatus+", but there was no lockout status"); + } + } else { + assertEquals("Wrong lockout status of "+shadow, expectedStatus, activationType.getLockoutStatus()); + } + } } diff --git a/repo/security-api/pom.xml b/repo/security-api/pom.xml index f4d4e7dc681..0cbc5cdddaf 100644 --- a/repo/security-api/pom.xml +++ b/repo/security-api/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,12 +35,12 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/security-impl/pom.xml b/repo/security-impl/pom.xml index 36b844020ab..b01d37ddefd 100644 --- a/repo/security-impl/pom.xml +++ b/repo/security-impl/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,17 +35,17 @@ com.evolveum.midpoint.repo security-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -56,7 +56,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -67,19 +67,19 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/system-init/pom.xml b/repo/system-init/pom.xml index 273c3c10547..e68ce340c41 100644 --- a/repo/system-init/pom.xml +++ b/repo/system-init/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -47,22 +47,22 @@ com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.apache.cxf @@ -74,7 +74,7 @@ com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -86,7 +86,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/task-api/pom.xml b/repo/task-api/pom.xml index a4dd2233ddd..072bbb5d603 100644 --- a/repo/task-api/pom.xml +++ b/repo/task-api/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,12 +35,12 @@ com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/task-quartz-impl/pom.xml b/repo/task-quartz-impl/pom.xml index b119f8c3e60..1cffdc89224 100644 --- a/repo/task-quartz-impl/pom.xml +++ b/repo/task-quartz-impl/pom.xml @@ -24,7 +24,7 @@ repo com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -35,22 +35,22 @@ com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-cache - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT commons-pool @@ -64,7 +64,7 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT provided @@ -76,7 +76,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -92,13 +92,13 @@ com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -134,7 +134,7 @@ com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -145,7 +145,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java index efd32334f85..60feeae1487 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java @@ -43,6 +43,9 @@ import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.TimeZone; + +import static com.evolveum.midpoint.test.IntegrationTestTools.display; /** * @author lazyman @@ -96,6 +99,7 @@ public void testTasksCleanup() throws Exception { // THEN List> tasks = repositoryService.searchObjects(TaskType.class, null, null, result); AssertJUnit.assertNotNull(tasks); + display("tasks", tasks); AssertJUnit.assertEquals(1, tasks.size()); PrismObject task = tasks.get(0); @@ -111,7 +115,7 @@ public void testTasksCleanup() throws Exception { } private Calendar create_2013_07_12_12_00_Calendar() { - Calendar calendar = Calendar.getInstance(); + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+2")); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.MAY); calendar.set(Calendar.DAY_OF_MONTH, 7); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java index 73b24fc7f4e..4e9bb0986d9 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java @@ -54,6 +54,7 @@ import org.quartz.JobKey; import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.Assert; @@ -100,6 +101,7 @@ "classpath:ctx-security.xml", "classpath:ctx-common.xml", "classpath:ctx-configuration-test.xml"}) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestQuartzTaskManagerContract extends AbstractTestNGSpringContextTests { private static final transient Trace LOGGER = TraceManager.getTrace(TestQuartzTaskManagerContract.class); diff --git a/repo/task-quartz-impl/testng.xml b/repo/task-quartz-impl/testng.xml index 9c01fbce6f4..6de4c934899 100644 --- a/repo/task-quartz-impl/testng.xml +++ b/repo/task-quartz-impl/testng.xml @@ -16,7 +16,7 @@ --> - + diff --git a/samples/model-client-sample/pom.xml b/samples/model-client-sample/pom.xml index 511c210bef3..34fbb4691f5 100644 --- a/samples/model-client-sample/pom.xml +++ b/samples/model-client-sample/pom.xml @@ -21,7 +21,7 @@ com.evolveum.midpoint.samples model-client-sample - 3.2-SNAPSHOT + 3.3-SNAPSHOT 1.7 @@ -144,7 +144,7 @@ com.evolveum.midpoint.model model-client - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.apache.cxf diff --git a/samples/pom.xml b/samples/pom.xml index bed60655906..959a627201c 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/samples/resources/edirectory/resource-ldap-edirectory.xml b/samples/resources/edirectory/resource-ldap-edirectory-legacy.xml similarity index 98% rename from samples/resources/edirectory/resource-ldap-edirectory.xml rename to samples/resources/edirectory/resource-ldap-edirectory-legacy.xml index 851ed270d98..770e7c83cf3 100644 --- a/samples/resources/edirectory/resource-ldap-edirectory.xml +++ b/samples/resources/edirectory/resource-ldap-edirectory-legacy.xml @@ -43,7 +43,7 @@ + xmlns:icfcldap="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap-legacy/org.identityconnectors.ldap.LdapConnector"> 3636 true deimos.lab.evolveum.com diff --git a/samples/samples-test/pom.xml b/samples/samples-test/pom.xml index ea27a504209..578b73e004b 100644 --- a/samples/samples-test/pom.xml +++ b/samples/samples-test/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -60,52 +60,52 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -117,7 +117,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -139,13 +139,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -156,7 +156,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/conntest/pom.xml b/testing/conntest/pom.xml index ed0a6d764c6..a53693e44ff 100644 --- a/testing/conntest/pom.xml +++ b/testing/conntest/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -60,57 +60,57 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.apache.directory.api api-all - 1.0.0-M29-SNAPSHOT + 1.0.0-M31-e1 @@ -122,7 +122,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -145,13 +145,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -162,7 +162,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java index 0685056853b..b5538d432a8 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java @@ -85,7 +85,7 @@ protected boolean isIdmAdminInteOrgPerson() { } @Override - public String getAttributeEntryIdName() { + public String getPrimaryIdentifierAttributeName() { return "nsUniqueId"; } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java new file mode 100644 index 00000000000..2d0bad918b9 --- /dev/null +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java @@ -0,0 +1,341 @@ +/** + * Copyright (c) 2015 Evolveum + * + * Licensed 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 com.evolveum.midpoint.testing.conntest; + +import static org.testng.AssertJUnit.assertNotNull; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; + +import java.io.File; + +import org.apache.directory.api.ldap.model.exception.LdapException; +import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.query.EqualFilter; +import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.SearchResultMetadata; +import com.evolveum.midpoint.schema.processor.ResourceAttribute; +import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; +import com.evolveum.midpoint.schema.util.ShadowUtil; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.util.MidPointTestConstants; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; + +/** + * @author semancik + * + */ +@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +public abstract class AbstractEDirTest extends AbstractLdapTest { + + protected static final String ACCOUNT_JACK_UID = "jack"; + protected static final int NUMBER_OF_ACCOUNTS = 5; + protected static final int LOCKOUT_EXPIRATION_SECONDS = 65; + + protected long jackLockoutTimestamp; + + + @Override + public String getStartSystemCommand() { + return null; + } + + @Override + public String getStopSystemCommand() { + return null; + } + + @Override + protected File getBaseDir() { + return new File(MidPointTestConstants.TEST_RESOURCES_DIR, "edir"); + } + + @Override + protected String getSyncTaskOid() { + return null; + } + + @Override + protected boolean useSsl() { + return true; + } + + @Override + protected String getLdapSuffix() { + return "o=example"; + } + + @Override + protected String getLdapBindDn() { + return "cn=admin,o=example"; + } + + @Override + protected String getLdapBindPassword() { + return "secret"; + } + + @Override + protected int getSearchSizeLimit() { + return -1; + } + + @Override + public String getPrimaryIdentifierAttributeName() { + return "GUID"; + } + + @Override + protected String getLdapGroupObjectClass() { + return "groupOfNames"; + } + + @Override + protected String getLdapGroupMemberAttribute() { + return "member"; + } + + @Test + public void test100SeachJackByLdapUid() throws Exception { + final String TEST_NAME = "test100SeachJackByLdapUid"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ResourceAttributeDefinition ldapUidAttrDef = accountObjectClassDefinition.findAttributeDefinition("uid"); + + ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); + + rememberConnectorOperationCount(); + rememberConnectorSimulatedPagingSearchCount(); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + + PrismObject shadow = shadows.get(0); + display("Shadow", shadow); + assertAccountShadow(shadow, toDn(ACCOUNT_JACK_UID)); + assertLockout(shadow, LockoutStatusType.NORMAL); + + assertConnectorOperationIncrement(2); + assertConnectorSimulatedPagingSearchIncrement(0); + + SearchResultMetadata metadata = shadows.getMetadata(); + if (metadata != null) { + assertFalse(metadata.isPartialResults()); + } + } + + @Test + public void test110JackLockout() throws Exception { + final String TEST_NAME = "test110JackLockout"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + makeBadLoginAttempt(ACCOUNT_JACK_UID); + makeBadLoginAttempt(ACCOUNT_JACK_UID); + makeBadLoginAttempt(ACCOUNT_JACK_UID); + makeBadLoginAttempt(ACCOUNT_JACK_UID); + + jackLockoutTimestamp = System.currentTimeMillis(); + + ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); + + rememberConnectorOperationCount(); + rememberConnectorSimulatedPagingSearchCount(); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + + PrismObject shadow = shadows.get(0); + display("Shadow", shadow); + assertAccountShadow(shadow, toDn(ACCOUNT_JACK_UID)); + assertLockout(shadow, LockoutStatusType.LOCKED); + + assertConnectorOperationIncrement(2); + assertConnectorSimulatedPagingSearchIncrement(0); + + SearchResultMetadata metadata = shadows.getMetadata(); + if (metadata != null) { + assertFalse(metadata.isPartialResults()); + } + } + + /** + * No paging. It should return all accounts. + */ + @Test + public void test150SeachAllAccounts() throws Exception { + final String TEST_NAME = "test150SeachAllAccounts"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); + + SearchResultList> searchResultList = doSearch(TEST_NAME, query, NUMBER_OF_ACCOUNTS, task, result); + + assertConnectorOperationIncrement(6); + assertConnectorSimulatedPagingSearchIncrement(0); + + SearchResultMetadata metadata = searchResultList.getMetadata(); + if (metadata != null) { + assertFalse(metadata.isPartialResults()); + } + } + + @Test + public void test190SeachLockedAccounts() throws Exception { + final String TEST_NAME = "test190SeachLockedAccounts"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); + ObjectQueryUtil.filterAnd(query.getFilter(), + EqualFilter.createEqual(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), getShadowDefinition(), LockoutStatusType.LOCKED)); + + SearchResultList> searchResultList = doSearch(TEST_NAME, query, 1, task, result); + + assertConnectorOperationIncrement(2); + assertConnectorSimulatedPagingSearchIncrement(0); + + PrismObject shadow = searchResultList.get(0); + display("Shadow", shadow); + assertAccountShadow(shadow, toDn(ACCOUNT_JACK_UID)); + assertLockout(shadow, LockoutStatusType.LOCKED); + + SearchResultMetadata metadata = searchResultList.getMetadata(); + if (metadata != null) { + assertFalse(metadata.isPartialResults()); + } + } + + // TODO: Search all locked accounts. Jack should be there. + + // TODO: test rename + + // Wait until the lockout of Jack expires, check status + @Test + public void test800JackLockoutExpires() throws Exception { + final String TEST_NAME = "test800JackLockoutExpires"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + long now = System.currentTimeMillis(); + long lockoutExpires = jackLockoutTimestamp + LOCKOUT_EXPIRATION_SECONDS*1000; + if (now < lockoutExpires) { + display("Sleeping for "+(lockoutExpires-now)+"ms (waiting for lockout expiration)"); + Thread.sleep(lockoutExpires-now); + } + now = System.currentTimeMillis(); + display("Time is now "+now); + + ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); + + rememberConnectorOperationCount(); + rememberConnectorSimulatedPagingSearchCount(); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + + PrismObject shadow = shadows.get(0); + display("Shadow", shadow); + assertAccountShadow(shadow, toDn(ACCOUNT_JACK_UID)); + assertLockout(shadow, LockoutStatusType.NORMAL); + + assertConnectorOperationIncrement(2); + assertConnectorSimulatedPagingSearchIncrement(0); + + SearchResultMetadata metadata = shadows.getMetadata(); + if (metadata != null) { + assertFalse(metadata.isPartialResults()); + } + } + + // TODO: Search all locked accounts. Jack should not be there. + + // TODO: lock out jack again, explicitly reset the lock, see that he can login + + @Override + protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { + super.assertAccountShadow(shadow, dn); + ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); + assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + String primaryId = primaryIdAttr.getRealValue(); + assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9]+")); + } + + private void makeBadLoginAttempt(String uid) throws LdapException { + LdapNetworkConnection conn = ldapConnect(toDn(uid), "thisIsAwRoNgPASSW0RD"); + if (conn.isAuthenticated()) { + AssertJUnit.fail("Bad authentication went good for "+uid); + } + } + +} diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java index 6d4c2dff33f..14f7f0599f3 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java @@ -127,22 +127,10 @@ */ @ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) -public abstract class AbstractLdapConnTest extends AbstractModelIntegrationTest { +public abstract class AbstractLdapConnTest extends AbstractLdapTest { private static final Trace LOGGER = TraceManager.getTrace(AbstractLdapConnTest.class); - - public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ldap"); - - public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); - public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); - - protected static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); - protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; - protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; - - protected static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); - protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; - + protected static final File USER_BARBOSSA_FILE = new File(COMMON_DIR, "user-barbossa.xml"); protected static final String USER_BARBOSSA_OID = "c0c010c0-d34d-b33f-f00d-111111111112"; protected static final String USER_BARBOSSA_USERNAME = "barbossa"; @@ -156,9 +144,7 @@ public abstract class AbstractLdapConnTest extends AbstractModelIntegrationTest private static final String USER_LECHUCK_NAME = "lechuck"; private static final String ACCOUNT_LECHUCK_NAME = "lechuck"; private static final String ACCOUNT_CHARLES_NAME = "charles"; - - private static final String LDAP_ACCOUNT_OBJECTCLASS = "inetOrgPerson"; - + private static final String LDAP_GROUP_PIRATES_DN = "cn=Pirates,ou=groups,dc=example,dc=com"; protected static final String ACCOUNT_IDM_DN = "uid=idm,ou=Administrators,dc=example,dc=com"; @@ -180,42 +166,12 @@ public abstract class AbstractLdapConnTest extends AbstractModelIntegrationTest private static final String GROUP_MONKEYS_CN = "monkeys"; private static final String GROUP_MONKEYS_DESCRIPTION = "Monkeys of Monkey Island"; - @Autowired(required = true) - protected MatchingRuleRegistry matchingRuleRegistry; - - protected ResourceType resourceType; - protected PrismObject resource; - - protected MatchingRule ciMatchingRule; - - private static String stopCommand; - - protected ObjectClassComplexTypeDefinition accountObjectClassDefinition; protected String account0Oid; protected String accountBarbossaOid; @Autowired protected ReconciliationTaskHandler reconciliationTaskHandler; - - @Override - protected void startResources() throws Exception { - super.startResources(); - - String command = getStartSystemCommand(); - if (command != null) { - TestUtil.execSystemCommand(command); - } - stopCommand = getStopSystemCommand(); - } - - public String getAttributeEntryIdName() { - return "entryUuid"; - } - public abstract String getStartSystemCommand(); - - public abstract String getStopSystemCommand(); - protected abstract void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException; protected boolean isIdmAdminInteOrgPerson() { @@ -225,166 +181,25 @@ protected boolean isIdmAdminInteOrgPerson() { protected boolean syncCanDetectDelete() { return true; } - - - @AfterClass - public static void stopResources() throws Exception { - //end profiling - ProfilingDataManager.getInstance().printMapAfterTest(); - ProfilingDataManager.getInstance().stopProfilingAfterTest(); - - if (stopCommand != null) { - TestUtil.execSystemCommand(stopCommand); - } - } - - protected abstract String getResourceOid(); - - protected abstract File getBaseDir(); protected File getResourceFile() { return new File(getBaseDir(), "resource.xml"); } - - protected File getSyncTaskFile() { - return new File(getBaseDir(), "task-sync.xml"); - } - - protected File getSyncTaskInetOrgPersonFile() { - return new File(getBaseDir(), "task-sync-inetorgperson.xml"); - } - - protected abstract String getSyncTaskOid(); - - protected QName getAccountObjectClass() { - return new QName(MidPointConstants.NS_RI, "inetOrgPerson"); - } - - - protected abstract String getLdapServerHost(); - - protected abstract int getLdapServerPort(); - - protected abstract String getLdapBindDn(); - - protected abstract String getLdapBindPassword(); - - protected abstract int getSearchSizeLimit(); - - protected String getLdapSuffix() { - return "dc=example,dc=com"; - } - - protected String getPeopleLdapSuffix() { - return "ou=people,"+getLdapSuffix(); - } - - protected String getGroupsLdapSuffix() { - return "ou=groups,"+getLdapSuffix(); - } - - protected abstract String getLdapGroupObjectClass(); - - protected abstract String getLdapGroupMemberAttribute(); - - protected String getScriptDirectoryName() { - return "/opt/Bamboo/local/conntest"; - } - + protected abstract String getAccount0Cn(); @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - // System Configuration - PrismObject config; - try { - config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, SystemConfigurationType.class, initResult); - } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + - "looks like the previous test haven't cleaned it up", e); - } - - modelService.postInit(initResult); - - // to get profiling facilities (until better API is available) -// LoggingConfigurationManager.configure( -// ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), -// config.asObjectable().getVersion(), initResult); - - // administrator - PrismObject userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult); - repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult); - login(userAdministrator); - // Users repoAddObjectFromFile(USER_BARBOSSA_FILE, UserType.class, initResult); repoAddObjectFromFile(USER_GUYBRUSH_FILE, UserType.class, initResult); // Roles - // Resources - resource = importAndGetObjectFromFile(ResourceType.class, getResourceFile(), getResourceOid(), initTask, initResult); - resourceType = resource.asObjectable(); - - assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - - //initProfiling - start - ProfilingDataManager profilingManager = ProfilingDataManager.getInstance(); - - Map subsystems = new HashMap<>(); - subsystems.put(ProfilingDataManager.Subsystem.MODEL, true); - subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true); - profilingManager.configureProfilingDataManagerForTest(subsystems, true); - - profilingManager.appendProfilingToTest(); - //initProfiling - end - - ciMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING); } - - @Test - public void test010Connection() throws Exception { - final String TEST_NAME = "test010Connection"; - TestUtil.displayTestTile(TEST_NAME); - - OperationResult result = new OperationResult(this.getClass().getName()+"."+TEST_NAME); - - OperationResult operationResult = provisioningService.testResource(getResourceOid()); - display("Test connection result",operationResult); - TestUtil.assertSuccess("Test connection failed",operationResult); - } - - @Test - public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - TestUtil.displayTestTile(this, TEST_NAME); - - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); - OperationResult result = task.getResult(); - - RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); - accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(getAccountObjectClass()); - assertNotNull("No definition for object class "+getAccountObjectClass(), accountObjectClassDefinition); - - ResourceAttributeDefinition cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); - PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, -1); - assertTrue("createTimestampDef read", cnDef.canRead()); - assertTrue("createTimestampDef read", cnDef.canModify()); - assertTrue("createTimestampDef read", cnDef.canAdd()); - - ResourceAttributeDefinition createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimestamp"); - PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimestamp"), - DOMUtil.XSD_LONG, 0, 1); - assertTrue("createTimestampDef read", createTimestampDef.canRead()); - assertFalse("createTimestampDef read", createTimestampDef.canModify()); - assertFalse("createTimestampDef read", createTimestampDef.canAdd()); - - } - @Test public void test100SeachAccount0ByLdapUid() throws Exception { final String TEST_NAME = "test100SeachAccount0ByLdapUid"; @@ -396,10 +211,7 @@ public void test100SeachAccount0ByLdapUid() throws Exception { ResourceAttributeDefinition ldapUidAttrDef = accountObjectClassDefinition.findAttributeDefinition("uid"); - ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - ObjectFilter additionalFilter = EqualFilter.createEqual( - new ItemPath(ShadowType.F_ATTRIBUTES, ldapUidAttrDef.getName()), ldapUidAttrDef, ACCOUNT_0_UID); - ObjectQueryUtil.filterAnd(query.getFilter(), additionalFilter); + ObjectQuery query = createUidQuery(ACCOUNT_0_UID); rememberConnectorOperationCount(); rememberConnectorSimulatedPagingSearchCount(); @@ -693,52 +505,7 @@ public void test190SeachAllAccountsSizelimit() throws Exception { } // TODO: scoped search - - private SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - return doSearch(TEST_NAME, query, null, expectedSize, task, result); - } - - private SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, GetOperationOptions rootOptions, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - final List> foundObjects = new ArrayList>(expectedSize); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { -// LOGGER.trace("Found {}", object); - String name = object.asObjectable().getName().getOrig(); - for(PrismObject foundShadow: foundObjects) { - if (foundShadow.asObjectable().getName().getOrig().equals(name)) { - AssertJUnit.fail("Duplicate name "+name); - } - } - foundObjects.add(object); - return true; - } - }; - - Collection> options = null; - if (rootOptions != null) { - options = SelectorOptions.createCollection(rootOptions); - } - - rememberConnectorOperationCount(); - rememberConnectorSimulatedPagingSearchCount(); - - // WHEN - TestUtil.displayWhen(TEST_NAME); - SearchResultMetadata searchResultMetadata = modelService.searchObjectsIterative(ShadowType.class, query, handler, options, task, result); - - // THEN - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertEquals("Unexpected number of accounts", expectedSize, foundObjects.size()); - - SearchResultList> resultList = new SearchResultList<>(foundObjects, searchResultMetadata); - - return resultList; - } - // TODO: count shadows @Test @@ -774,7 +541,7 @@ public void test200AssignAccountToBarbossa() throws Exception { String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); - assertEquals("Wrong ICFS UID", entry.get(getAttributeEntryIdName()).getString(), accountBarbossaIcfUid); + assertEquals("Wrong ICFS UID", entry.get(getPrimaryIdentifierAttributeName()).getString(), accountBarbossaIcfUid); assertLdapPassword(USER_BARBOSSA_USERNAME, "deadjacktellnotales"); @@ -1333,151 +1100,4 @@ public void test839DeleteSyncTask() throws Exception { assertNoObject(TaskType.class, getSyncTaskOid(), task, result); } - protected Entry getLdapAccountByUid(String uid) throws LdapException, IOException, CursorException { - LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(uid="+uid+")"); - ldapDisconnect(connection); - - assertEquals("Unexpected number of entries for uid="+uid+": "+entries, 1, entries.size()); - Entry entry = entries.get(0); - - return entry; - } - - protected Entry assertLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException { - Entry entry = getLdapAccountByUid(uid); - assertAttribute(entry, "cn", cn); - return entry; - } - - protected void assertAttribute(Entry entry, String attrName, String expectedValue) throws LdapInvalidAttributeValueException { - String dn = entry.getDn().toString(); - Attribute ldapAttribute = entry.get(attrName); - if (ldapAttribute == null) { - if (expectedValue == null) { - return; - } else { - AssertJUnit.fail("No attribute "+attrName+" in "+dn+", expected: "+expectedValue); - } - } else { - assertEquals("Wrong attribute "+attrName+" in "+dn, expectedValue, ldapAttribute.getString()); - } - } - - protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { - LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(uid="+uid+")"); - ldapDisconnect(connection); - - assertEquals("Unexpected number of entries for uid="+uid+": "+entries, 0, entries.size()); - } - - protected List ldapSearch(LdapNetworkConnection connection, String filter) throws LdapException, CursorException { - return ldapSearch(connection, getLdapSuffix(), filter, SearchScope.SUBTREE, "*", getAttributeEntryIdName()); - } - - protected List ldapSearch(LdapNetworkConnection connection, String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException, CursorException { - List entries = new ArrayList(); - EntryCursor entryCursor = connection.search( baseDn, filter, scope, attributes ); - Entry entry = null; - while (entryCursor.next()) { - entries.add(entryCursor.get()); - } - return entries; - } - - protected void assertLdapPassword(String uid, String password) throws LdapException, IOException, CursorException { - Entry entry = getLdapAccountByUid(uid); - LdapNetworkConnection conn = ldapConnect(entry.getDn().toString(), password); - assertTrue("Not connected", conn.isConnected()); - assertTrue("Not authenticated", conn.isAuthenticated()); - } - - protected Entry addLdapAccount(String uid, String cn, String givenName, String sn) throws LdapException, IOException, CursorException { - LdapNetworkConnection connection = ldapConnect(); - Entry entry = createAccountEntry(uid, cn, givenName, sn); - connection.add(entry); - display("Added LDAP account:"+entry); - ldapDisconnect(connection); - return entry; - } - - protected Entry createAccountEntry(String uid, String cn, String givenName, String sn) throws LdapException { - Entry entry = new DefaultEntry(toDn(uid), - "objectclass", LDAP_ACCOUNT_OBJECTCLASS, - "uid", uid, - "cn", cn, - "givenName", givenName, - "sn", sn); - return entry; - } - - protected Entry addLdapGroup(String cn, String description, String memberDn) throws LdapException, IOException, CursorException { - LdapNetworkConnection connection = ldapConnect(); - Entry entry = createGroupEntry(cn, description, memberDn); - connection.add(entry); - display("Added LDAP group:"+entry); - ldapDisconnect(connection); - return entry; - } - - protected Entry createGroupEntry(String cn, String description, String memberDn) throws LdapException { - Entry entry = new DefaultEntry(toGroupDn(cn), - "objectclass", getLdapGroupObjectClass(), - "cn", cn, - "description", description, - getLdapGroupMemberAttribute(), memberDn); - return entry; - } - - protected void deleteLdapEntry(String dn) throws LdapException, IOException { - LdapNetworkConnection connection = ldapConnect(); - connection.delete(dn); - display("Deleted LDAP entry: "+dn); - ldapDisconnect(connection); - } - - protected String toDn(String username) { - return "uid="+username+","+getPeopleLdapSuffix(); - } - - protected String toGroupDn(String cn) { - return "cn="+cn+","+getGroupsLdapSuffix(); - } - - protected LdapNetworkConnection ldapConnect() throws LdapException { - return ldapConnect(getLdapBindDn(), getLdapBindPassword()); - } - - protected LdapNetworkConnection ldapConnect(String bindDn, String bindPassword) throws LdapException { - LdapConnectionConfig config = new LdapConnectionConfig(); - config.setLdapHost(getLdapServerHost()); - config.setLdapPort(getLdapServerPort()); - LdapNetworkConnection connection = new LdapNetworkConnection(config); - boolean connected = connection.connect(); - if (!connected) { - AssertJUnit.fail("Cannot connect to LDAP server "+getLdapServerHost()+":"+getLdapServerPort()); - } - BindRequest bindRequest = new BindRequestImpl(); - bindRequest.setDn(new Dn(bindDn)); - bindRequest.setCredentials(bindPassword); - BindResponse bindResponse = connection.bind(bindRequest); - return connection; - } - - protected void ldapDisconnect(LdapNetworkConnection connection) throws IOException { - connection.close(); - } - - protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { - assertShadowCommon(shadow, null, dn, resourceType, getAccountObjectClass(), ciMatchingRule); - } - - protected long roundTsDown(long ts) { - return (((long)(ts/1000))*1000); - } - - protected long roundTsUp(long ts) { - return (((long)(ts/1000))*1000)+1; - } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java new file mode 100644 index 00000000000..359c1f638b7 --- /dev/null +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java @@ -0,0 +1,566 @@ +package com.evolveum.midpoint.testing.conntest; +/* + * Copyright (c) 2010-2015 Evolveum + * + * Licensed 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. + */ + + +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.assertNotNull; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.Holder; +import com.evolveum.midpoint.util.aspect.ProfilingDataManager; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; +import org.apache.commons.lang.mutable.MutableInt; +import org.apache.directory.api.ldap.model.cursor.CursorException; +import org.apache.directory.api.ldap.model.cursor.EntryCursor; +import org.apache.directory.api.ldap.model.entry.Attribute; +import org.apache.directory.api.ldap.model.entry.DefaultEntry; +import org.apache.directory.api.ldap.model.entry.DefaultModification; +import org.apache.directory.api.ldap.model.entry.Entry; +import org.apache.directory.api.ldap.model.entry.Modification; +import org.apache.directory.api.ldap.model.entry.ModificationOperation; +import org.apache.directory.api.ldap.model.exception.LdapException; +import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; +import org.apache.directory.api.ldap.model.message.BindRequest; +import org.apache.directory.api.ldap.model.message.BindRequestImpl; +import org.apache.directory.api.ldap.model.message.BindResponse; +import org.apache.directory.api.ldap.model.message.ModifyDnRequest; +import org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl; +import org.apache.directory.api.ldap.model.message.ModifyDnResponse; +import org.apache.directory.api.ldap.model.message.SearchScope; +import org.apache.directory.api.ldap.model.name.Dn; +import org.apache.directory.api.ldap.model.name.Rdn; +import org.apache.directory.ldap.client.api.LdapConnectionConfig; +import org.apache.directory.ldap.client.api.LdapNetworkConnection; + +import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.match.MatchingRule; +import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; +import com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.query.EqualFilter; +import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectPaging; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.ResultHandler; +import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.SearchResultMetadata; +import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; +import com.evolveum.midpoint.schema.processor.ResourceAttribute; +import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; +import com.evolveum.midpoint.schema.util.SchemaTestConstants; +import com.evolveum.midpoint.schema.util.ShadowUtil; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.util.MidPointTestConstants; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; + +/** + * @author Radovan Semancik + * + */ +@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +public abstract class AbstractLdapTest extends AbstractModelIntegrationTest { + + private static final Trace LOGGER = TraceManager.getTrace(AbstractLdapTest.class); + + public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); + public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); + + protected static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); + protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; + protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; + + protected static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); + protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; + + private static final String LDAP_ACCOUNT_OBJECTCLASS = "inetOrgPerson"; + + @Autowired(required = true) + protected MatchingRuleRegistry matchingRuleRegistry; + + @Autowired + protected ReconciliationTaskHandler reconciliationTaskHandler; + + protected ResourceType resourceType; + protected PrismObject resource; + + protected MatchingRule ciMatchingRule; + + private static String stopCommand; + + protected ObjectClassComplexTypeDefinition accountObjectClassDefinition; + + @Override + protected void startResources() throws Exception { + super.startResources(); + + String command = getStartSystemCommand(); + if (command != null) { + TestUtil.execSystemCommand(command); + } + stopCommand = getStopSystemCommand(); + } + + + public abstract String getStartSystemCommand(); + + public abstract String getStopSystemCommand(); + + @AfterClass + public static void stopResources() throws Exception { + //end profiling + ProfilingDataManager.getInstance().printMapAfterTest(); + ProfilingDataManager.getInstance().stopProfilingAfterTest(); + + if (stopCommand != null) { + TestUtil.execSystemCommand(stopCommand); + } + } + + protected abstract String getResourceOid(); + + protected abstract File getBaseDir(); + + protected File getResourceFile() { + return new File(getBaseDir(), "resource.xml"); + } + + protected File getSyncTaskFile() { + return new File(getBaseDir(), "task-sync.xml"); + } + + protected File getSyncTaskInetOrgPersonFile() { + return new File(getBaseDir(), "task-sync-inetorgperson.xml"); + } + + protected abstract String getSyncTaskOid(); + + protected QName getAccountObjectClass() { + return new QName(MidPointConstants.NS_RI, LDAP_ACCOUNT_OBJECTCLASS); + } + + protected abstract String getLdapServerHost(); + + protected abstract int getLdapServerPort(); + + protected boolean useSsl() { + return false; + } + + protected abstract String getLdapBindDn(); + + protected abstract String getLdapBindPassword(); + + protected abstract int getSearchSizeLimit(); + + protected String getLdapSuffix() { + return "dc=example,dc=com"; + } + + protected String getPeopleLdapSuffix() { + return "ou=people,"+getLdapSuffix(); + } + + protected String getGroupsLdapSuffix() { + return "ou=groups,"+getLdapSuffix(); + } + + public String getPrimaryIdentifierAttributeName() { + return "entryUuid"; + } + + public QName getPrimaryIdentifierAttributeQName() { + return new QName(MidPointConstants.NS_RI,getPrimaryIdentifierAttributeName()); + } + + protected abstract String getLdapGroupObjectClass(); + + protected abstract String getLdapGroupMemberAttribute(); + + protected String getScriptDirectoryName() { + return "/opt/Bamboo/local/conntest"; + } + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + super.initSystem(initTask, initResult); + + // System Configuration + PrismObject config; + try { + config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, SystemConfigurationType.class, initResult); + } catch (ObjectAlreadyExistsException e) { + throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + + "looks like the previous test haven't cleaned it up", e); + } + + modelService.postInit(initResult); + + // to get profiling facilities (until better API is available) +// LoggingConfigurationManager.configure( +// ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), +// config.asObjectable().getVersion(), initResult); + + // administrator + PrismObject userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult); + repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult); + login(userAdministrator); + + // Roles + + // Resources + resource = importAndGetObjectFromFile(ResourceType.class, getResourceFile(), getResourceOid(), initTask, initResult); + resourceType = resource.asObjectable(); + + assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); + + //initProfiling - start + ProfilingDataManager profilingManager = ProfilingDataManager.getInstance(); + + Map subsystems = new HashMap<>(); + subsystems.put(ProfilingDataManager.Subsystem.MODEL, true); + subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true); + profilingManager.configureProfilingDataManagerForTest(subsystems, true); + + profilingManager.appendProfilingToTest(); + //initProfiling - end + + ciMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING); + } + + @Test + public void test010Connection() throws Exception { + final String TEST_NAME = "test010Connection"; + TestUtil.displayTestTile(TEST_NAME); + + OperationResult result = new OperationResult(this.getClass().getName()+"."+TEST_NAME); + + OperationResult operationResult = provisioningService.testResource(getResourceOid()); + + display("Test connection result",operationResult); + TestUtil.assertSuccess("Test connection failed",operationResult); + } + + @Test + public void test020Schema() throws Exception { + final String TEST_NAME = "test020Schema"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); + accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(getAccountObjectClass()); + assertNotNull("No definition for object class "+getAccountObjectClass(), accountObjectClassDefinition); + display("Account object class def", accountObjectClassDefinition); + + ResourceAttributeDefinition cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); + PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, -1); + assertTrue("createTimestampDef read", cnDef.canRead()); + assertTrue("createTimestampDef read", cnDef.canModify()); + assertTrue("createTimestampDef read", cnDef.canAdd()); + + ResourceAttributeDefinition createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimestamp"); + PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimestamp"), + DOMUtil.XSD_LONG, 0, 1); + assertTrue("createTimestampDef read", createTimestampDef.canRead()); + assertFalse("createTimestampDef read", createTimestampDef.canModify()); + assertFalse("createTimestampDef read", createTimestampDef.canAdd()); + + } + + protected ObjectFilter createAttributeFilter(String attrName, T attrVal) throws SchemaException { + ResourceAttributeDefinition ldapUidAttrDef = accountObjectClassDefinition.findAttributeDefinition(attrName); + return EqualFilter.createEqual( + new ItemPath(ShadowType.F_ATTRIBUTES, ldapUidAttrDef.getName()), ldapUidAttrDef, attrVal); + } + + protected ObjectQuery createUidQuery(String uid) throws SchemaException { + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); + ObjectQueryUtil.filterAnd(query.getFilter(), createAttributeFilter("uid", uid)); + return query; + } + + protected SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + return doSearch(TEST_NAME, query, null, expectedSize, task, result); + } + + protected SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, GetOperationOptions rootOptions, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + final List> foundObjects = new ArrayList>(expectedSize); + ResultHandler handler = new ResultHandler() { + @Override + public boolean handle(PrismObject object, OperationResult parentResult) { +// LOGGER.trace("Found {}", object); + String name = object.asObjectable().getName().getOrig(); + for(PrismObject foundShadow: foundObjects) { + if (foundShadow.asObjectable().getName().getOrig().equals(name)) { + AssertJUnit.fail("Duplicate name "+name); + } + } + foundObjects.add(object); + return true; + } + }; + + Collection> options = null; + if (rootOptions != null) { + options = SelectorOptions.createCollection(rootOptions); + } + + rememberConnectorOperationCount(); + rememberConnectorSimulatedPagingSearchCount(); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultMetadata searchResultMetadata = modelService.searchObjectsIterative(ShadowType.class, query, handler, options, task, result); + + // THEN + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Unexpected number of accounts", expectedSize, foundObjects.size()); + + SearchResultList> resultList = new SearchResultList<>(foundObjects, searchResultMetadata); + + return resultList; + } + + protected Entry getLdapAccountByUid(String uid) throws LdapException, IOException, CursorException { + LdapNetworkConnection connection = ldapConnect(); + List entries = ldapSearch(connection, "(uid="+uid+")"); + ldapDisconnect(connection); + + assertEquals("Unexpected number of entries for uid="+uid+": "+entries, 1, entries.size()); + Entry entry = entries.get(0); + + return entry; + } + + protected Entry assertLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException { + Entry entry = getLdapAccountByUid(uid); + assertAttribute(entry, "cn", cn); + return entry; + } + + protected void assertAttribute(Entry entry, String attrName, String expectedValue) throws LdapInvalidAttributeValueException { + String dn = entry.getDn().toString(); + Attribute ldapAttribute = entry.get(attrName); + if (ldapAttribute == null) { + if (expectedValue == null) { + return; + } else { + AssertJUnit.fail("No attribute "+attrName+" in "+dn+", expected: "+expectedValue); + } + } else { + assertEquals("Wrong attribute "+attrName+" in "+dn, expectedValue, ldapAttribute.getString()); + } + } + + protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { + LdapNetworkConnection connection = ldapConnect(); + List entries = ldapSearch(connection, "(uid="+uid+")"); + ldapDisconnect(connection); + + assertEquals("Unexpected number of entries for uid="+uid+": "+entries, 0, entries.size()); + } + + protected List ldapSearch(LdapNetworkConnection connection, String filter) throws LdapException, CursorException { + return ldapSearch(connection, getLdapSuffix(), filter, SearchScope.SUBTREE, "*", getPrimaryIdentifierAttributeName()); + } + + protected List ldapSearch(LdapNetworkConnection connection, String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException, CursorException { + List entries = new ArrayList(); + EntryCursor entryCursor = connection.search( baseDn, filter, scope, attributes ); + Entry entry = null; + while (entryCursor.next()) { + entries.add(entryCursor.get()); + } + return entries; + } + + protected void assertLdapPassword(String uid, String password) throws LdapException, IOException, CursorException { + Entry entry = getLdapAccountByUid(uid); + LdapNetworkConnection conn = ldapConnect(entry.getDn().toString(), password); + assertTrue("Not connected", conn.isConnected()); + assertTrue("Not authenticated", conn.isAuthenticated()); + } + + protected Entry addLdapAccount(String uid, String cn, String givenName, String sn) throws LdapException, IOException, CursorException { + LdapNetworkConnection connection = ldapConnect(); + Entry entry = createAccountEntry(uid, cn, givenName, sn); + connection.add(entry); + display("Added LDAP account:"+entry); + ldapDisconnect(connection); + return entry; + } + + protected Entry createAccountEntry(String uid, String cn, String givenName, String sn) throws LdapException { + Entry entry = new DefaultEntry(toDn(uid), + "objectclass", LDAP_ACCOUNT_OBJECTCLASS, + "uid", uid, + "cn", cn, + "givenName", givenName, + "sn", sn); + return entry; + } + + protected Entry addLdapGroup(String cn, String description, String memberDn) throws LdapException, IOException, CursorException { + LdapNetworkConnection connection = ldapConnect(); + Entry entry = createGroupEntry(cn, description, memberDn); + connection.add(entry); + display("Added LDAP group:"+entry); + ldapDisconnect(connection); + return entry; + } + + protected Entry createGroupEntry(String cn, String description, String memberDn) throws LdapException { + Entry entry = new DefaultEntry(toGroupDn(cn), + "objectclass", getLdapGroupObjectClass(), + "cn", cn, + "description", description, + getLdapGroupMemberAttribute(), memberDn); + return entry; + } + + protected void deleteLdapEntry(String dn) throws LdapException, IOException { + LdapNetworkConnection connection = ldapConnect(); + connection.delete(dn); + display("Deleted LDAP entry: "+dn); + ldapDisconnect(connection); + } + + protected String toDn(String username) { + return "uid="+username+","+getPeopleLdapSuffix(); + } + + protected String toGroupDn(String cn) { + return "cn="+cn+","+getGroupsLdapSuffix(); + } + + protected LdapNetworkConnection ldapConnect() throws LdapException { + return ldapConnect(getLdapBindDn(), getLdapBindPassword()); + } + + protected LdapNetworkConnection ldapConnect(String bindDn, String bindPassword) throws LdapException { + LdapConnectionConfig config = new LdapConnectionConfig(); + config.setLdapHost(getLdapServerHost()); + config.setLdapPort(getLdapServerPort()); + + if (useSsl()) { + config.setUseSsl(true); + TrustManager trustManager = new X509TrustManager() { + public void checkClientTrusted(X509Certificate[] chain, String authType) + throws CertificateException { + + } + public void checkServerTrusted(X509Certificate[] chain, String authType) + throws CertificateException { + } + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + }; + config.setTrustManagers(trustManager); + } + + LdapNetworkConnection connection = new LdapNetworkConnection(config); + boolean connected = connection.connect(); + if (!connected) { + AssertJUnit.fail("Cannot connect to LDAP server "+getLdapServerHost()+":"+getLdapServerPort()); + } + BindRequest bindRequest = new BindRequestImpl(); + bindRequest.setDn(new Dn(bindDn)); + bindRequest.setCredentials(bindPassword); + BindResponse bindResponse = connection.bind(bindRequest); + return connection; + } + + protected void ldapDisconnect(LdapNetworkConnection connection) throws IOException { + connection.close(); + } + + protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { + assertShadowCommon(shadow, null, dn, resourceType, getAccountObjectClass(), ciMatchingRule); + } + + protected long roundTsDown(long ts) { + return (((long)(ts/1000))*1000); + } + + protected long roundTsUp(long ts) { + return (((long)(ts/1000))*1000)+1; + } +} diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java new file mode 100644 index 00000000000..d77099a4ee1 --- /dev/null +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2015 Evolveum + * + * Licensed 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 com.evolveum.midpoint.testing.conntest; + +import java.io.File; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.Listeners; + +import com.evolveum.midpoint.test.util.MidPointTestConstants; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; + +/** + * @author semancik + * + */ +public class TestEDirAthena extends AbstractEDirTest { + + @Override + protected String getResourceOid() { + return "0893372c-3c42-11e5-9179-001e8c717e5b"; + } + + @Override + protected File getResourceFile() { + return new File(getBaseDir(), "resource-athena.xml"); + } + + @Override + protected String getLdapServerHost() { + return "athena.evolveum.com"; + } + + @Override + protected int getLdapServerPort() { + return 33636; + } + +} diff --git a/testing/conntest/src/test/resources/edir/resource-athena.xml b/testing/conntest/src/test/resources/edir/resource-athena.xml new file mode 100644 index 00000000000..554c8766448 --- /dev/null +++ b/testing/conntest/src/test/resources/edir/resource-athena.xml @@ -0,0 +1,251 @@ + + + + + + + + eDirectory deimos/athena + + Novell/NetIQ eDirectory + + + + + c:connectorType + com.evolveum.polygon.connector.ldap.edirectory.EDirectoryLdapConnector + + + + + + + 33636 + athena.evolveum.com + ssl + o=example + cn=admin,o=example + + secret + + createTimestamp + + + + false + false + false + + + + + + + account + Default Account + true + ri:inetOrgPerson + + dn + Distinguished Name + + 0 + + mr:distinguishedName + + + $user/name + + + + + + + + ri:cn + + 0 + + + + fullName + + + + + ri:sn + + 0 + + + + familyName + + + + + ri:givenName + + + givenName + + + + + ri:uid + mr:stringIgnoreCase + + weak + + name + + + + + + ri:mail + + + emailAddress + + + + + ri:telephoneNumber + + + telephoneNumber + + + + + + ri:group + LDAP Group Membership + entitlement + ldapGroup + objectToSubject + ri:member + ri:dn + + + + + + attributes/dn + + cn=admin,o=example + + + + + + + + + + + weak + + + + + + + + + + + + + + + + + + + + + entitlement + ldapGroup + LDAP Group + ri:groupOfNames + + dn + mr:distinguishedName + + + $focus/name + + + + + + + + ri:cn + mr:stringIgnoreCase + + weak + + $focus/name + + + + + ri:description + + + description + + + + + + + + + + diff --git a/testing/conntest/src/test/resources/truststore.jks b/testing/conntest/src/test/resources/truststore.jks new file mode 100644 index 00000000000..4d49dba3118 Binary files /dev/null and b/testing/conntest/src/test/resources/truststore.jks differ diff --git a/testing/conntest/testng.xml b/testing/conntest/testng.xml index bb263414835..cb1e58670f0 100644 --- a/testing/conntest/testng.xml +++ b/testing/conntest/testng.xml @@ -1,6 +1,6 @@ + + + diff --git a/testing/consistency-mechanism/pom.xml b/testing/consistency-mechanism/pom.xml index 78b34ac433d..00c02752cfc 100644 --- a/testing/consistency-mechanism/pom.xml +++ b/testing/consistency-mechanism/pom.xml @@ -22,7 +22,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -59,47 +59,47 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -111,7 +111,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -133,19 +133,19 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -156,7 +156,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/longtest/pom.xml b/testing/longtest/pom.xml index 292afb64432..e9505ed951e 100644 --- a/testing/longtest/pom.xml +++ b/testing/longtest/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -60,52 +60,52 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -117,7 +117,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -140,13 +140,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -157,7 +157,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/minipoint/pom.xml b/testing/minipoint/pom.xml index 9eecc5c1120..e7c71f7729c 100644 --- a/testing/minipoint/pom.xml +++ b/testing/minipoint/pom.xml @@ -26,7 +26,7 @@ minipoint com.evolveum.midpoint.testing - 3.2-SNAPSHOT + 3.3-SNAPSHOT midPoint Testing - MiniPoint Atlassian JIRA @@ -38,7 +38,7 @@ https://fisheye.evolveum.com/browse/midPoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT 6.8.8 1.4.0.49 @@ -78,7 +78,7 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra @@ -137,7 +137,7 @@ com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.polygon @@ -152,12 +152,12 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.slf4j diff --git a/testing/pom.xml b/testing/pom.xml index 6780a3390f2..cb5808bb606 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -24,7 +24,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/testing/rest/pom.xml b/testing/rest/pom.xml index 702e892ee30..32ea87c0882 100644 --- a/testing/rest/pom.xml +++ b/testing/rest/pom.xml @@ -20,7 +20,7 @@ com.evolveum.midpoint parent - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml rest @@ -43,47 +43,47 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -95,13 +95,13 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -123,19 +123,19 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -146,7 +146,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/sanity/pom.xml b/testing/sanity/pom.xml index 979a2275c3f..73e8ac151f6 100644 --- a/testing/sanity/pom.xml +++ b/testing/sanity/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -60,82 +60,82 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model report-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model report-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model notifications-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model notifications-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model workflow-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model workflow-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -147,7 +147,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -175,13 +175,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -192,7 +192,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/selenium-tests/pom.xml b/testing/selenium-tests/pom.xml index 91eefe94fe3..ff26a9df222 100644 --- a/testing/selenium-tests/pom.xml +++ b/testing/selenium-tests/pom.xml @@ -6,12 +6,12 @@ Selenium tests com.evolveum.midpoint.testing selenium-tests - 3.2-SNAPSHOT + 3.3-SNAPSHOT testing com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -55,7 +55,7 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/story/pom.xml b/testing/story/pom.xml index c7dcaa35cbf..c16973f7626 100644 --- a/testing/story/pom.xml +++ b/testing/story/pom.xml @@ -23,7 +23,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml @@ -60,52 +60,52 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.infra common - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-api - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.model model-test - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.provisioning provisioning-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo task-quartz-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo repo-test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT @@ -117,7 +117,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -145,13 +145,13 @@ com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -162,7 +162,7 @@ com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/testing/wstest/pom.xml b/testing/wstest/pom.xml index cfae0975b04..9a51abae5d4 100644 --- a/testing/wstest/pom.xml +++ b/testing/wstest/pom.xml @@ -22,7 +22,7 @@ com.evolveum.midpoint parent - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../../build-system/pom.xml wstest @@ -42,7 +42,7 @@ com.evolveum.midpoint.model model-client - 3.2-SNAPSHOT + 3.3-SNAPSHOT org.apache.cxf @@ -73,13 +73,13 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.infra test-util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test @@ -90,7 +90,7 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/tools/gui-i18n/pom.xml b/tools/gui-i18n/pom.xml index 8d9f3bf09a1..6d02d1cd9bf 100644 --- a/tools/gui-i18n/pom.xml +++ b/tools/gui-i18n/pom.xml @@ -25,7 +25,7 @@ tools com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -48,7 +48,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/tools/pom.xml b/tools/pom.xml index ca7a609bc8b..1d76fcb94c7 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -24,7 +24,7 @@ parent com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT ../build-system/pom.xml diff --git a/tools/repo-ninja/pom.xml b/tools/repo-ninja/pom.xml index ba972abedd1..500132d6b39 100644 --- a/tools/repo-ninja/pom.xml +++ b/tools/repo-ninja/pom.xml @@ -25,7 +25,7 @@ tools com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,28 +36,28 @@ com.evolveum.midpoint.repo repo-sql-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo system-init - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.repo security-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test com.evolveum.midpoint.repo audit-impl - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/tools/schema-dist-maven-plugin/pom.xml b/tools/schema-dist-maven-plugin/pom.xml index 834ca20d6e6..448befe6275 100644 --- a/tools/schema-dist-maven-plugin/pom.xml +++ b/tools/schema-dist-maven-plugin/pom.xml @@ -20,13 +20,13 @@ 4.0.0 com.evolveum.midpoint.tools schema-dist-maven-plugin - 3.2-SNAPSHOT + 3.3-SNAPSHOT maven-plugin midPoint Tools - schema dist maven plugin tools com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -71,7 +71,7 @@ com.evolveum.midpoint.infra util - 3.2-SNAPSHOT + 3.3-SNAPSHOT diff --git a/tools/test-ng/pom.xml b/tools/test-ng/pom.xml index 5251739702d..54c761cf43f 100644 --- a/tools/test-ng/pom.xml +++ b/tools/test-ng/pom.xml @@ -24,7 +24,7 @@ tools com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AlphabeticalMethodInterceptor.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AlphabeticalMethodInterceptor.java index 89bd38eb49f..635094cebba 100644 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AlphabeticalMethodInterceptor.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AlphabeticalMethodInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,6 +58,8 @@ public int compare(IMethodInstance o1, IMethodInstance o2) { Arrays.sort(array, comparator); result.addAll(Arrays.asList(array)); } + + System.out.println("AlphabeticalMethodInterceptor: "+result); return result; } diff --git a/tools/xjc-plugin/pom.xml b/tools/xjc-plugin/pom.xml index 5daa9478f5f..7df46ba5fd4 100644 --- a/tools/xjc-plugin/pom.xml +++ b/tools/xjc-plugin/pom.xml @@ -19,13 +19,13 @@ 4.0.0 com.evolveum.midpoint.tools xjc-plugin - 3.2-SNAPSHOT + 3.3-SNAPSHOT jar midPoint Infrastructure - xjc plugin tools com.evolveum.midpoint - 3.2-SNAPSHOT + 3.3-SNAPSHOT https://github.com/Evolveum/midpoint.git @@ -36,7 +36,7 @@ com.evolveum.midpoint.infra prism - 3.2-SNAPSHOT + 3.3-SNAPSHOT com.sun.xml.bind @@ -62,7 +62,7 @@ com.evolveum.midpoint.tools test-ng - 3.2-SNAPSHOT + 3.3-SNAPSHOT test diff --git a/weblogic-build/pom.xml b/weblogic-build/pom.xml index 8302312064e..5f9f38df407 100644 --- a/weblogic-build/pom.xml +++ b/weblogic-build/pom.xml @@ -20,7 +20,7 @@ com.evolveum.midpoint.dist midPoint-weblogic ear - 3.2-SNAPSHOT + 3.3-SNAPSHOT midPoint distribution for WebLogic Server https://github.com/Evolveum/midpoint.git @@ -36,7 +36,7 @@ com.evolveum.midpoint.gui admin-gui - 3.2-SNAPSHOT + 3.3-SNAPSHOT war