You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2016/05/27 09:24:59 UTC
[1/3] syncope git commit: [SYNCOPE-745] provides policy management +
console integration tests
Repository: syncope
Updated Branches:
refs/heads/master 51383dd9c -> 030d1c249
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/policy/ComposablePolicy.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/ComposablePolicy.java b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/ComposablePolicy.java
new file mode 100644
index 0000000..b03d538
--- /dev/null
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/ComposablePolicy.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.lib.policy;
+
+import java.io.Serializable;
+import java.util.List;
+
+public interface ComposablePolicy<T extends RuleConf> extends Serializable {
+
+ /**
+ * Return policy rules.
+ *
+ * @return policy rules.
+ */
+ List<T> getRuleConfs();
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultAccountRuleConf.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultAccountRuleConf.java b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultAccountRuleConf.java
index 804fcc5..1d7cdb3 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultAccountRuleConf.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultAccountRuleConf.java
@@ -25,6 +25,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.apache.syncope.common.lib.report.Schema;
+import org.apache.syncope.common.lib.types.IntMappingType;
@XmlRootElement(name = "defaultAccountRuleConf")
@XmlType
@@ -65,6 +67,8 @@ public class DefaultAccountRuleConf extends AbstractAccountRuleConf implements A
/**
* User attribute values not permitted.
*/
+ @Schema(type
+ = { IntMappingType.UserPlainSchema, IntMappingType.UserDerivedSchema, IntMappingType.UserVirtualSchema })
private final List<String> schemasNotPermitted = new ArrayList<>();
/**
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultPasswordRuleConf.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultPasswordRuleConf.java b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultPasswordRuleConf.java
index 8792897..b75ff9c 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultPasswordRuleConf.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/DefaultPasswordRuleConf.java
@@ -25,6 +25,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.apache.syncope.common.lib.report.Schema;
+import org.apache.syncope.common.lib.types.IntMappingType;
@XmlRootElement(name = "defaultPasswordRuleConf")
@XmlType
@@ -140,6 +142,8 @@ public class DefaultPasswordRuleConf extends AbstractPasswordRuleConf {
/**
* User attribute values not permitted.
*/
+ @Schema(type
+ = { IntMappingType.UserPlainSchema, IntMappingType.UserDerivedSchema, IntMappingType.UserVirtualSchema })
private final List<String> schemasNotPermitted = new ArrayList<>();
/**
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/policy/PasswordPolicyTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/PasswordPolicyTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/PasswordPolicyTO.java
index 20f238a..b9d6d3e 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/PasswordPolicyTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/PasswordPolicyTO.java
@@ -28,7 +28,7 @@ import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "passwordPolicy")
@XmlType
-public class PasswordPolicyTO extends AbstractPolicyTO {
+public class PasswordPolicyTO extends AbstractPolicyTO implements ComposablePolicy<AbstractPasswordRuleConf> {
private static final long serialVersionUID = -5606086441294799690L;
@@ -57,6 +57,7 @@ public class PasswordPolicyTO extends AbstractPolicyTO {
@XmlElementWrapper(name = "ruleConfs")
@XmlElement(name = "ruleConf")
@JsonProperty("ruleConfs")
+ @Override
public List<AbstractPasswordRuleConf> getRuleConfs() {
return ruleConfs;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/policy/RuleConf.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/RuleConf.java b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/RuleConf.java
index 5a99cd1..edb139a 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/RuleConf.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/RuleConf.java
@@ -19,9 +19,10 @@
package org.apache.syncope.common.lib.policy;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import java.io.Serializable;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
-public interface RuleConf {
+public interface RuleConf extends Serializable {
/**
* Give name of related rule instance.
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/report/Schema.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/report/Schema.java b/common/lib/src/main/java/org/apache/syncope/common/lib/report/Schema.java
index 1aad334..31844af 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/report/Schema.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/report/Schema.java
@@ -28,5 +28,5 @@ import org.apache.syncope.common.lib.types.IntMappingType;
@Retention(RetentionPolicy.RUNTIME)
public @interface Schema {
- IntMappingType type() default IntMappingType.UserPlainSchema;
+ IntMappingType[] type() default { IntMappingType.UserPlainSchema };
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
index 72cd14e..5a76d63 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
@@ -177,8 +177,8 @@ public class SyncopeLogic extends AbstractLogic<AbstractBaseBean> {
PLATFORM_INFO.setPasswordGenerator(passwordGenerator.getClass().getName());
PLATFORM_INFO.getReportletConfs().addAll(implLookup.getClassNames(Type.REPORTLET_CONF));
- PLATFORM_INFO.getAccountRules().addAll(implLookup.getClassNames(Type.ACCOUNT_RULE));
- PLATFORM_INFO.getPasswordRules().addAll(implLookup.getClassNames(Type.PASSWORD_RULE));
+ PLATFORM_INFO.getAccountRules().addAll(implLookup.getClassNames(Type.ACCOUNT_RULE_CONF));
+ PLATFORM_INFO.getPasswordRules().addAll(implLookup.getClassNames(Type.PASSWORD_RULE_CONF));
PLATFORM_INFO.getMappingItemTransformers().addAll(
implLookup.getClassNames(Type.MAPPING_ITEM_TRANSFORMER));
PLATFORM_INFO.getTaskJobs().addAll(implLookup.getClassNames(Type.TASKJOBDELEGATE));
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java b/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
index 0192a2a..ac641a2 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
@@ -57,6 +57,7 @@ import org.apache.syncope.core.provisioning.api.pushpull.PullCorrelationRule;
import org.apache.syncope.core.provisioning.api.pushpull.PullActions;
import org.apache.syncope.core.provisioning.java.data.JEXLMappingItemTransformer;
import org.apache.syncope.core.provisioning.java.job.GroupMemberProvisionTaskJobDelegate;
+import org.apache.syncope.core.provisioning.java.pushpull.PlainAttrsPullCorrelationRule;
/**
* Cache class names for all implementations of Syncope interfaces found in classpath, for later usage.
@@ -123,17 +124,21 @@ public class ClassPathScanImplementationLookup implements ImplementationLookup {
}
if (AccountRule.class.isAssignableFrom(clazz) && !isAbsractClazz) {
- classNames.get(Type.ACCOUNT_RULE).add(clazz.getName());
-
AccountRuleConfClass annotation = clazz.getAnnotation(AccountRuleConfClass.class);
- if (annotation != null) {
+ if (annotation == null) {
+ LOG.warn("Found account policy rule {} without declared configuration", clazz.getName());
+ } else {
+ classNames.get(Type.ACCOUNT_RULE_CONF).add(annotation.value().getName());
accountRuleClasses.put(annotation.value(), (Class<? extends AccountRule>) clazz);
}
}
+
if (PasswordRule.class.isAssignableFrom(clazz) && !isAbsractClazz) {
- classNames.get(Type.PASSWORD_RULE).add(clazz.getName());
PasswordRuleConfClass annotation = clazz.getAnnotation(PasswordRuleConfClass.class);
- if (annotation != null) {
+ if (annotation == null) {
+ LOG.warn("Found password policy rule {} without declared configuration", clazz.getName());
+ } else {
+ classNames.get(Type.PASSWORD_RULE_CONF).add(annotation.value().getName());
passwordRuleClasses.put(annotation.value(), (Class<? extends PasswordRule>) clazz);
}
}
@@ -172,7 +177,8 @@ public class ClassPathScanImplementationLookup implements ImplementationLookup {
classNames.get(Type.PUSH_ACTIONS).add(bd.getBeanClassName());
}
- if (PullCorrelationRule.class.isAssignableFrom(clazz) && !isAbsractClazz) {
+ if (PullCorrelationRule.class.isAssignableFrom(clazz) && !isAbsractClazz
+ && !PlainAttrsPullCorrelationRule.class.isAssignableFrom(clazz)) {
classNames.get(Type.PULL_CORRELATION_RULE).add(bd.getBeanClassName());
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java
index 292acb4..c3c1c2d 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java
@@ -31,8 +31,8 @@ public interface ImplementationLookup extends SyncopeLoader {
enum Type {
REPORTLET_CONF,
- ACCOUNT_RULE,
- PASSWORD_RULE,
+ ACCOUNT_RULE_CONF,
+ PASSWORD_RULE_CONF,
MAPPING_ITEM_TRANSFORMER,
TASKJOBDELEGATE,
RECONCILIATION_FILTER_BUILDER,
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java
index 625f88d..8829c03 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java
@@ -104,7 +104,7 @@ public class PolicyDataBinderImpl implements PolicyDataBinder {
}
accountPolicy.getResources().clear();
- for (String resourceName : accountPolicyTO.getResources()) {
+ for (String resourceName : accountPolicyTO.getPassthroughResources()) {
ExternalResource resource = resourceDAO.find(resourceName);
if (resource == null) {
LOG.debug("Ignoring invalid resource {} ", resourceName);
@@ -167,7 +167,7 @@ public class PolicyDataBinderImpl implements PolicyDataBinder {
accountPolicyTO.getRuleConfs().add((AbstractAccountRuleConf) ruleConf);
}
- accountPolicyTO.getResources().addAll(accountPolicy.getResourceNames());
+ accountPolicyTO.getPassthroughResources().addAll(accountPolicy.getResourceNames());
} else if (policy instanceof PullPolicy) {
policyTO = (T) new PullPolicyTO();
((PullPolicyTO) policyTO).setSpecification(((PullPolicy) policy).getSpecification());
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutesDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutesDirectoryPanel.java b/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutesDirectoryPanel.java
index e1d0b81..b40e466 100644
--- a/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutesDirectoryPanel.java
+++ b/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutesDirectoryPanel.java
@@ -19,7 +19,6 @@
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -101,16 +100,6 @@ public class CamelRoutesDirectoryPanel extends DirectoryPanel<
}
};
}
-
- @Override
- protected void onCancelInternal(final CamelRouteTO modelObject) {
- }
-
- @Override
- protected Serializable onApplyInternal(final CamelRouteTO modelObject) {
- // do nothing
- return null;
- }
}, false);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestAccountRuleConf.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestAccountRuleConf.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestAccountRuleConf.java
index 47c468d..44bc308 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestAccountRuleConf.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestAccountRuleConf.java
@@ -28,7 +28,7 @@ public class TestAccountRuleConf extends AbstractAccountRuleConf {
private static final long serialVersionUID = -1803947511928491978L;
- private String mustContainSubstring = "YYY";
+ private final String mustContainSubstring = "YYY";
public String getMustContainSubstring() {
return mustContainSubstring;
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPasswordRuleConf.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPasswordRuleConf.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPasswordRuleConf.java
index c6c6446..ecd3cb4 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPasswordRuleConf.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPasswordRuleConf.java
@@ -28,7 +28,7 @@ public class TestPasswordRuleConf extends AbstractPasswordRuleConf {
private static final long serialVersionUID = -1803947511928491978L;
- private String mustEndWith = "XXX";
+ private final String mustEndWith = "XXX";
public String getMustEndWith() {
return mustEndWith;
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
index 6182453..efb59e1 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
@@ -20,6 +20,7 @@ package org.apache.syncope.fit.console;
import java.io.Serializable;
import java.lang.reflect.Method;
+import java.util.List;
import javax.servlet.ServletContext;
import org.apache.syncope.client.console.SyncopeConsoleApplication;
import org.apache.syncope.client.console.init.ClassPathScanImplementationLookup;
@@ -29,6 +30,8 @@ import org.apache.syncope.client.console.pages.Login;
import org.apache.syncope.fit.AbstractITCase;
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.behavior.AbstractAjaxBehavior;
+import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.core.util.lang.PropertyResolver;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.util.tester.FormTester;
@@ -100,4 +103,13 @@ public abstract class AbstractConsoleITCase extends AbstractITCase {
}
});
}
+
+ protected void closeCallBack(final Component modal) {
+ final List<? extends Behavior> behaviors = modal.getBehaviors();
+ for (Behavior behavior : behaviors) {
+ if (behavior instanceof AbstractAjaxBehavior) {
+ wicketTester.executeBehavior((AbstractAjaxBehavior) behavior);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/fit/core-reference/src/test/java/org/apache/syncope/fit/console/PoliciesITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/PoliciesITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/PoliciesITCase.java
new file mode 100644
index 0000000..acbe454
--- /dev/null
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/PoliciesITCase.java
@@ -0,0 +1,669 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.fit.console;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.pages.Policies;
+import org.apache.syncope.common.lib.types.ConflictResolutionAction;
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.util.tester.FormTester;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.JVM)
+public class PoliciesITCase extends AbstractConsoleITCase {
+
+ private void createAccountPolicy(final String description) {
+ wicketTester.clickLink("body:content:tabbedPanel:tabs-container:tabs:0:link");
+ wicketTester.clickLink("body:content:tabbedPanel:panel:container:content:add");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description);
+ formTester.setValue("content:fields:1:field:spinner", "1");
+ formTester.setValue("content:fields:2:field:checkboxField", true);
+ formTester.setValue("content:fields:3:field:paletteField:recorder", "resource-csv");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", WebMarkupContainer.class);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:9:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:0:field:textField", description);
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:1:field:spinner", 1);
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:2:field:checkboxField", true);
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:3:field:paletteField:recorder", "resource-csv");
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:buttons:0:button",
+ Constants.ON_CLICK);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+ }
+
+ private void createPasswordPolicy(final String description) {
+ wicketTester.clickLink("body:content:tabbedPanel:tabs-container:tabs:1:link");
+ wicketTester.clickLink("body:content:tabbedPanel:panel:container:content:add");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description);
+ formTester.setValue("content:fields:1:field:spinner", "1");
+ formTester.setValue("content:fields:2:field:checkboxField", true);
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:8:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:0:field:textField", description);
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:1:field:spinner", 1);
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:2:field:checkboxField", true);
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:buttons:0:button",
+ Constants.ON_CLICK);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+ }
+
+ private void createPullPolicy(final String description) {
+ wicketTester.clickLink("body:content:tabbedPanel:tabs-container:tabs:2:link");
+ wicketTester.clickLink("body:content:tabbedPanel:panel:container:content:add");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description);
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit",
+ Constants.ON_CLICK);
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:6:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:0:field:textField", description);
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:buttons:0:button",
+ Constants.ON_CLICK);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+ }
+
+ private void deleteAccountPolicy(final String description) {
+ wicketTester.clickLink("body:content:tabbedPanel:tabs-container:tabs:0:link");
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+
+ wicketTester.getRequest().addParameter("confirm", "true");
+ wicketTester.clickLink(wicketTester.getComponentFromLastRenderedPage(
+ component.getPageRelativePath() + ":cells:9:cell:panelDelete:deleteLink"));
+
+ wicketTester.executeAjaxEvent(wicketTester.getComponentFromLastRenderedPage(
+ component.getPageRelativePath() + ":cells:9:cell:panelDelete:deleteLink"), Constants.ON_CLICK);
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ Assert.assertNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+ }
+
+ private void deletePasswordPolicy(final String description) {
+ wicketTester.clickLink("body:content:tabbedPanel:tabs-container:tabs:1:link");
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+
+ wicketTester.getRequest().addParameter("confirm", "true");
+ wicketTester.clickLink(
+ wicketTester.getComponentFromLastRenderedPage(
+ component.getPageRelativePath() + ":cells:8:cell:panelDelete:deleteLink"));
+
+ wicketTester.executeAjaxEvent(wicketTester.getComponentFromLastRenderedPage(
+ component.getPageRelativePath() + ":cells:8:cell:panelDelete:deleteLink"), Constants.ON_CLICK);
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ Assert.assertNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+ }
+
+ private void deletePullPolicy(final String description) {
+ wicketTester.clickLink("body:content:tabbedPanel:tabs-container:tabs:2:link");
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+
+ wicketTester.getRequest().addParameter("confirm", "true");
+ wicketTester.clickLink(
+ wicketTester.getComponentFromLastRenderedPage(
+ component.getPageRelativePath() + ":cells:6:cell:panelDelete:deleteLink"));
+
+ wicketTester.executeAjaxEvent(wicketTester.getComponentFromLastRenderedPage(
+ component.getPageRelativePath() + ":cells:6:cell:panelDelete:deleteLink"), Constants.ON_CLICK);
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ Assert.assertNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+ }
+
+ @Before
+ public void login() {
+ doLogin(ADMIN_UNAME, ADMIN_PWD);
+ wicketTester.clickLink("body:configurationLI:configurationUL:policiesLI:policies");
+ wicketTester.assertRenderedPage(Policies.class);
+ }
+
+ @Test
+ public void read() {
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", "an account policy"));
+ }
+
+ @Test
+ public void createDeleteAccountPolicy() {
+ final String description = "My Test Account Policy";
+ createAccountPolicy(description);
+ deleteAccountPolicy(description);
+ }
+
+ @Test
+ public void cloneDeleteAccountPolicy() {
+ final String description = "My Test Account Policy to be cloned";
+ createAccountPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:9:cell:panelClone:cloneLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description + "2");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+
+ deleteAccountPolicy(description);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description + "2"));
+
+ deleteAccountPolicy(description + "2");
+ }
+
+ @Test
+ public void createDeletePasswordPolicy() {
+ final String description = "My Test Password Policy";
+ createPasswordPolicy(description);
+ deletePasswordPolicy(description);
+ }
+
+ @Test
+ public void cloneDeletePasswordPolicy() {
+ final String description = "My Test Password Policy to be cloned";
+ createPasswordPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:8:cell:panelClone:cloneLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description + "2");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+
+ deletePasswordPolicy(description);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description + "2"));
+
+ deletePasswordPolicy(description + "2");
+ }
+
+ @Test
+ public void createDeletePullPolicy() {
+ final String description = "My Test Pull Policy";
+ createPullPolicy(description);
+ deletePullPolicy(description);
+ }
+
+ @Test
+ public void cloneDeletePullPolicy() {
+ final String description = "My Test Pull Policy to be cloned";
+ createPullPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:6:cell:panelClone:cloneLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description + "2");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description));
+
+ deletePullPolicy(description);
+
+ Assert.assertNotNull(findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description + "2"));
+
+ deletePullPolicy(description + "2");
+ }
+
+ @Test
+ public void createUpdateDeleteAccountPolicy() {
+ final String description = "Account Policy To Be Updated";
+ createAccountPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:9:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:1:field:spinner", "2");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.assertLabel(component.getPageRelativePath() + ":cells:7:cell", "2");
+
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:9:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:1:field:spinner", 2);
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:buttons:0:button",
+ Constants.ON_CLICK);
+
+ deleteAccountPolicy(description);
+ }
+
+ @Test
+ public void createComposeDeleteAccountPolicy() {
+ final String description = "Account Policy To Be Composed";
+ createAccountPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:9:cell:panelCompose:composeLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:content:container:content:add");
+
+ FormTester formTester = wicketTester.newFormTester("body:content:tabbedPanel:panel:outerObjectsRepeater:3:"
+ + "outer:form:content:container:content:wizard:form");
+ formTester.setValue("view:name:textField", "myrule");
+ formTester.setValue("view:configuration:dropDownChoiceField", "1");
+ formTester.submit("buttons:next");
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:content:"
+ + "container:content:wizard:form:view:bean:propView:1:value:spinner", 0);
+
+ formTester = wicketTester.newFormTester("body:content:tabbedPanel:panel:outerObjectsRepeater:3:"
+ + "outer:form:content:container:content:wizard:form");
+ formTester.submit("buttons:finish");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ component = findComponentByProp("name", "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:"
+ + "content:container:content:searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable",
+ "myrule");
+
+ Assert.assertNotNull(component);
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:content:container:content:exit");
+
+ closeCallBack(modal);
+
+ deleteAccountPolicy(description);
+ }
+
+ @Test
+ public void createUpdateDeletePasswordPolicy() {
+ final String description = "Password Policy To Be Updated";
+ createPasswordPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:8:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:1:field:spinner", "2");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.assertLabel(component.getPageRelativePath() + ":cells:6:cell", "2");
+
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:8:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:1:field:spinner", 2);
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:buttons:0:button",
+ Constants.ON_CLICK);
+
+ deletePasswordPolicy(description);
+ }
+
+ @Test
+ public void createComposeDeletePasswordPolicy() {
+ final String description = "Password Policy To Be Composed";
+ createPasswordPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:8:cell:panelCompose:composeLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:content:container:content:add");
+
+ FormTester formTester = wicketTester.newFormTester("body:content:tabbedPanel:panel:outerObjectsRepeater:3:"
+ + "outer:form:content:container:content:wizard:form");
+ formTester.setValue("view:name:textField", "myrule");
+ formTester.setValue("view:configuration:dropDownChoiceField", "1");
+ formTester.submit("buttons:next");
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:content:"
+ + "container:content:wizard:form:view:bean:propView:0:value:spinner", 0);
+
+ formTester = wicketTester.newFormTester("body:content:tabbedPanel:panel:outerObjectsRepeater:3:"
+ + "outer:form:content:container:content:wizard:form");
+ formTester.submit("buttons:finish");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ component = findComponentByProp("name", "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:"
+ + "content:container:content:searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable",
+ "myrule");
+
+ Assert.assertNotNull(component);
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:3:outer:form:content:container:content:exit");
+
+ closeCallBack(modal);
+
+ deletePasswordPolicy(description);
+ }
+
+ @Test
+ public void createUpdateDeletePullPolicy() {
+ final String description = "Pull Policy To Be Updated";
+ createPullPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer");
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:6:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
+ formTester.setValue("content:fields:0:field:textField", description + "2");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description + "2");
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:6:cell:panelEdit:editLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form"
+ + ":content:fields:0:field:textField", description + "2");
+
+ wicketTester.executeAjaxEvent(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:buttons:0:button",
+ Constants.ON_CLICK);
+
+ deletePullPolicy(description + "2");
+ }
+
+ @Test
+ public void createComposeDeletePullPolicy() {
+ final String description = "Pull Policy To Be Composed";
+ createPullPolicy(description);
+
+ Component component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:6:cell:panelCompose:composeLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer", Modal.class);
+
+ Component modal = wicketTester.getComponentFromLastRenderedPage(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer");
+
+ FormTester formTester = wicketTester.newFormTester(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer:form");
+
+ wicketTester.executeAjaxEvent("body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer:form:content:"
+ + "correlationRules:multiValueContainer:innerForm:content:panelPlus:add", Constants.ON_CLICK);
+
+ formTester.setValue("content:conflictResolutionAction:dropDownChoiceField", "1");
+ formTester.setValue("content:correlationRules:multiValueContainer:innerForm:content:view:0:panel:"
+ + "jsonRule:paletteField:recorder", "fullname");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer:dialog:footer:inputs:0:submit");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+
+ closeCallBack(modal);
+
+ component = findComponentByProp("description", "body:content:tabbedPanel:panel:container:content:"
+ + "searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", description);
+
+ Assert.assertNotNull(component);
+ wicketTester.clickLink(component.getPageRelativePath() + ":cells:6:cell:panelCompose:composeLink");
+ wicketTester.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer", Modal.class);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer:form:"
+ + "content:conflictResolutionAction:dropDownChoiceField", ConflictResolutionAction.FIRSTMATCH);
+
+ wicketTester.assertModelValue("body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer:form:"
+ + "content:correlationRules:multiValueContainer:innerForm:content:view:0:panel:"
+ + "jsonRule:paletteField:recorder", "fullname");
+
+ wicketTester.clickLink(
+ "body:content:tabbedPanel:panel:outerObjectsRepeater:4:outer:dialog:footer:buttons:0:button");
+
+ closeCallBack(modal);
+
+ deletePullPolicy(description);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/fit/core-reference/src/test/java/org/apache/syncope/fit/console/TopologyITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/TopologyITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/TopologyITCase.java
index a36d1cc..d4a5b9c 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/TopologyITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/TopologyITCase.java
@@ -119,8 +119,7 @@ public class TopologyITCase extends AbstractConsoleITCase {
wicketTester.executeAjaxEvent(
"body:toggle:container:content:togglePanelContainer:container:actions:create", Constants.ON_CLICK);
- FormTester formTester =
- wicketTester.newFormTester("body:toggle:outerObjectsRepeater:0:outer:form:content:form");
+ FormTester formTester = wicketTester.newFormTester("body:toggle:outerObjectsRepeater:0:outer:form:content:form");
formTester.setValue("view:container:key:textField", res);
formTester.submit("buttons:next");
@@ -440,4 +439,19 @@ public class TopologyITCase extends AbstractConsoleITCase {
wicketTester.assertInfoMessages("Operation executed successfully");
wicketTester.cleanupFeedbackMessages();
}
+
+ @Test
+ public void reloadConnectors() {
+ wicketTester.clickLink("body:topologyLI:topology");
+ wicketTester.executeAjaxEvent("body:syncope", Constants.ON_CLICK);
+ wicketTester.assertComponent("body:toggle:container:content:togglePanelContainer:container:actions:reload",
+ AjaxLink.class);
+
+ wicketTester.cleanupFeedbackMessages();
+ wicketTester.getRequest().addParameter("confirm", "true");
+ wicketTester.clickLink("body:toggle:container:content:togglePanelContainer:container:actions:reload");
+
+ wicketTester.assertInfoMessages("Operation executed successfully");
+ wicketTester.cleanupFeedbackMessages();
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PolicyITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PolicyITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PolicyITCase.java
index b00df7d..c66e4d0 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PolicyITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PolicyITCase.java
@@ -159,7 +159,7 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void getCorrelationRules() {
- assertEquals(2, syncopeService.platform().getPullCorrelationRules().size());
+ assertEquals(1, syncopeService.platform().getPullCorrelationRules().size());
}
@Test
@@ -180,7 +180,7 @@ public class PolicyITCase extends AbstractITCase {
public void issueSYNCOPE682() {
AccountPolicyTO policy = new AccountPolicyTO();
policy.setDescription("SYNCOPE682");
- policy.getResources().add(RESOURCE_NAME_LDAP);
+ policy.getPassthroughResources().add(RESOURCE_NAME_LDAP);
DefaultAccountRuleConf ruleConf = new DefaultAccountRuleConf();
ruleConf.setMinLength(3);
[2/3] syncope git commit: [SYNCOPE-745] provides policy management +
console integration tests
Posted by fm...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicySpecModalPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicySpecModalPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicySpecModalPanel.java
new file mode 100644
index 0000000..f166d10
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicySpecModalPanel.java
@@ -0,0 +1,353 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.panels.AbstractModalPanel;
+import org.apache.syncope.client.console.rest.AnyTypeRestClient;
+import org.apache.syncope.client.console.rest.PolicyRestClient;
+import org.apache.syncope.client.console.rest.SchemaRestClient;
+import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.MultiPanel;
+import org.apache.syncope.common.lib.policy.PullPolicyTO;
+import org.apache.syncope.common.lib.to.AbstractSchemaTO;
+import org.apache.syncope.common.lib.to.AnyTypeTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.ConflictResolutionAction;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.PropertyModel;
+
+public class PolicySpecModalPanel extends AbstractModalPanel<PullPolicyTO> {
+
+ private static final long serialVersionUID = 5945391813567245081L;
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private final IModel<List<CorrelationRule>> model;
+
+ private final PolicyRestClient restClient = new PolicyRestClient();
+
+ public PolicySpecModalPanel(
+ final PullPolicyTO policyTO, final BaseModal<PullPolicyTO> modal, final PageReference pageRef) {
+ super(modal, pageRef);
+ modal.setFormModel(policyTO);
+
+ add(new AjaxDropDownChoicePanel<ConflictResolutionAction>(
+ "conflictResolutionAction",
+ "conflictResolutionAction",
+ new PropertyModel<ConflictResolutionAction>(policyTO.getSpecification(), "conflictResolutionAction")).
+ setChoices(Arrays.asList(ConflictResolutionAction.values())));
+
+ model = new PropertyModel<List<CorrelationRule>>(policyTO.getSpecification(), "correlationRules") {
+
+ private static final long serialVersionUID = -8168676563540297301L;
+
+ private List<CorrelationRule> rules = CollectionUtils.collect(
+ policyTO.getSpecification().getCorrelationRules() == null
+ ? Collections.<String>emptySet()
+ : policyTO.getSpecification().getCorrelationRules().keySet(),
+ new Transformer<String, CorrelationRule>() {
+
+ @Override
+ public CorrelationRule transform(final String input) {
+ return new CorrelationRule(input, policyTO.getSpecification().getCorrelationRules().get(
+ input));
+ }
+ }, new ArrayList<CorrelationRule>());
+
+ @Override
+ public List<CorrelationRule> getObject() {
+ return rules;
+ }
+
+ @Override
+ public void setObject(final List<CorrelationRule> object) {
+ policyTO.getSpecification().getCorrelationRules().clear();
+ for (CorrelationRule rule : rules) {
+ policyTO.getSpecification().getCorrelationRules().put(rule.getAny(), rule.getRule());
+ }
+ }
+
+ };
+
+ add(new MultiPanel<CorrelationRule>("correlationRules", "correlationRules", model, false) {
+
+ private static final long serialVersionUID = -2481579077338205547L;
+
+ @Override
+ protected CorrelationRule newModelObject() {
+ return new CorrelationRule();
+ }
+
+ @Override
+ protected CorrelationRulePanel getItemPanel(final ListItem<CorrelationRule> item) {
+ return new CorrelationRulePanel("panel", item.getModelObject());
+ }
+ });
+ }
+
+ @Override
+ public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ try {
+ getItem().getSpecification().getCorrelationRules().clear();
+ for (CorrelationRule rule : model.getObject()) {
+ getItem().getSpecification().getCorrelationRules().put(rule.getAny(), rule.getRule());
+ }
+ restClient.updatePolicy(getItem());
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ this.modal.close(target);
+ } catch (Exception e) {
+ LOG.error("While creating/updating policy", e);
+ error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
+ }
+ SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+ }
+
+ public static class CorrelationRulePanel extends Panel {
+
+ private static final long serialVersionUID = -4708008994320210839L;
+
+ public CorrelationRulePanel(final String id, final CorrelationRule rule) {
+ super(id);
+
+ final AjaxDropDownChoicePanel<String> anyType = new AjaxDropDownChoicePanel<>(
+ "anyType", "any.type", new PropertyModel<String>(rule, "any")).
+ setNullValid(true).
+ setChoices(CollectionUtils.collect(
+ new AnyTypeRestClient().list(),
+ new Transformer<AnyTypeTO, String>() {
+
+ @Override
+ public String transform(final AnyTypeTO input) {
+ return input.getKey();
+ }
+ }, new ArrayList<String>()));
+ add(anyType);
+
+ final AjaxDropDownChoicePanel<String> ruleType = new AjaxDropDownChoicePanel<>(
+ "ruleType", "rule.type", new PropertyModel<String>(rule, "type"), false).
+ setNullValid(true).
+ setChoices(Arrays.asList("PLAIN", "JAVA"));
+ add(ruleType);
+
+ // ---------------------------------------------------------------
+ // Java rule palette
+ // ---------------------------------------------------------------
+ final AjaxDropDownChoicePanel<String> javaRule = new AjaxDropDownChoicePanel<>(
+ "javaRule", "rule.java", new PropertyModel<String>(rule, "rule")).setChoices(
+ new ArrayList<>(SyncopeConsoleSession.get().getPlatformInfo().getPullCorrelationRules()));
+ javaRule.setOutputMarkupPlaceholderTag(true);
+ add(javaRule.setVisible("JAVA".equals(rule.getType())));
+ // ---------------------------------------------------------------
+
+ // ---------------------------------------------------------------
+ // Json rule palette
+ // ---------------------------------------------------------------
+ final LoadableDetachableModel<List<String>> plainSchemas = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ return getPlainSchemas(rule);
+ }
+ };
+
+ final AjaxPalettePanel.Builder<String> jsonRuleBuilder
+ = new AjaxPalettePanel.Builder<String>().setName("rule.json");
+
+ final PropertyModel<List<String>> jsonRuleModel = new PropertyModel<List<String>>(rule, "rule") {
+
+ private static final long serialVersionUID = 3799387950428254072L;
+
+ @Override
+ public List<String> getObject() {
+ final List<String> res = new ArrayList<>();
+ try {
+ JsonNode obj = OBJECT_MAPPER.readTree(rule.getRule());
+ if (obj.isArray()) {
+ for (final JsonNode objNode : obj) {
+ res.add(objNode.asText());
+ }
+ }
+ } catch (IOException e) {
+ LOG.warn("Error deserializing json tree", e);
+ }
+ return res;
+ }
+
+ @Override
+ public void setObject(final List<String> object) {
+ final StringBuilder bld = new StringBuilder();
+ bld.append("[");
+
+ boolean comma = false;
+ for (String obj : object) {
+ if (comma) {
+ bld.append(",");
+ } else {
+ comma = true;
+ }
+ bld.append("\"").append(obj).append("\"");
+ }
+ bld.append("]");
+ rule.setRule(bld.toString());
+ }
+ };
+
+ final AjaxPalettePanel<String> jsonRule = jsonRuleBuilder.build("jsonRule", jsonRuleModel, plainSchemas);
+
+ jsonRule.setOutputMarkupPlaceholderTag(true);
+
+ anyType.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ if (jsonRule.isVisibleInHierarchy()) {
+ jsonRule.getChoicesModel().setObject(getPlainSchemas(rule));
+ jsonRule.reload(target);
+ }
+ }
+ });
+
+ add(jsonRule.setVisible("PLAIN".equals(rule.getType())));
+ // ---------------------------------------------------------------
+
+ ruleType.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ switch (ruleType.getModelObject() == null ? StringUtils.EMPTY : ruleType.getModelObject()) {
+ case "PLAIN":
+ jsonRule.setVisible(true);
+ jsonRule.getChoicesModel().setObject(getPlainSchemas(rule));
+ jsonRule.reload(target);
+
+ javaRule.setVisible(false);
+
+ break;
+ case "JAVA":
+ jsonRule.setVisible(false);
+ javaRule.setVisible(true);
+ break;
+ default:
+ javaRule.setVisible(false);
+ jsonRule.setVisible(false);
+
+ }
+ target.add(jsonRule);
+ target.add(javaRule);
+ }
+ });
+ }
+
+ private static List<String> getPlainSchemas(final CorrelationRule rule) {
+ final List<String> choices = StringUtils.isEmpty(rule.getAny())
+ ? new ArrayList<String>()
+ : CollectionUtils.collect(
+ new SchemaRestClient().getSchemas(SchemaType.PLAIN,
+ rule.getAny().equals(AnyTypeKind.USER.name())
+ ? AnyTypeKind.USER : rule.getAny().equals(AnyTypeKind.GROUP.name())
+ ? AnyTypeKind.GROUP
+ : AnyTypeKind.ANY_OBJECT), new Transformer<AbstractSchemaTO, String>() {
+
+ @Override
+ public String transform(final AbstractSchemaTO input) {
+ return input.getKey();
+ }
+ }, new ArrayList<String>());
+
+ Collections.sort(choices);
+ return choices;
+ }
+ }
+
+ protected static class CorrelationRule implements Serializable {
+
+ private static final long serialVersionUID = 5250228867297353011L;
+
+ private String any;
+
+ private String type;
+
+ private String rule;
+
+ public CorrelationRule() {
+ this.any = AnyTypeKind.USER.name();
+ this.type = "PLAIN";
+ this.rule = "[]";
+ }
+
+ public CorrelationRule(final String any, final String rule) {
+ this.any = any;
+ this.type = StringUtils.isEmpty(rule) || rule.trim().startsWith("[") ? "PLAIN" : "JAVA";
+ this.rule = rule;
+ }
+
+ public String getAny() {
+ return any;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getRule() {
+ return rule;
+ }
+
+ public void setAny(final String any) {
+ this.any = any;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public void setRule(final String rule) {
+ this.rule = rule;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PullPolicyDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PullPolicyDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PullPolicyDirectoryPanel.java
new file mode 100644
index 0000000..99bd048
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PullPolicyDirectoryPanel.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import static org.apache.wicket.Component.ENABLE;
+
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.common.lib.policy.PullPolicySpec;
+import org.apache.syncope.common.lib.policy.PullPolicyTO;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.StringResourceModel;
+
+/**
+ * Pull policies page.
+ */
+public class PullPolicyDirectoryPanel extends PolicyDirectoryPanel<PullPolicyTO> {
+
+ private static final long serialVersionUID = 4984337552918213290L;
+
+ public PullPolicyDirectoryPanel(final String id, final PageReference pageRef) {
+ super(id, PolicyType.PULL, pageRef);
+
+ final PullPolicyTO defaultItem = new PullPolicyTO();
+ defaultItem.setSpecification(new PullPolicySpec());
+
+ this.addNewItemPanelBuilder(
+ new PolicyModalPanelBuilder<PullPolicyTO>(defaultItem, modal, pageRef), true);
+ MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.POLICY_CREATE);
+
+ initResultTable();
+ }
+
+ @Override
+ protected void addCustomActions(
+ final ActionLinksPanel.Builder<PullPolicyTO> panel, final IModel<PullPolicyTO> model) {
+ panel.add(new ActionLink<PullPolicyTO>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final PullPolicyTO ignore) {
+ target.add(policySpecModal.setContent(
+ new PolicySpecModalPanel(model.getObject(), policySpecModal, pageRef)));
+
+ policySpecModal.header(new StringResourceModel(
+ "policy.rule.conf", PullPolicyDirectoryPanel.this, Model.of(model.getObject())));
+
+ MetaDataRoleAuthorizationStrategy.authorize(
+ policySpecModal.getForm(), ENABLE, StandardEntitlement.POLICY_UPDATE);
+
+ policySpecModal.show(true);
+ }
+ }, ActionLink.ActionType.COMPOSE, StandardEntitlement.POLICY_UPDATE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletDirectoryPanel.java
index ce852d9..1eb86e2 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletDirectoryPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletDirectoryPanel.java
@@ -98,7 +98,6 @@ public class ReportletDirectoryPanel extends DirectoryPanel<
this.addNewItemPanelBuilder(new ReportletWizardBuilder(report, new ReportletWrapper(), pageRef), true);
MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.REPORT_UPDATE);
- restClient = new ReportRestClient();
initResultTable();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletWizardBuilder.java
index 76c07e7..7156acf 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/reports/ReportletWizardBuilder.java
@@ -19,61 +19,30 @@
package org.apache.syncope.client.console.reports;
import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
-import org.apache.commons.collections4.Transformer;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.client.console.SyncopeConsoleSession;
-import org.apache.syncope.client.console.panels.search.AnyObjectSearchPanel;
-import org.apache.syncope.client.console.panels.search.GroupSearchPanel;
+import org.apache.syncope.client.console.panels.BeanPanel;
import org.apache.syncope.client.console.panels.search.SearchClause;
import org.apache.syncope.client.console.panels.search.SearchUtils;
-import org.apache.syncope.client.console.panels.search.UserSearchPanel;
import org.apache.syncope.client.console.rest.ReportRestClient;
-import org.apache.syncope.client.console.rest.SchemaRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.DateTimeFieldPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel;
import org.apache.syncope.client.console.wizards.AjaxWizardBuilder;
-import org.apache.syncope.client.lib.SyncopeClient;
-import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.report.AbstractReportletConf;
-import org.apache.syncope.common.lib.report.Schema;
-import org.apache.syncope.common.lib.to.AbstractSchemaTO;
import org.apache.syncope.common.lib.to.ReportTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.wicket.PageReference;
import org.apache.wicket.extensions.wizard.WizardModel;
import org.apache.wicket.extensions.wizard.WizardStep;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.ResourceModel;
-import org.apache.wicket.model.util.ListModel;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.PropertyAccessorFactory;
-import org.springframework.util.ClassUtils;
-import org.apache.syncope.common.lib.report.SearchCondition;
import org.apache.syncope.common.lib.search.AbstractFiqlSearchConditionBuilder;
+import org.apache.wicket.model.LoadableDetachableModel;
public class ReportletWizardBuilder extends AjaxWizardBuilder<ReportletDirectoryPanel.ReportletWrapper> {
@@ -177,204 +146,19 @@ public class ReportletWizardBuilder extends AjaxWizardBuilder<ReportletDirectory
private static final long serialVersionUID = -785981096328637758L;
- private final String[] excluded = new String[] { "serialVersionUID", "class", "name", "reportletClassName" };
-
- private final ReportletDirectoryPanel.ReportletWrapper reportlet;
-
public Configuration(final ReportletDirectoryPanel.ReportletWrapper reportlet) {
- this.reportlet = reportlet;
-
- LoadableDetachableModel<List<String>> propViewModel = new LoadableDetachableModel<List<String>>() {
+ final LoadableDetachableModel<Serializable> bean = new LoadableDetachableModel<Serializable>() {
- private static final long serialVersionUID = 5275935387613157437L;
+ private static final long serialVersionUID = 2092144708018739371L;
@Override
- protected List<String> load() {
- List<String> result = new ArrayList<String>();
- if (Configuration.this.reportlet.getConf() != null) {
- for (Field field : Configuration.this.reportlet.getConf().getClass().getDeclaredFields()) {
- if (!ArrayUtils.contains(excluded, field.getName())) {
- result.add(field.getName());
- }
- }
- }
-
- return result;
+ protected Serializable load() {
+ return reportlet.getConf();
}
};
- add(new ListView<String>("propView", propViewModel) {
-
- private static final long serialVersionUID = 9101744072914090143L;
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- protected void populateItem(final ListItem<String> item) {
- final String fieldName = item.getModelObject();
-
- item.add(new Label("fieldName", new ResourceModel(fieldName, fieldName)));
-
- Field field = null;
- try {
- field = reportlet.getConf().getClass().getDeclaredField(fieldName);
- } catch (NoSuchFieldException | SecurityException e) {
- LOG.error("Could not find field {} in class {}", fieldName, reportlet.getConf().getClass(), e);
- }
-
- if (field == null) {
- return;
- }
-
- final SearchCondition scondAnnot = field.getAnnotation(SearchCondition.class);
- final Schema schemaAnnot = field.getAnnotation(Schema.class);
-
- BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(reportlet.getConf());
-
- Panel panel;
-
- if (scondAnnot != null) {
- final String fiql = (String) wrapper.getPropertyValue(fieldName);
-
- final List<SearchClause> clauses;
- if (StringUtils.isEmpty(fiql)) {
- clauses = new ArrayList<>();
- } else {
- clauses = SearchUtils.getSearchClauses(fiql);
- }
-
- final AbstractFiqlSearchConditionBuilder builder;
-
- switch (scondAnnot.type()) {
- case "USER":
- panel = new UserSearchPanel.Builder(
- new ListModel<SearchClause>(clauses)).required(false).build("value");
- builder = SyncopeClient.getUserSearchConditionBuilder();
- break;
- case "GROUP":
- panel = new GroupSearchPanel.Builder(
- new ListModel<SearchClause>(clauses)).required(false).build("value");
- builder = SyncopeClient.getGroupSearchConditionBuilder();
- break;
- default:
- panel = new AnyObjectSearchPanel.Builder(
- scondAnnot.type(),
- new ListModel<SearchClause>(clauses)).required(false).build("value");
- builder = SyncopeClient.getAnyObjectSearchConditionBuilder(null);
- }
-
- reportlet.getSCondWrapper().put(fieldName, Pair.of(builder, clauses));
- } else if (List.class.equals(field.getType())) {
- Class<?> listItemType = String.class;
- if (field.getGenericType() instanceof ParameterizedType) {
- listItemType = (Class<?>) ((ParameterizedType) field.getGenericType()).
- getActualTypeArguments()[0];
- }
-
- if (listItemType.equals(String.class) && schemaAnnot != null) {
- SchemaRestClient schemaRestClient = new SchemaRestClient();
-
- List<AbstractSchemaTO> choices;
- switch (schemaAnnot.type()) {
- case UserPlainSchema:
- choices = schemaRestClient.getSchemas(SchemaType.PLAIN, AnyTypeKind.USER);
- break;
-
- case UserDerivedSchema:
- choices = schemaRestClient.getSchemas(SchemaType.DERIVED, AnyTypeKind.USER);
- break;
-
- case UserVirtualSchema:
- choices = schemaRestClient.getSchemas(SchemaType.VIRTUAL, AnyTypeKind.USER);
- break;
-
- case GroupPlainSchema:
- choices = schemaRestClient.getSchemas(SchemaType.PLAIN, AnyTypeKind.GROUP);
- break;
-
- case GroupDerivedSchema:
- choices = schemaRestClient.getSchemas(SchemaType.DERIVED, AnyTypeKind.GROUP);
- break;
-
- case GroupVirtualSchema:
- choices = schemaRestClient.getSchemas(SchemaType.VIRTUAL, AnyTypeKind.GROUP);
- break;
-
- case AnyObjectPlainSchema:
- choices = schemaRestClient.getSchemas(SchemaType.PLAIN, AnyTypeKind.ANY_OBJECT);
- break;
-
- case AnyObjectDerivedSchema:
- choices = schemaRestClient.getSchemas(SchemaType.DERIVED, AnyTypeKind.ANY_OBJECT);
- break;
-
- case AnyObjectVirtualSchema:
- choices = schemaRestClient.getSchemas(SchemaType.VIRTUAL, AnyTypeKind.ANY_OBJECT);
- break;
-
- default:
- choices = Collections.emptyList();
- }
-
- panel = new AjaxPalettePanel.Builder<String>().setName(fieldName).build(
- "value",
- new PropertyModel<List<String>>(reportlet.getConf(), fieldName),
- new ListModel<String>(
- CollectionUtils.collect(
- choices, new Transformer<AbstractSchemaTO, String>() {
-
- @Override
- public String transform(final AbstractSchemaTO input) {
- return input.getKey();
- }
- }, new ArrayList<String>()))).hideLabel();
- } else if (listItemType.isEnum()) {
- panel = new AjaxPalettePanel.Builder<String>().setName(fieldName).build(
- "value",
- new PropertyModel<List<String>>(reportlet.getConf(), fieldName),
- new ListModel(Arrays.asList(listItemType.getEnumConstants()))).hideLabel();
- } else {
- if (((List) wrapper.getPropertyValue(fieldName)).isEmpty()) {
- ((List) wrapper.getPropertyValue(fieldName)).add(null);
- }
-
- panel = new MultiFieldPanel.Builder<String>(
- new PropertyModel<List<String>>(reportlet.getConf(), fieldName)).build(
- "value",
- fieldName,
- buildSinglePanel(field.getType(), fieldName, "panel")).hideLabel();
- }
- } else {
- panel = buildSinglePanel(field.getType(), fieldName, "value").hideLabel();
- }
-
- item.add(panel.setRenderBodyOnly(true));
- }
- });
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private FieldPanel buildSinglePanel(final Class<?> type, final String fieldName, final String id) {
- FieldPanel result = null;
- PropertyModel model = new PropertyModel(reportlet.getConf(), fieldName);
- if (ClassUtils.isAssignable(Boolean.class, type)) {
- result = new AjaxCheckBoxPanel(id, fieldName, model);
- } else if (ClassUtils.isAssignable(Number.class, type)) {
- result = new AjaxSpinnerFieldPanel.Builder<Number>().build(
- id, fieldName, (Class<Number>) ClassUtils.resolvePrimitiveIfNecessary(type), model);
- } else if (Date.class.equals(type)) {
- result = new DateTimeFieldPanel(id, fieldName, model, SyncopeConstants.DEFAULT_DATE_PATTERN);
- } else if (type.isEnum()) {
- result = new AjaxDropDownChoicePanel(id, fieldName, model).setChoices(
- Arrays.asList(type.getEnumConstants()));
- }
-
- // treat as String if nothing matched above
- if (result == null) {
- result = new AjaxTextFieldPanel(id, fieldName, model);
- }
-
- result.hideLabel();
- return result;
+ add(new BeanPanel<>("bean", bean, reportlet.getSCondWrapper(), "name", "reportletClassName").
+ setRenderBodyOnly(true));
}
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/rest/PolicyRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/PolicyRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/PolicyRestClient.java
index c5e8e36..3bfaef6 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/PolicyRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/PolicyRestClient.java
@@ -62,7 +62,7 @@ public class PolicyRestClient extends BaseRestClient {
getService(PolicyService.class).update(policy);
}
- public void delete(final String key, final Class<? extends AbstractPolicyTO> policyClass) {
+ public void delete(final String key) {
getService(PolicyService.class).delete(key);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxPalettePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxPalettePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxPalettePanel.java
index bf16686..4f1f714 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxPalettePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxPalettePanel.java
@@ -41,7 +41,6 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
-import org.apache.wicket.model.util.ListModel;
import org.apache.wicket.util.string.Strings;
public class AjaxPalettePanel<T extends Serializable> extends AbstractFieldPanel<List<T>> {
@@ -73,7 +72,7 @@ public class AjaxPalettePanel<T extends Serializable> extends AbstractFieldPanel
}
public AjaxPalettePanel(
- final String id, final IModel<List<T>> model, final ListModel<T> choices, final Builder<T> builder) {
+ final String id, final IModel<List<T>> model, final IModel<List<T>> choices, final Builder<T> builder) {
super(id, builder.name == null ? id : builder.name, model);
choicesModel = new PaletteLoadableDetachableModel(builder) {
@@ -198,6 +197,10 @@ public class AjaxPalettePanel<T extends Serializable> extends AbstractFieldPanel
return palette.getModelCollection();
}
+ public void reload(final AjaxRequestTarget target) {
+ target.add(palette);
+ }
+
public static class Builder<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 991248996001040352L;
@@ -268,7 +271,7 @@ public class AjaxPalettePanel<T extends Serializable> extends AbstractFieldPanel
return this;
}
- public AjaxPalettePanel<T> build(final String id, final IModel<List<T>> model, final ListModel<T> choices) {
+ public AjaxPalettePanel<T> build(final String id, final IModel<List<T>> model, final IModel<List<T>> choices) {
return new AjaxPalettePanel<>(id, model, choices, this);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.java
new file mode 100644
index 0000000..1f5a159
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.wicket.markup.html.form;
+
+import java.io.Serializable;
+import org.apache.syncope.client.console.panels.AbstractModalPanel;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnLoadHeaderItem;
+import org.apache.wicket.markup.html.form.TextArea;
+import org.apache.wicket.model.IModel;
+
+public class JsonEditorPanel extends AbstractModalPanel<Serializable> {
+
+ private static final long serialVersionUID = -5110368813584745668L;
+
+ private final IModel<String> content;
+
+ public JsonEditorPanel(final IModel<String> content) {
+ this(null, content, null);
+ }
+
+ public JsonEditorPanel(
+ final BaseModal<Serializable> modal,
+ final IModel<String> content,
+ final PageReference pageRef) {
+ super(modal, pageRef);
+ this.content = content;
+ final TextArea<String> jsonEditorInfoDefArea = new TextArea<>("jsonEditorInfo", this.content);
+ jsonEditorInfoDefArea.setMarkupId("jsonEditorInfo").setOutputMarkupPlaceholderTag(true);
+ add(jsonEditorInfoDefArea);
+ }
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(OnLoadHeaderItem.forScript(
+ "CodeMirror.fromTextArea(document.getElementById('jsonEditorInfo'), {"
+ + " lineNumbers: true, "
+ + " lineWrapping: true, "
+ + " matchBrackets: true,"
+ + " autoCloseBrackets: true,"
+ + " autoRefresh: true"
+ + "}).on('change', updateTextArea);"));
+ }
+
+ @Override
+ public IModel<String> getItem() {
+ return content;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.html b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.html
index e76ca31..b96752a 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.html
@@ -22,7 +22,6 @@ under the License.
<section class="content-header">
<h1>
- <small>Work in progress</small>
</h1>
<ol class="breadcrumb">
<li><a wicket:id="dashboardBr"><i class="fa fa-dashboard"></i> <wicket:message key="dashboard"/></a></li>
@@ -31,11 +30,10 @@ under the License.
</ol>
</section>
- <section class="content">
- <div class="progress progress active" style="margin:100px">
- <div style="width: 70%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="20" role="progressbar" class="progress-bar progress-bar-success progress-bar-striped">
- <span class="sr-only">20% Complete</span>
- </div>
+
+ <section class="content" wicket:id="content">
+ <div class="box">
+ <div class="box-body" wicket:id="tabbedPanel"/>
</div>
</section>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.properties
new file mode 100644
index 0000000..1df0602
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+policy.account=Account Policy
+policy.password=Password Policy
+policy.pull=Pull Policy
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_it.properties
new file mode 100644
index 0000000..1df0602
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_it.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+policy.account=Account Policy
+policy.password=Password Policy
+policy.pull=Pull Policy
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_pt_BR.properties
new file mode 100644
index 0000000..1df0602
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_pt_BR.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+policy.account=Account Policy
+policy.password=Password Policy
+policy.pull=Pull Policy
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_ru.properties
new file mode 100644
index 0000000..710e458
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Policies_ru.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# reports=\u00d0\u00a3\u00d0\u00b2\u00d0\u00b5\u00d0\u00b4\u00d0\u00be\u00d0\u00bc\u00d0\u00bb\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d1\u008f
+policy.account=Account Policy
+policy.password=Password Policy
+policy.pull=Pull Policy
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/panels/BeanPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/panels/BeanPanel.html b/client/console/src/main/resources/org/apache/syncope/client/console/panels/BeanPanel.html
new file mode 100644
index 0000000..3d58410
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/panels/BeanPanel.html
@@ -0,0 +1,28 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <div wicket:id="propView">
+ <div class="form-group inforow">
+ <label wicket:id="fieldName">[LABEL]</label>
+ <span wicket:id="value">[value]</span>
+ </div>
+ </div>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.properties
new file mode 100644
index 0000000..5c2d7fa
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+description=Description
+usedByResources=Used By Resource
+usedByRealms=Used By Realm
+passthroughResources=Passthrough Resources
+maxAuthenticationAttempts=Max Authentication Attempts
+propagateSuspension=Propagate Suspension
+historyLength=History Length
+allowNullPassword=Allow Null Password
+policy.rule.conf=Policy '${key}' Rule Configuration
+any.edit=Edit ${key}
+any.new=New Policy
+any.finish=Submit ${key}
+any.cancel=Cancel ${key}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_it.properties
new file mode 100644
index 0000000..2b6d87c
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_it.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+description=Descrizione
+usedByResources=Usata Dalla Risorsa
+usedByRealms=Usata Dal Realm
+passthroughResources=Risorse Passthrough
+maxAuthenticationAttempts=Numero Massimo Tentativi Authenticazione
+propagateSuspension=Propagare Sospensione
+historyLength=Lunghezza Storico
+allowNullPassword=Permetti Password Nulla
+policy.rule.conf=Configurazione Regola Policy '${key}'
+any.edit=Modifica ${key}
+any.new=Nuova Policy
+any.finish=Invia ${key}
+any.cancel=Annulla ${key}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_pt_BR.properties
new file mode 100644
index 0000000..5c2d7fa
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_pt_BR.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+description=Description
+usedByResources=Used By Resource
+usedByRealms=Used By Realm
+passthroughResources=Passthrough Resources
+maxAuthenticationAttempts=Max Authentication Attempts
+propagateSuspension=Propagate Suspension
+historyLength=History Length
+allowNullPassword=Allow Null Password
+policy.rule.conf=Policy '${key}' Rule Configuration
+any.edit=Edit ${key}
+any.new=New Policy
+any.finish=Submit ${key}
+any.cancel=Cancel ${key}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_ru.properties
new file mode 100644
index 0000000..064b0e6
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyDirectoryPanel_ru.properties
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# reports=\u00d0\u00a3\u00d0\u00b2\u00d0\u00b5\u00d0\u00b4\u00d0\u00be\u00d0\u00bc\u00d0\u00bb\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d1\u008f
+description=Description
+usedByResources=Used By Resource
+usedByRealms=Used By Realm
+passthroughResources=Passthrough Resources
+maxAuthenticationAttempts=Max Authentication Attempts
+propagateSuspension=Propagate Suspension
+historyLength=History Length
+allowNullPassword=Allow Null Password
+policy.rule.conf=Policy '${key}' Rule Configuration
+any.edit=Edit ${key}
+any.new=New Policy
+any.finish=Submit ${key}
+any.cancel=Cancel ${key}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder$Profile.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder$Profile.html b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder$Profile.html
new file mode 100644
index 0000000..78bd426
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder$Profile.html
@@ -0,0 +1,27 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <div wicket:id="fields">
+ <div class="form-group">
+ <span wicket:id="field"/>
+ </div>
+ </div>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.properties
new file mode 100644
index 0000000..d55a533
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+ruleConf=Rule
+configuration=Type
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_it.properties
new file mode 100644
index 0000000..1ee8471
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_it.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+ruleConf=Regola
+configuration=Tipo
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_pt_BR.properties
new file mode 100644
index 0000000..d55a533
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_pt_BR.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+ruleConf=Rule
+configuration=Type
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_ru.properties
new file mode 100644
index 0000000..57196fb
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel_ru.properties
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# reports=\u00d0\u00a3\u00d0\u00b2\u00d0\u00b5\u00d0\u00b4\u00d0\u00be\u00d0\u00bc\u00d0\u00bb\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d1\u008f
+ruleConf=Rule
+configuration=Type
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Configuration.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Configuration.html b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Configuration.html
new file mode 100644
index 0000000..7772c93
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Configuration.html
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <span wicket:id="bean"/>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Profile.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Profile.html b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Profile.html
new file mode 100644
index 0000000..5ce9540
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder$Profile.html
@@ -0,0 +1,28 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <div class="form-group">
+ <span wicket:id="name"/>
+ </div>
+ <div class="form-group">
+ <span wicket:id="configuration"/>
+ </div>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel$CorrelationRulePanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel$CorrelationRulePanel.html b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel$CorrelationRulePanel.html
new file mode 100644
index 0000000..eafcadb
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel$CorrelationRulePanel.html
@@ -0,0 +1,32 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <div class="form-group">
+ <span wicket:id="anyType"/>
+ </div>
+ <div class="form-group">
+ <span wicket:id="ruleType"/>
+ </div>
+ <div class="form-group">
+ <span wicket:id="javaRule"/>
+ <span wicket:id="jsonRule"/>
+ </div>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.html b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.html
new file mode 100644
index 0000000..9aaced7
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.html
@@ -0,0 +1,28 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <div class="form-group">
+ <span wicket:id="conflictResolutionAction"/>
+ </div>
+ <div class="form-group">
+ <span wicket:id="correlationRules"/>
+ </div>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.properties
new file mode 100644
index 0000000..18b0ba1
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+rule.java=Java Class
+rule.json=JSON Rule
+rule.type=Rule Type
+JSON=JSON Rule
+JAVA=Java Class
+any.type=Policy Specificaton Target
+correlationRules=Correlation Rules
+conflictResolutionAction=Conflice Resolution Action
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_it.properties
new file mode 100644
index 0000000..7ecc0d6
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_it.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+rule.java=Classe Java
+rule.json=Regola JSON
+rule.type=Tipo Regola
+JSON=Regola JSON
+JAVA=Classe Java
+any.type=Target Specifica Policy
+correlationRules=Regole di Correlazione
+conflictResolutionAction=Azione di Risoluzione Conflitti
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_pt_BR.properties
new file mode 100644
index 0000000..18b0ba1
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_pt_BR.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+rule.java=Java Class
+rule.json=JSON Rule
+rule.type=Rule Type
+JSON=JSON Rule
+JAVA=Java Class
+any.type=Policy Specificaton Target
+correlationRules=Correlation Rules
+conflictResolutionAction=Conflice Resolution Action
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_ru.properties
new file mode 100644
index 0000000..7d84cbe
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/policies/PolicySpecModalPanel_ru.properties
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# reports=\u00d0\u00a3\u00d0\u00b2\u00d0\u00b5\u00d0\u00b4\u00d0\u00be\u00d0\u00bc\u00d0\u00bb\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d1\u008f
+rule.java=Java Class
+rule.json=JSON Rule
+rule.type=Rule Type
+JSON=JSON Rule
+JAVA=Java Class
+any.type=Policy Specificaton Target
+correlationRules=Correlation Rules
+conflictResolutionAction=Conflice Resolution Action
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/reports/ReportletWizardBuilder$Configuration.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/reports/ReportletWizardBuilder$Configuration.html b/client/console/src/main/resources/org/apache/syncope/client/console/reports/ReportletWizardBuilder$Configuration.html
index 3d58410..7772c93 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/reports/ReportletWizardBuilder$Configuration.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/reports/ReportletWizardBuilder$Configuration.html
@@ -18,11 +18,6 @@ under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
- <div wicket:id="propView">
- <div class="form-group inforow">
- <label wicket:id="fieldName">[LABEL]</label>
- <span wicket:id="value">[value]</span>
- </div>
- </div>
+ <span wicket:id="bean"/>
</wicket:panel>
</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.html b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.html
new file mode 100644
index 0000000..e7b558f
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/JsonEditorPanel.html
@@ -0,0 +1,54 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:head>
+ <link rel="stylesheet" type="text/css" href="webjars/codemirror/${codemirror.version}/lib/codemirror.css"/>
+
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/lib/codemirror.js"></script>
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/mode/javascript/javascript.js"></script>
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/addon/display/autorefresh.js"></script>
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/addon/search/search.js"></script>
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/addon/search/searchcursor.js"></script>
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/addon/edit/matchbrackets.js"></script>
+ <script type="text/javascript" src="webjars/codemirror/${codemirror.version}/addon/edit/closebrackets.js"></script>
+ <script type="text/javascript">
+ function updateTextArea(editor) {
+ document.getElementById("jsonEditorInfoDefForm").children["jsonEditorInfo"].value = editor.getValue();
+ }
+ </script>
+ <style>
+ .w_content_3 {
+ padding: 0;
+ color: #333333;
+ font-family: Verdana,Tahoma,sans-serif;
+ font-size: 100%;
+ border: 1px solid #BBBBBB;
+ padding: 1%;
+ }
+ </style>
+ </wicket:head>
+ <wicket:panel>
+ <div style="padding: 1%;">
+ <div class="w_content_3" id="jsonEditorInfoDefForm">
+ <textarea wicket:id="jsonEditorInfo" id="consoleLayoutInfo" name="jsonEditorInfo" style="width: 100%; height: 350px;">
+ </textarea>
+ </div>
+ </div>
+ </wicket:panel>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/common/lib/src/main/java/org/apache/syncope/common/lib/policy/AccountPolicyTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/AccountPolicyTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/AccountPolicyTO.java
index 63b78a9..caf2506 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/policy/AccountPolicyTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/policy/AccountPolicyTO.java
@@ -28,7 +28,7 @@ import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "accountPolicy")
@XmlType
-public class AccountPolicyTO extends AbstractPolicyTO {
+public class AccountPolicyTO extends AbstractPolicyTO implements ComposablePolicy<AbstractAccountRuleConf> {
private static final long serialVersionUID = -1557150042828800134L;
@@ -38,7 +38,7 @@ public class AccountPolicyTO extends AbstractPolicyTO {
private final List<AbstractAccountRuleConf> ruleConfs = new ArrayList<>();
- private final List<String> resources = new ArrayList<>();
+ private final List<String> passthroughResources = new ArrayList<>();
public boolean isPropagateSuspension() {
return propagateSuspension;
@@ -59,14 +59,15 @@ public class AccountPolicyTO extends AbstractPolicyTO {
@XmlElementWrapper(name = "ruleConfs")
@XmlElement(name = "ruleConf")
@JsonProperty("ruleConfs")
+ @Override
public List<AbstractAccountRuleConf> getRuleConfs() {
return ruleConfs;
}
- @XmlElementWrapper(name = "resources")
- @XmlElement(name = "resource")
- @JsonProperty("resources")
- public List<String> getResources() {
- return resources;
+ @XmlElementWrapper(name = "passthroughResources")
+ @XmlElement(name = "passthroughResource")
+ @JsonProperty("passthroughResources")
+ public List<String> getPassthroughResources() {
+ return passthroughResources;
}
}
[3/3] syncope git commit: [SYNCOPE-745] provides policy management +
console integration tests
Posted by fm...@apache.org.
[SYNCOPE-745] provides policy management + console integration tests
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/030d1c24
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/030d1c24
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/030d1c24
Branch: refs/heads/master
Commit: 030d1c24929209e31e318cb5601be36306405207
Parents: 51383dd
Author: fmartelli <fa...@gmail.com>
Authored: Fri May 27 11:22:22 2016 +0200
Committer: fmartelli <fa...@gmail.com>
Committed: Fri May 27 11:22:22 2016 +0200
----------------------------------------------------------------------
.../client/console/commons/Constants.java | 6 +-
.../syncope/client/console/pages/Policies.java | 53 ++
.../client/console/panels/BeanPanel.java | 307 +++++++++
.../policies/AccountPolicyDirectoryPanel.java | 92 +++
.../policies/PasswordPolicyDirectoryPanel.java | 87 +++
.../console/policies/PolicyDirectoryPanel.java | 264 ++++++++
.../policies/PolicyModalPanelBuilder.java | 169 +++++
.../policies/PolicyRuleDirectoryPanel.java | 332 +++++++++
.../policies/PolicyRuleWizardBuilder.java | 170 +++++
.../console/policies/PolicySpecModalPanel.java | 353 ++++++++++
.../policies/PullPolicyDirectoryPanel.java | 78 +++
.../reports/ReportletDirectoryPanel.java | 1 -
.../console/reports/ReportletWizardBuilder.java | 232 +------
.../client/console/rest/PolicyRestClient.java | 2 +-
.../markup/html/form/AjaxPalettePanel.java | 9 +-
.../markup/html/form/JsonEditorPanel.java | 68 ++
.../syncope/client/console/pages/Policies.html | 10 +-
.../client/console/pages/Policies.properties | 19 +
.../client/console/pages/Policies_it.properties | 19 +
.../console/pages/Policies_pt_BR.properties | 19 +
.../client/console/pages/Policies_ru.properties | 21 +
.../client/console/panels/BeanPanel.html | 28 +
.../policies/PolicyDirectoryPanel.properties | 29 +
.../policies/PolicyDirectoryPanel_it.properties | 29 +
.../PolicyDirectoryPanel_pt_BR.properties | 29 +
.../policies/PolicyDirectoryPanel_ru.properties | 31 +
.../PolicyModalPanelBuilder$Profile.html | 27 +
.../PolicyRuleDirectoryPanel.properties | 18 +
.../PolicyRuleDirectoryPanel_it.properties | 18 +
.../PolicyRuleDirectoryPanel_pt_BR.properties | 18 +
.../PolicyRuleDirectoryPanel_ru.properties | 20 +
.../PolicyRuleWizardBuilder$Configuration.html | 23 +
.../PolicyRuleWizardBuilder$Profile.html | 28 +
...licySpecModalPanel$CorrelationRulePanel.html | 32 +
.../console/policies/PolicySpecModalPanel.html | 28 +
.../policies/PolicySpecModalPanel.properties | 24 +
.../policies/PolicySpecModalPanel_it.properties | 24 +
.../PolicySpecModalPanel_pt_BR.properties | 24 +
.../policies/PolicySpecModalPanel_ru.properties | 26 +
.../ReportletWizardBuilder$Configuration.html | 7 +-
.../markup/html/form/JsonEditorPanel.html | 54 ++
.../common/lib/policy/AccountPolicyTO.java | 15 +-
.../common/lib/policy/ComposablePolicy.java | 32 +
.../lib/policy/DefaultAccountRuleConf.java | 4 +
.../lib/policy/DefaultPasswordRuleConf.java | 4 +
.../common/lib/policy/PasswordPolicyTO.java | 3 +-
.../syncope/common/lib/policy/RuleConf.java | 3 +-
.../syncope/common/lib/report/Schema.java | 2 +-
.../apache/syncope/core/logic/SyncopeLogic.java | 4 +-
.../init/ClassPathScanImplementationLookup.java | 18 +-
.../persistence/api/ImplementationLookup.java | 4 +-
.../java/data/PolicyDataBinderImpl.java | 4 +-
.../panels/CamelRoutesDirectoryPanel.java | 11 -
.../fit/core/reference/TestAccountRuleConf.java | 2 +-
.../core/reference/TestPasswordRuleConf.java | 2 +-
.../fit/console/AbstractConsoleITCase.java | 12 +
.../syncope/fit/console/PoliciesITCase.java | 669 +++++++++++++++++++
.../syncope/fit/console/TopologyITCase.java | 18 +-
.../apache/syncope/fit/core/PolicyITCase.java | 4 +-
59 files changed, 3357 insertions(+), 282 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
index 6c6d4fa..19b1ce1 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
@@ -114,6 +114,10 @@ public final class Constants {
public static final String PREF_REPORTLET_TASKS_PAGINATOR_ROWS = "reportlet.paginator.rows";
+ public static final String PREF_POLICY_RULE_PAGINATOR_ROWS = "policy.rules.paginator.rows";
+
+ public static final String PREF_POLICY_PAGINATOR_ROWS = "policy.paginator.rows";
+
public static final String PREF_TASK_EXECS_PAGINATOR_ROWS = "task.execs.paginator.rows";
public static final String PREF_NOTIFICATION_TASKS_PAGINATOR_ROWS = "notificationtasks.paginator.rows";
@@ -134,8 +138,6 @@ public final class Constants {
public static final String PAGEPARAM_CURRENT_PAGE = "_current_page";
- public static final String PREF_POLICY_PAGINATOR_ROWS = "policy.paginator.rows";
-
public static final String PREF_ANY_OBJECT_DETAILS_VIEW = "anyobject.%s.details.view";
public static final String PREF_ANY_OBJECT_PLAIN_ATTRS_VIEW = "anyobject.%s.plain.attrs.view";
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/pages/Policies.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Policies.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Policies.java
index 59cc25f..508c6c8 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Policies.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/Policies.java
@@ -18,7 +18,18 @@
*/
package org.apache.syncope.client.console.pages;
+import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
+import org.apache.syncope.client.console.policies.AccountPolicyDirectoryPanel;
+import org.apache.syncope.client.console.policies.PasswordPolicyDirectoryPanel;
+import org.apache.syncope.client.console.policies.PullPolicyDirectoryPanel;
+import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
+import org.apache.wicket.extensions.markup.html.tabs.ITab;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class Policies extends BasePage {
@@ -29,5 +40,47 @@ public class Policies extends BasePage {
super(parameters);
body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
+
+ WebMarkupContainer content = new WebMarkupContainer("content");
+ content.setOutputMarkupId(true);
+ content.setMarkupId("policies");
+ content.add(new AjaxBootstrapTabbedPanel<>("tabbedPanel", buildTabList()));
+ body.add(content);
+ }
+
+ private List<ITab> buildTabList() {
+ final List<ITab> tabs = new ArrayList<>();
+
+ tabs.add(new AbstractTab(new ResourceModel("policy.account")) {
+
+ private static final long serialVersionUID = -6815067322125799251L;
+
+ @Override
+ public Panel getPanel(final String panelId) {
+ return new AccountPolicyDirectoryPanel(panelId, getPageReference());
+ }
+ });
+
+ tabs.add(new AbstractTab(new ResourceModel("policy.password")) {
+
+ private static final long serialVersionUID = -6815067322125799251L;
+
+ @Override
+ public Panel getPanel(final String panelId) {
+ return new PasswordPolicyDirectoryPanel(panelId, getPageReference());
+ }
+ });
+
+ tabs.add(new AbstractTab(new ResourceModel("policy.pull")) {
+
+ private static final long serialVersionUID = -6815067322125799251L;
+
+ @Override
+ public Panel getPanel(final String panelId) {
+ return new PullPolicyDirectoryPanel(panelId, getPageReference());
+ }
+ });
+
+ return tabs;
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/panels/BeanPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/BeanPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/BeanPanel.java
new file mode 100644
index 0000000..fe09351
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/BeanPanel.java
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.client.console.panels.search.AnyObjectSearchPanel;
+import org.apache.syncope.client.console.panels.search.GroupSearchPanel;
+import org.apache.syncope.client.console.panels.search.SearchClause;
+import org.apache.syncope.client.console.panels.search.SearchUtils;
+import org.apache.syncope.client.console.panels.search.UserSearchPanel;
+import org.apache.syncope.client.console.rest.SchemaRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.DateTimeFieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel;
+import org.apache.syncope.client.lib.SyncopeClient;
+import org.apache.syncope.common.lib.SyncopeConstants;
+import org.apache.syncope.common.lib.report.Schema;
+import org.apache.syncope.common.lib.report.SearchCondition;
+import org.apache.syncope.common.lib.search.AbstractFiqlSearchConditionBuilder;
+import org.apache.syncope.common.lib.to.AbstractSchemaTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.model.util.ListModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.PropertyAccessorFactory;
+import org.springframework.util.ClassUtils;
+
+public class BeanPanel<T extends Serializable> extends Panel {
+
+ private static final long serialVersionUID = 3905038169553185171L;
+
+ protected static final Logger LOG = LoggerFactory.getLogger(BeanPanel.class);
+
+ private final List<String> excluded;
+
+ private final Map<String, Pair<AbstractFiqlSearchConditionBuilder, List<SearchClause>>> sCondWrapper;
+
+ public BeanPanel(final String id, final IModel<T> bean, final String... excluded) {
+ this(id, bean, null, excluded);
+ }
+
+ public BeanPanel(
+ final String id,
+ final IModel<T> bean,
+ final Map<String, Pair<AbstractFiqlSearchConditionBuilder, List<SearchClause>>> sCondWrapper,
+ final String... excluded) {
+ super(id, bean);
+ setOutputMarkupId(true);
+
+ this.sCondWrapper = sCondWrapper;
+
+ this.excluded = new ArrayList<>(Arrays.asList(excluded));
+ this.excluded.add("serialVersionUID");
+ this.excluded.add("class");
+
+ final LoadableDetachableModel<List<String>> model = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ List<String> result = new ArrayList<String>();
+
+ if (BeanPanel.this.getDefaultModelObject() != null) {
+ for (Field field : BeanPanel.this.getDefaultModelObject().getClass().getDeclaredFields()) {
+ if (!BeanPanel.this.excluded.contains(field.getName())) {
+ result.add(field.getName());
+ }
+ }
+ }
+
+ return result;
+ }
+ };
+
+ add(new ListView<String>("propView", model) {
+
+ private static final long serialVersionUID = 9101744072914090143L;
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ final String fieldName = item.getModelObject();
+
+ item.add(new Label("fieldName", new ResourceModel(fieldName, fieldName)));
+
+ Field field = null;
+ try {
+ field = bean.getObject().getClass().getDeclaredField(fieldName);
+ } catch (NoSuchFieldException | SecurityException e) {
+ LOG.error("Could not find field {} in class {}", fieldName, bean.getObject().getClass(), e);
+ }
+
+ if (field == null) {
+ return;
+ }
+
+ final SearchCondition scondAnnot = field.getAnnotation(SearchCondition.class);
+ final Schema schemaAnnot = field.getAnnotation(Schema.class);
+
+ BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(bean.getObject());
+
+ Panel panel;
+
+ if (scondAnnot != null) {
+ final String fiql = (String) wrapper.getPropertyValue(fieldName);
+
+ final List<SearchClause> clauses;
+ if (StringUtils.isEmpty(fiql)) {
+ clauses = new ArrayList<>();
+ } else {
+ clauses = SearchUtils.getSearchClauses(fiql);
+ }
+
+ final AbstractFiqlSearchConditionBuilder builder;
+
+ switch (scondAnnot.type()) {
+ case "USER":
+ panel = new UserSearchPanel.Builder(
+ new ListModel<SearchClause>(clauses)).required(false).build("value");
+ builder = SyncopeClient.getUserSearchConditionBuilder();
+ break;
+ case "GROUP":
+ panel = new GroupSearchPanel.Builder(
+ new ListModel<SearchClause>(clauses)).required(false).build("value");
+ builder = SyncopeClient.getGroupSearchConditionBuilder();
+ break;
+ default:
+ panel = new AnyObjectSearchPanel.Builder(
+ scondAnnot.type(),
+ new ListModel<SearchClause>(clauses)).required(false).build("value");
+ builder = SyncopeClient.getAnyObjectSearchConditionBuilder(null);
+ }
+
+ if (BeanPanel.this.sCondWrapper != null) {
+ BeanPanel.this.sCondWrapper.put(fieldName, Pair.of(builder, clauses));
+ }
+ } else if (List.class.equals(field.getType())) {
+ Class<?> listItemType = String.class;
+ if (field.getGenericType() instanceof ParameterizedType) {
+ listItemType = (Class<?>) ((ParameterizedType) field.getGenericType()).
+ getActualTypeArguments()[0];
+ }
+
+ if (listItemType.equals(String.class) && schemaAnnot != null) {
+ SchemaRestClient schemaRestClient = new SchemaRestClient();
+
+ final List<AbstractSchemaTO> choices = new ArrayList<>();
+
+ for (IntMappingType type : schemaAnnot.type()) {
+ switch (type) {
+ case UserPlainSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.PLAIN, AnyTypeKind.USER));
+ break;
+
+ case UserDerivedSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.DERIVED, AnyTypeKind.USER));
+ break;
+
+ case UserVirtualSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.VIRTUAL, AnyTypeKind.USER));
+ break;
+
+ case GroupPlainSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.PLAIN, AnyTypeKind.GROUP));
+ break;
+
+ case GroupDerivedSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.DERIVED, AnyTypeKind.GROUP));
+ break;
+
+ case GroupVirtualSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.VIRTUAL, AnyTypeKind.GROUP));
+ break;
+
+ case AnyObjectPlainSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.PLAIN, AnyTypeKind.ANY_OBJECT));
+ break;
+
+ case AnyObjectDerivedSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.DERIVED, AnyTypeKind.ANY_OBJECT));
+ break;
+
+ case AnyObjectVirtualSchema:
+ choices.addAll(
+ schemaRestClient.getSchemas(SchemaType.VIRTUAL, AnyTypeKind.ANY_OBJECT));
+ break;
+
+ default:
+ }
+ }
+
+ panel = new AjaxPalettePanel.Builder<String>().setName(fieldName).build(
+ "value",
+ new PropertyModel<List<String>>(bean.getObject(), fieldName),
+ new ListModel<String>(
+ CollectionUtils.collect(
+ choices, new Transformer<AbstractSchemaTO, String>() {
+
+ @Override
+ public String transform(final AbstractSchemaTO input) {
+ return input.getKey();
+ }
+ }, new ArrayList<String>()))).hideLabel();
+ } else if (listItemType.isEnum()) {
+ panel = new AjaxPalettePanel.Builder<String>().setName(fieldName).build(
+ "value",
+ new PropertyModel<List<String>>(bean.getObject(), fieldName),
+ new ListModel(Arrays.asList(listItemType.getEnumConstants()))).hideLabel();
+ } else {
+ if (((List) wrapper.getPropertyValue(fieldName)).isEmpty()) {
+ ((List) wrapper.getPropertyValue(fieldName)).add(null);
+ }
+
+ panel = new MultiFieldPanel.Builder<String>(
+ new PropertyModel<List<String>>(bean.getObject(), fieldName)).build(
+ "value",
+ fieldName,
+ buildSinglePanel(bean.getObject(), field.getType(), fieldName, "panel")).hideLabel();
+ }
+ } else {
+ panel = buildSinglePanel(bean.getObject(), field.getType(), fieldName, "value").hideLabel();
+ }
+
+ item.add(panel.setRenderBodyOnly(true));
+ }
+
+ }.setReuseItems(true).setOutputMarkupId(true));
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private FieldPanel buildSinglePanel(
+ final Serializable bean, final Class<?> type, final String fieldName, final String id) {
+ FieldPanel result = null;
+ PropertyModel model = new PropertyModel(bean, fieldName);
+ if (ClassUtils.isAssignable(Boolean.class, type)) {
+ result = new AjaxCheckBoxPanel(id, fieldName, model);
+ } else if (ClassUtils.isAssignable(Number.class, type)) {
+ result = new AjaxSpinnerFieldPanel.Builder<Number>().build(
+ id, fieldName, (Class<Number>) ClassUtils.resolvePrimitiveIfNecessary(type), model);
+ } else if (Date.class.equals(type)) {
+ result = new DateTimeFieldPanel(id, fieldName, model, SyncopeConstants.DEFAULT_DATE_PATTERN);
+ } else if (type.isEnum()) {
+ result = new AjaxDropDownChoicePanel(id, fieldName, model).setChoices(
+ Arrays.asList(type.getEnumConstants()));
+ }
+
+ // treat as String if nothing matched above
+ if (result == null) {
+ result = new AjaxTextFieldPanel(id, fieldName, model);
+ }
+
+ result.hideLabel();
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/AccountPolicyDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/AccountPolicyDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/AccountPolicyDirectoryPanel.java
new file mode 100644
index 0000000..5671bdd
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/AccountPolicyDirectoryPanel.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import static org.apache.wicket.Component.ENABLE;
+
+import java.util.List;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.CollectionPropertyColumn;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.common.lib.policy.AccountPolicyTO;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.StringResourceModel;
+
+/**
+ * Account policies page.
+ */
+public class AccountPolicyDirectoryPanel extends PolicyDirectoryPanel<AccountPolicyTO> {
+
+ private static final long serialVersionUID = 4984337552918213290L;
+
+ public AccountPolicyDirectoryPanel(final String id, final PageReference pageRef) {
+ super(id, PolicyType.ACCOUNT, pageRef);
+
+ this.addNewItemPanelBuilder(new PolicyModalPanelBuilder<AccountPolicyTO>(
+ new AccountPolicyTO(), modal, pageRef), true);
+ MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.POLICY_CREATE);
+
+ initResultTable();
+ }
+
+ @Override
+ protected void addCustomColumnFields(final List<IColumn<AccountPolicyTO, String>> columns) {
+ columns.add(new CollectionPropertyColumn<AccountPolicyTO>(new StringResourceModel(
+ "passthroughResources", this, null), "passthroughResources", "passthroughResources"));
+
+ columns.add(new PropertyColumn<AccountPolicyTO, String>(new StringResourceModel(
+ "maxAuthenticationAttempts", this, null), "maxAuthenticationAttempts", "maxAuthenticationAttempts"));
+
+ columns.add(new BooleanPropertyColumn<AccountPolicyTO>(new StringResourceModel(
+ "propagateSuspension", this, null), "propagateSuspension", "propagateSuspension"));
+ }
+
+ @Override
+ protected void addCustomActions(
+ final ActionLinksPanel.Builder<AccountPolicyTO> panel, final IModel<AccountPolicyTO> model) {
+ panel.add(new ActionLink<AccountPolicyTO>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final AccountPolicyTO ignore) {
+ target.add(ruleCompositionModal.setContent(new PolicyRuleDirectoryPanel<AccountPolicyTO>(
+ ruleCompositionModal, model.getObject().getKey(), PolicyType.ACCOUNT, pageRef)));
+
+ ruleCompositionModal.header(new StringResourceModel(
+ "policy.rule.conf", AccountPolicyDirectoryPanel.this, Model.of(model.getObject())));
+
+ MetaDataRoleAuthorizationStrategy.authorize(
+ ruleCompositionModal.getForm(), ENABLE, StandardEntitlement.POLICY_UPDATE);
+
+ ruleCompositionModal.show(true);
+ }
+ }, ActionLink.ActionType.COMPOSE, StandardEntitlement.POLICY_UPDATE);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PasswordPolicyDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PasswordPolicyDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PasswordPolicyDirectoryPanel.java
new file mode 100644
index 0000000..c05f983
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PasswordPolicyDirectoryPanel.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import static org.apache.wicket.Component.ENABLE;
+
+import java.util.List;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.common.lib.policy.PasswordPolicyTO;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.StringResourceModel;
+
+/**
+ * Password policies page.
+ */
+public class PasswordPolicyDirectoryPanel extends PolicyDirectoryPanel<PasswordPolicyTO> {
+
+ private static final long serialVersionUID = 4984337552918213290L;
+
+ public PasswordPolicyDirectoryPanel(final String id, final PageReference pageRef) {
+ super(id, PolicyType.PASSWORD, pageRef);
+
+ this.addNewItemPanelBuilder(
+ new PolicyModalPanelBuilder<PasswordPolicyTO>(new PasswordPolicyTO(), modal, pageRef), true);
+ MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.POLICY_CREATE);
+
+ initResultTable();
+ }
+
+ @Override
+ protected void addCustomColumnFields(final List<IColumn<PasswordPolicyTO, String>> columns) {
+ columns.add(new PropertyColumn<PasswordPolicyTO, String>(new StringResourceModel(
+ "historyLength", this, null), "historyLength", "historyLength"));
+
+ columns.add(new BooleanPropertyColumn<PasswordPolicyTO>(new StringResourceModel(
+ "allowNullPassword", this, null), "allowNullPassword", "allowNullPassword"));
+ }
+
+ @Override
+ protected void addCustomActions(
+ final ActionLinksPanel.Builder<PasswordPolicyTO> panel, final IModel<PasswordPolicyTO> model) {
+ panel.add(new ActionLink<PasswordPolicyTO>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final PasswordPolicyTO ignore) {
+ target.add(ruleCompositionModal.setContent(new PolicyRuleDirectoryPanel<PasswordPolicyTO>(
+ ruleCompositionModal, model.getObject().getKey(), PolicyType.PASSWORD, pageRef)));
+
+ ruleCompositionModal.header(new StringResourceModel(
+ "policy.rule.conf", PasswordPolicyDirectoryPanel.this, Model.of(model.getObject())));
+
+ MetaDataRoleAuthorizationStrategy.authorize(
+ ruleCompositionModal.getForm(), ENABLE, StandardEntitlement.POLICY_UPDATE);
+
+ ruleCompositionModal.show(true);
+ }
+ }, ActionLink.ActionType.COMPOSE, StandardEntitlement.POLICY_UPDATE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.java
new file mode 100644
index 0000000..dfce46d
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyDirectoryPanel.java
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.lang3.SerializationUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
+import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
+import org.apache.syncope.client.console.panels.DirectoryPanel;
+import org.apache.syncope.client.console.rest.PolicyRestClient;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.CollectionPropertyColumn;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.KeyPropertyColumn;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.policy.AbstractPolicyTO;
+import org.apache.syncope.common.lib.to.ReportTO;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.model.StringResourceModel;
+
+/**
+ * Policies page.
+ *
+ * @param <T> policy type.
+ */
+public abstract class PolicyDirectoryPanel<T extends AbstractPolicyTO>
+ extends DirectoryPanel<T, T, DirectoryDataProvider<T>, PolicyRestClient> {
+
+ private static final long serialVersionUID = 4984337552918213290L;
+
+ protected final BaseModal<T> ruleCompositionModal = new BaseModal<T>("outer") {
+
+ private static final long serialVersionUID = 389935548143327858L;
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setFooterVisible(false);
+ }
+
+ };
+
+ protected final BaseModal<T> policySpecModal = new BaseModal<T>("outer");
+
+ private final PolicyType policyType;
+
+ public PolicyDirectoryPanel(final String id, final PolicyType policyType, final PageReference pageRef) {
+ super(id, pageRef, true);
+ this.policyType = policyType;
+ this.restClient = new PolicyRestClient();
+
+ ruleCompositionModal.size(Modal.Size.Large);
+ setWindowClosedReloadCallback(ruleCompositionModal);
+ addOuterObject(ruleCompositionModal);
+
+ policySpecModal.size(Modal.Size.Large);
+ policySpecModal.addSubmitButton();
+ setWindowClosedReloadCallback(policySpecModal);
+ addOuterObject(policySpecModal);
+
+ modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
+
+ private static final long serialVersionUID = 8804221891699487129L;
+
+ @Override
+ public void onClose(final AjaxRequestTarget target) {
+ updateResultTable(target);
+ modal.show(false);
+ }
+ });
+
+ setFooterVisibility(true);
+ modal.addSubmitButton();
+ modal.size(Modal.Size.Large);
+ }
+
+ @Override
+ protected List<IColumn<T, String>> getColumns() {
+ final List<IColumn<T, String>> columns = new ArrayList<>();
+
+ columns.add(new KeyPropertyColumn<T>(
+ new StringResourceModel("key", this, null), "key", "key"));
+
+ columns.add(new PropertyColumn<T, String>(new StringResourceModel(
+ "description", this, null), "description", "description"));
+
+ columns.add(new CollectionPropertyColumn<T>(
+ new StringResourceModel("usedByResources", this, null), "usedByResources", "usedByResources"));
+
+ columns.add(new CollectionPropertyColumn<T>(
+ new StringResourceModel("usedByRealms", this, null), "usedByRealms", "usedByRealms"));
+
+ addCustomColumnFields(columns);
+
+ columns.add(new ActionColumn<T, String>(new ResourceModel("actions")) {
+
+ private static final long serialVersionUID = 2054811145491901166L;
+
+ @Override
+ public ActionLinksPanel<T> getActions(final String componentId, final IModel<T> model) {
+
+ final ActionLinksPanel.Builder<T> panel = ActionLinksPanel.<T>builder().
+ add(new ActionLink<T>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final AbstractPolicyTO ignore) {
+ final AbstractPolicyTO clone = SerializationUtils.clone(model.getObject());
+ clone.setKey(null);
+ send(PolicyDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.EditItemActionEvent<>(clone, target));
+ }
+ }, ActionLink.ActionType.CLONE, StandardEntitlement.POLICY_CREATE).
+ add(new ActionLink<T>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final AbstractPolicyTO ignore) {
+ send(PolicyDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.EditItemActionEvent<>(
+ restClient.getPolicy(model.getObject().getKey()), target));
+ }
+ }, ActionLink.ActionType.EDIT, StandardEntitlement.POLICY_UPDATE).
+ add(new ActionLink<T>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final AbstractPolicyTO ignore) {
+ final T policyTO = model.getObject();
+ try {
+ restClient.delete(policyTO.getKey());
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ target.add(container);
+ } catch (SyncopeClientException e) {
+ LOG.error("While deleting {}", policyTO.getKey(), e);
+ error(StringUtils.isBlank(e.getMessage())
+ ? e.getClass().getName() : e.getMessage());
+ }
+ SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+ }
+ }, ActionLink.ActionType.DELETE, StandardEntitlement.POLICY_DELETE);
+
+ addCustomActions(panel, model);
+ return panel.build(componentId);
+ }
+
+ @Override
+ public ActionLinksPanel<ReportTO> getHeader(final String componentId) {
+ final ActionLinksPanel.Builder<ReportTO> panel = ActionLinksPanel.builder();
+
+ return panel.add(new ActionLink<ReportTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final ReportTO ignore) {
+ if (target != null) {
+ target.add(container);
+ }
+ }
+ }, ActionLink.ActionType.RELOAD, StandardEntitlement.TASK_LIST).build(componentId);
+ }
+ });
+
+ return columns;
+ }
+
+ protected void addCustomColumnFields(final List<IColumn<T, String>> columns) {
+ }
+
+ protected void addCustomActions(final ActionLinksPanel.Builder<T> panel, final IModel<T> model) {
+ }
+
+ @Override
+ protected Collection<ActionType> getBulkActions() {
+ final List<ActionType> bulkActions = new ArrayList<>();
+ bulkActions.add(ActionType.EXECUTE);
+ bulkActions.add(ActionType.DELETE);
+ return bulkActions;
+ }
+
+ @Override
+ protected PolicyDataProvider dataProvider() {
+ return new PolicyDataProvider(rows);
+ }
+
+ @Override
+ protected String paginatorRowsKey() {
+ return Constants.PREF_POLICY_PAGINATOR_ROWS;
+ }
+
+ protected class PolicyDataProvider extends DirectoryDataProvider<T> {
+
+ private static final long serialVersionUID = 4725679400450513556L;
+
+ private final SortableDataProviderComparator<T> comparator;
+
+ public PolicyDataProvider(final int paginatorRows) {
+ super(paginatorRows);
+
+ setSort("description", SortOrder.DESCENDING);
+ comparator = new SortableDataProviderComparator<>(this);
+ }
+
+ @Override
+ public Iterator<T> iterator(final long first, final long count) {
+ List<T> list = restClient.getPolicies(policyType);
+ Collections.sort(list, comparator);
+ return list.subList((int) first, (int) first + (int) count).iterator();
+ }
+
+ @Override
+ public long size() {
+ return restClient.getPolicies(policyType).size();
+ }
+
+ @Override
+ public IModel<T> model(final T object) {
+ return new CompoundPropertyModel<>(object);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java
new file mode 100644
index 0000000..1c99859
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.panels.AbstractModalPanel;
+import org.apache.syncope.client.console.panels.WizardModalPanel;
+import org.apache.syncope.client.console.rest.PolicyRestClient;
+import org.apache.syncope.client.console.rest.ResourceRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.syncope.client.console.wizards.AbstractModalPanelBuilder;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
+import org.apache.syncope.common.lib.policy.AbstractPolicyTO;
+import org.apache.syncope.common.lib.policy.AccountPolicyTO;
+import org.apache.syncope.common.lib.policy.PasswordPolicyTO;
+import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.wicket.Component;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.util.ListModel;
+
+public class PolicyModalPanelBuilder<T extends AbstractPolicyTO> extends AbstractModalPanelBuilder<T> {
+
+ private static final long serialVersionUID = 5945391813567245081L;
+
+ private final BaseModal<T> modal;
+
+ private final PolicyRestClient restClient = new PolicyRestClient();
+
+ public PolicyModalPanelBuilder(final T policyTO, final BaseModal<T> modal, final PageReference pageRef) {
+ super(policyTO, pageRef);
+ this.modal = modal;
+ }
+
+ @Override
+ public WizardModalPanel<T> build(final String id, final int index, final AjaxWizard.Mode mode) {
+ return new Profile(newModelObject(), modal, pageRef);
+ }
+
+ public class Profile extends AbstractModalPanel<T> {
+
+ private static final long serialVersionUID = -3043839139187792810L;
+
+ private final T policyTO;
+
+ private final LoadableDetachableModel<List<String>> resources = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ return CollectionUtils.collect(
+ new ResourceRestClient().list(),
+ new Transformer<ResourceTO, String>() {
+
+ @Override
+ public String transform(final ResourceTO input) {
+ return input.getKey();
+ }
+ }, new ArrayList<String>());
+ }
+ };
+
+ public Profile(final T policyTO, final BaseModal<T> modal, final PageReference pageRef) {
+ super(modal, pageRef);
+ modal.setFormModel(policyTO);
+
+ this.policyTO = policyTO;
+
+ final List<Component> components = new ArrayList<>();
+
+ components.add(new AjaxTextFieldPanel(
+ "field", "description", new PropertyModel<String>(policyTO, "description"), false));
+
+ if (policyTO instanceof AccountPolicyTO) {
+ components.add(new AjaxSpinnerFieldPanel.Builder<Integer>().build(
+ "field",
+ "maxAuthenticationAttempts",
+ Integer.class,
+ new PropertyModel<Integer>(policyTO, "maxAuthenticationAttempts")));
+
+ components.add(new AjaxCheckBoxPanel(
+ "field",
+ "propagateSuspension",
+ new PropertyModel<Boolean>(policyTO, "propagateSuspension"),
+ false));
+
+ components.add(new AjaxPalettePanel.Builder<String>().setName("passthroughResources").build(
+ "field",
+ new PropertyModel<List<String>>(policyTO, "passthroughResources"),
+ new ListModel<String>(resources.getObject())));
+ }
+
+ if (policyTO instanceof PasswordPolicyTO) {
+ components.add(new AjaxSpinnerFieldPanel.Builder<Integer>().build(
+ "field",
+ "historyLength",
+ Integer.class,
+ new PropertyModel<Integer>(policyTO, "historyLength")));
+
+ components.add(new AjaxCheckBoxPanel(
+ "field",
+ "allowNullPassword",
+ new PropertyModel<Boolean>(policyTO, "allowNullPassword"),
+ false));
+ }
+
+ add(new ListView<Component>("fields", components) {
+
+ private static final long serialVersionUID = -9180479401817023838L;
+
+ @Override
+ protected void populateItem(final ListItem<Component> item) {
+ item.add(item.getModelObject());
+ }
+
+ });
+ }
+
+ @Override
+ public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ try {
+ if (policyTO.getKey() == null) {
+ restClient.createPolicy(policyTO);
+ } else {
+ restClient.updatePolicy(policyTO);
+ }
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ Profile.this.modal.close(target);
+ } catch (Exception e) {
+ LOG.error("While creating/updating policy", e);
+ error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
+ }
+ SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.java
new file mode 100644
index 0000000..2d1ce5e
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleDirectoryPanel.java
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Predicate;
+import org.apache.commons.collections4.Transformer;
+import org.apache.commons.lang3.SerializationUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
+import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
+import org.apache.syncope.client.console.panels.DirectoryPanel;
+import org.apache.syncope.client.console.panels.ModalPanel;
+import org.apache.syncope.client.console.policies.PolicyRuleDirectoryPanel.PolicyRuleWrapper;
+import org.apache.syncope.client.console.rest.PolicyRestClient;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.policy.AbstractPolicyTO;
+import org.apache.syncope.common.lib.policy.RuleConf;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
+import org.apache.wicket.core.util.lang.PropertyResolver;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.model.StringResourceModel;
+
+/**
+ * Policy rules page.
+ *
+ * @param <T> policy type.
+ */
+public class PolicyRuleDirectoryPanel<T extends AbstractPolicyTO> extends DirectoryPanel<
+ PolicyRuleWrapper, PolicyRuleWrapper, DirectoryDataProvider<PolicyRuleWrapper>, PolicyRestClient>
+ implements ModalPanel {
+
+ private static final long serialVersionUID = 4984337552918213290L;
+
+ private final BaseModal<T> baseModal;
+
+ private final String policy;
+
+ protected PolicyRuleDirectoryPanel(
+ final BaseModal<T> baseModal, final String policy, final PolicyType type, final PageReference pageRef) {
+ super(BaseModal.CONTENT_ID, pageRef, false);
+
+ disableCheckBoxes();
+
+ this.baseModal = baseModal;
+ this.policy = policy;
+ this.restClient = new PolicyRestClient();
+
+ enableExitButton();
+
+ this.addNewItemPanelBuilder(new PolicyRuleWizardBuilder(policy, type, new PolicyRuleWrapper(), pageRef), true);
+
+ MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.POLICY_UPDATE);
+ initResultTable();
+ }
+
+ @Override
+ protected List<IColumn<PolicyRuleWrapper, String>> getColumns() {
+ final List<IColumn<PolicyRuleWrapper, String>> columns = new ArrayList<>();
+
+ columns.add(new PropertyColumn<PolicyRuleWrapper, String>(
+ new StringResourceModel("ruleConf", this, null), "name", "name"));
+
+ columns.add(new AbstractColumn<PolicyRuleWrapper, String>(
+ new StringResourceModel("configuration", this, null)) {
+
+ private static final long serialVersionUID = -4008579357070833846L;
+
+ @Override
+ public void populateItem(
+ final Item<ICellPopulator<PolicyRuleWrapper>> cellItem,
+ final String componentId,
+ final IModel<PolicyRuleWrapper> rowModel) {
+ cellItem.add(new Label(componentId, rowModel.getObject().getConf().getClass().getName()));
+ }
+ });
+
+ columns.add(new ActionColumn<PolicyRuleWrapper, String>(new ResourceModel("actions")) {
+
+ private static final long serialVersionUID = 2054811145491901166L;
+
+ @Override
+ public ActionLinksPanel<PolicyRuleWrapper> getActions(final String componentId,
+ final IModel<PolicyRuleWrapper> model) {
+
+ final ActionLinksPanel<PolicyRuleWrapper> panel = ActionLinksPanel.<PolicyRuleWrapper>builder().
+ add(new ActionLink<PolicyRuleWrapper>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final PolicyRuleWrapper ignore) {
+ RuleConf clone = SerializationUtils.clone(model.getObject().getConf());
+
+ send(PolicyRuleDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.EditItemActionEvent<>(
+ new PolicyRuleWrapper().setConf(clone),
+ target));
+ }
+ }, ActionLink.ActionType.CLONE, StandardEntitlement.POLICY_UPDATE).
+ add(new ActionLink<PolicyRuleWrapper>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final PolicyRuleWrapper ignore) {
+ send(PolicyRuleDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.EditItemActionEvent<>(model.getObject(), target));
+ }
+ }, ActionLink.ActionType.EDIT, StandardEntitlement.POLICY_UPDATE).
+ add(new ActionLink<PolicyRuleWrapper>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final PolicyRuleWrapper ignore) {
+ final RuleConf rule = model.getObject().getConf();
+ try {
+ final T actual = restClient.getPolicy(policy);
+ CollectionUtils.filter(getRuleConf(actual), new Predicate<RuleConf>() {
+
+ @Override
+ public boolean evaluate(final RuleConf object) {
+ return !object.getName().equals(rule.getName());
+ }
+ });
+ restClient.updatePolicy(actual);
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ customActionOnCloseCallback(target);
+ } catch (SyncopeClientException e) {
+ LOG.error("While deleting {}", rule.getName(), e);
+ error(StringUtils.isBlank(e.getMessage())
+ ? e.getClass().getName() : e.getMessage());
+ }
+ SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+ }
+ }, ActionLink.ActionType.DELETE, StandardEntitlement.POLICY_UPDATE).build(componentId);
+
+ return panel;
+ }
+
+ @Override
+ public ActionLinksPanel<PolicyRuleWrapper> getHeader(final String componentId) {
+ final ActionLinksPanel.Builder<PolicyRuleWrapper> panel = ActionLinksPanel.builder();
+
+ return panel.add(new ActionLink<PolicyRuleWrapper>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final PolicyRuleWrapper ignore) {
+ if (target != null) {
+ customActionOnCloseCallback(target);
+ }
+ }
+ }, ActionLink.ActionType.RELOAD, StandardEntitlement.TASK_LIST).build(componentId);
+ }
+ });
+
+ return columns;
+ }
+
+ @Override
+ protected Collection<ActionType> getBulkActions() {
+ final List<ActionType> bulkActions = new ArrayList<>();
+ bulkActions.add(ActionType.DELETE);
+ return bulkActions;
+ }
+
+ @Override
+ protected PolicyRuleDataProvider dataProvider() {
+ return new PolicyRuleDataProvider(rows);
+ }
+
+ @Override
+ protected String paginatorRowsKey() {
+ return Constants.PREF_POLICY_RULE_PAGINATOR_ROWS;
+ }
+
+ protected class PolicyRuleDataProvider extends DirectoryDataProvider<PolicyRuleWrapper> {
+
+ private static final long serialVersionUID = 4725679400450513556L;
+
+ private final SortableDataProviderComparator<PolicyRuleWrapper> comparator;
+
+ public PolicyRuleDataProvider(final int paginatorRows) {
+ super(paginatorRows);
+
+ //Default sorting
+ setSort("name", SortOrder.DESCENDING);
+ comparator = new SortableDataProviderComparator<>(this);
+ }
+
+ @Override
+ public Iterator<PolicyRuleWrapper> iterator(final long first, final long count) {
+ final T actual = restClient.getPolicy(policy);
+
+ final ArrayList<PolicyRuleWrapper> rules = CollectionUtils.collect(getRuleConf(actual),
+ new Transformer<RuleConf, PolicyRuleWrapper>() {
+
+ @Override
+ public PolicyRuleWrapper transform(final RuleConf input) {
+ return new PolicyRuleWrapper(input.getName()).setName(input.getName()).setConf(input);
+ }
+ }, new ArrayList<PolicyRuleWrapper>());
+
+ Collections.sort(rules, comparator);
+ return rules.subList((int) first, (int) (first + count)).iterator();
+ }
+
+ @Override
+ public long size() {
+ final T actual = restClient.getPolicy(policy);
+ return getRuleConf(actual).size();
+ }
+
+ @Override
+ public IModel<PolicyRuleWrapper> model(final PolicyRuleWrapper object) {
+ return new CompoundPropertyModel<>(object);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<RuleConf> getRuleConf(final T policyTO) {
+ Object res = PropertyResolver.getValue("ruleConfs", policyTO);
+ if (res instanceof List) {
+ return (List<RuleConf>) res;
+ } else {
+ return null;
+ }
+ }
+
+ public static class PolicyRuleWrapper implements Serializable {
+
+ private static final long serialVersionUID = 2472755929742424558L;
+
+ private String oldname;
+
+ private String name;
+
+ private RuleConf conf;
+
+ public PolicyRuleWrapper() {
+ this(null);
+ }
+
+ public PolicyRuleWrapper(final String name) {
+ this.oldname = name;
+ }
+
+ public boolean isNew() {
+ return oldname == null;
+ }
+
+ public String getOldName() {
+ return this.oldname;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public PolicyRuleWrapper setName(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public RuleConf getConf() {
+ return conf;
+ }
+
+ public PolicyRuleWrapper setConf(final RuleConf conf) {
+ this.conf = conf;
+ return this;
+ }
+ }
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ super.onEvent(event);
+ if (event.getPayload() instanceof ExitEvent && modal != null) {
+ final AjaxRequestTarget target = ExitEvent.class.cast(event.getPayload()).getTarget();
+ baseModal.show(false);
+ baseModal.close(target);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/030d1c24/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder.java
new file mode 100644
index 0000000..6854cf1
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyRuleWizardBuilder.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.policies;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Predicate;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.panels.BeanPanel;
+import org.apache.syncope.client.console.rest.PolicyRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.syncope.client.console.wizards.AjaxWizardBuilder;
+import org.apache.syncope.common.lib.policy.AbstractPolicyTO;
+import org.apache.syncope.common.lib.policy.ComposablePolicy;
+import org.apache.syncope.common.lib.policy.RuleConf;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.extensions.wizard.WizardModel;
+import org.apache.wicket.extensions.wizard.WizardStep;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.PropertyModel;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.PropertyAccessorFactory;
+
+public class PolicyRuleWizardBuilder
+ extends AjaxWizardBuilder<PolicyRuleDirectoryPanel.PolicyRuleWrapper> {
+
+ private static final long serialVersionUID = 5945391813567245081L;
+
+ private final PolicyRestClient restClient = new PolicyRestClient();
+
+ private final String policy;
+
+ private final PolicyType type;
+
+ public PolicyRuleWizardBuilder(
+ final String policy,
+ final PolicyType type,
+ final PolicyRuleDirectoryPanel.PolicyRuleWrapper reportlet,
+ final PageReference pageRef) {
+ super(reportlet, pageRef);
+ this.policy = policy;
+ this.type = type;
+ }
+
+ @Override
+ protected Serializable onApplyInternal(final PolicyRuleDirectoryPanel.PolicyRuleWrapper modelObject) {
+ BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(modelObject.getConf());
+ wrapper.setPropertyValue("name", modelObject.getName());
+
+ AbstractPolicyTO policyTO = restClient.getPolicy(policy);
+
+ final ComposablePolicy<RuleConf> composable;
+ if (policyTO instanceof ComposablePolicy) {
+ composable = (ComposablePolicy<RuleConf>) policyTO;
+ } else {
+ throw new IllegalStateException("Non composable policy");
+ }
+
+ if (modelObject.isNew()) {
+ composable.getRuleConfs().add(modelObject.getConf());
+ } else {
+ CollectionUtils.filter(
+ composable.getRuleConfs(), new Predicate<RuleConf>() {
+
+ @Override
+ public boolean evaluate(final RuleConf object) {
+ return !object.getName().equals(modelObject.getOldName());
+ }
+ });
+ composable.getRuleConfs().add(modelObject.getConf());
+ }
+
+ restClient.updatePolicy(policyTO);
+ return modelObject;
+ }
+
+ @Override
+ protected WizardModel buildModelSteps(
+ final PolicyRuleDirectoryPanel.PolicyRuleWrapper modelObject, final WizardModel wizardModel) {
+ wizardModel.add(new Profile(modelObject));
+ wizardModel.add(new Configuration(modelObject));
+ return wizardModel;
+ }
+
+ public class Profile extends WizardStep {
+
+ private static final long serialVersionUID = -3043839139187792810L;
+
+ public Profile(final PolicyRuleDirectoryPanel.PolicyRuleWrapper rule) {
+
+ final AjaxTextFieldPanel name = new AjaxTextFieldPanel(
+ "name", "rule", new PropertyModel<String>(rule, "name"), false);
+ name.addRequiredLabel();
+ add(name);
+
+ final AjaxDropDownChoicePanel<String> conf = new AjaxDropDownChoicePanel<>(
+ "configuration", "configuration", new PropertyModel<String>(rule, "conf") {
+
+ private static final long serialVersionUID = -6427731218492117883L;
+
+ @Override
+ public String getObject() {
+ return rule.getConf() == null ? null : rule.getConf().getClass().getName();
+ }
+
+ @Override
+ public void setObject(final String object) {
+ RuleConf conf = null;
+
+ try {
+ conf = RuleConf.class.cast(Class.forName(object).newInstance());
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
+ LOG.warn("Error retrieving reportlet configuration instance", e);
+ }
+
+ rule.setConf(conf);
+ }
+ });
+
+ if (type == PolicyType.ACCOUNT) {
+ conf.setChoices(new ArrayList<>(SyncopeConsoleSession.get().getPlatformInfo().getAccountRules()));
+ } else if (type == PolicyType.PASSWORD) {
+ conf.setChoices(new ArrayList<>(SyncopeConsoleSession.get().getPlatformInfo().getPasswordRules()));
+ }
+
+ conf.addRequiredLabel();
+ add(conf);
+ }
+ }
+
+ public class Configuration extends WizardStep {
+
+ private static final long serialVersionUID = -785981096328637758L;
+
+ private final LoadableDetachableModel<Serializable> bean;
+
+ public Configuration(final PolicyRuleDirectoryPanel.PolicyRuleWrapper rule) {
+ bean = new LoadableDetachableModel<Serializable>() {
+
+ private static final long serialVersionUID = 2092144708018739371L;
+
+ @Override
+ protected Serializable load() {
+ return rule.getConf();
+ }
+ };
+
+ add(new BeanPanel("bean", bean).setRenderBodyOnly(true));
+ }
+ }
+}