You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by sk...@apache.org on 2020/03/09 16:17:25 UTC
[syncope] branch SYNCOPE-163-1 updated: [SYNCOPE-163] Added Access,
Authentication and AttrRelease policies to Realm object
This is an automated email from the ASF dual-hosted git repository.
skylark17 pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/SYNCOPE-163-1 by this push:
new 1a7186c [SYNCOPE-163] Added Access, Authentication and AttrRelease policies to Realm object
1a7186c is described below
commit 1a7186c56a9f5e852b74405c7477070bd5dc57a2
Author: skylark17 <sk...@apache.org>
AuthorDate: Mon Mar 9 17:17:13 2020 +0100
[SYNCOPE-163] Added Access, Authentication and AttrRelease policies to Realm object
---
.../syncope/common/lib/to/AccessPolicyTO.java | 1 -
.../syncope/common/lib/to/AttrReleasePolicyTO.java | 6 +-
.../org/apache/syncope/common/lib/to/RealmTO.java | 36 +++++++++
.../api/entity/policy/AccessPolicy.java | 1 -
.../src/test/resources/domains/MasterContent.xml | 5 ++
.../jpa/entity/policy/JPAAccessPolicy.java | 4 +-
.../jpa/entity/policy/JPAAttrReleasePolicy.java | 14 ++--
.../src/test/resources/domains/MasterContent.xml | 2 +-
.../java/data/RealmDataBinderImpl.java | 86 +++++++++++++++++++++-
.../org/apache/syncope/fit/core/PolicyITCase.java | 60 ++++++++-------
.../org/apache/syncope/fit/core/RealmITCase.java | 6 ++
11 files changed, 176 insertions(+), 45 deletions(-)
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AccessPolicyTO.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AccessPolicyTO.java
index c0182e4..c555106 100644
--- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AccessPolicyTO.java
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AccessPolicyTO.java
@@ -21,7 +21,6 @@ package org.apache.syncope.common.lib.to;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.syncope.common.lib.policy.PolicyTO;
-
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java
index e0f8144..2394da9 100644
--- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java
@@ -16,13 +16,11 @@
* under the License.
*
*/
-
package org.apache.syncope.common.lib.to;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.syncope.common.lib.policy.PolicyTO;
-
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
@@ -35,11 +33,9 @@ public class AttrReleasePolicyTO extends PolicyTO {
@XmlTransient
@JsonProperty("@class")
- @Schema(name = "@class", required = true,
- example = "org.apache.syncope.common.lib.to.AttrReleasePolicyTO")
+ @Schema(name = "@class", required = true, example = "org.apache.syncope.common.lib.to.AttrReleasePolicyTO")
@Override
public String getDiscriminator() {
return getClass().getName();
}
}
-
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/RealmTO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/RealmTO.java
index 910043f..e0514eb 100644
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/RealmTO.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/RealmTO.java
@@ -54,6 +54,12 @@ public class RealmTO extends BaseBean implements NamedEntityTO, TemplatableTO {
private String passwordPolicy;
+ private String authenticationPolicy;
+
+ private String accessPolicy;
+
+ private String attrReleasePolicy;
+
private final List<String> actions = new ArrayList<>();
@XmlJavaTypeAdapter(XmlGenericMapAdapter.class)
@@ -114,6 +120,30 @@ public class RealmTO extends BaseBean implements NamedEntityTO, TemplatableTO {
this.passwordPolicy = passwordPolicy;
}
+ public String getAuthenticationPolicy() {
+ return authenticationPolicy;
+ }
+
+ public void setAuthenticationPolicy(final String authenticationPolicy) {
+ this.authenticationPolicy = authenticationPolicy;
+ }
+
+ public String getAccessPolicy() {
+ return accessPolicy;
+ }
+
+ public void setAccessPolicy(final String accessPolicy) {
+ this.accessPolicy = accessPolicy;
+ }
+
+ public String getAttrReleasePolicy() {
+ return attrReleasePolicy;
+ }
+
+ public void setAttrReleasePolicy(final String attrReleasePolicy) {
+ this.attrReleasePolicy = attrReleasePolicy;
+ }
+
@XmlElementWrapper(name = "actions")
@XmlElement(name = "action")
@JsonProperty("actions")
@@ -153,6 +183,9 @@ public class RealmTO extends BaseBean implements NamedEntityTO, TemplatableTO {
append(fullPath, other.fullPath).
append(accountPolicy, other.accountPolicy).
append(passwordPolicy, other.passwordPolicy).
+ append(authenticationPolicy, other.authenticationPolicy).
+ append(accessPolicy, other.accessPolicy).
+ append(attrReleasePolicy, other.attrReleasePolicy).
append(actions, other.actions).
append(templates, other.templates).
append(resources, other.resources).
@@ -168,6 +201,9 @@ public class RealmTO extends BaseBean implements NamedEntityTO, TemplatableTO {
append(fullPath).
append(accountPolicy).
append(passwordPolicy).
+ append(authenticationPolicy).
+ append(accessPolicy).
+ append(attrReleasePolicy).
append(actions).
append(templates).
append(resources).
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java
index 69d481a..f57fc83 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java
@@ -19,7 +19,6 @@
package org.apache.syncope.core.persistence.api.entity.policy;
import org.apache.syncope.core.persistence.api.entity.Implementation;
-
import java.util.List;
public interface AccessPolicy extends Policy {
diff --git a/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml
index 62eee58..c8a5d7c 100644
--- a/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml
@@ -59,6 +59,11 @@ under the License.
<AccessPolicy id="419935c7-deb3-40b3-8a9a-683037e523a2" name="MyDefaultAccessPolicyConf"
description="an access policy" />
+ <!-- Attr Release Policies -->
+ <Implementation id="AllowedAttrReleasePolicyConf" type="ATTR_RELEASE_CONFIGURATIONS" engine="JAVA"
+ body='{"@class":"org.apache.syncope.common.lib.attrs.AllowedAttrReleasePolicyConf","name":"AllowedAttrReleasePolicy","allowedAttributes":["cn","givenName","uid"]}'/>
+ <AttrReleasePolicy id="319935c7-deb3-40b3-8a9a-683037e523a2" name="AllowedAttrReleasePolicy"
+ description="allowed attribute release policy policy" />
<RelationshipType id="inclusion" description="Models the act that an object is included in another"/>
<RelationshipType id="neighborhood" description="Models the act that an object is near another"/>
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java
index 63e83b6..97add50 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java
@@ -49,11 +49,11 @@ public class JPAAccessPolicy extends AbstractPolicy implements AccessPolicy {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = TABLE + "Conf",
joinColumns =
- @JoinColumn(name = "authentication_policy_id"),
+ @JoinColumn(name = "access_policy_id"),
inverseJoinColumns =
@JoinColumn(name = "implementation_id"),
uniqueConstraints =
- @UniqueConstraint(columnNames = { "authentication_policy_id", "implementation_id" }))
+ @UniqueConstraint(columnNames = { "access_policy_id", "implementation_id" }))
private List<JPAImplementation> configurations = new ArrayList<>();
@Override
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java
index e5f65c6..412b968 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java
@@ -48,12 +48,12 @@ public class JPAAttrReleasePolicy extends AbstractPolicy implements AttrReleaseP
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = TABLE + "Conf",
- joinColumns =
- @JoinColumn(name = "attr_release_policy_id"),
- inverseJoinColumns =
- @JoinColumn(name = "implementation_id"),
- uniqueConstraints =
- @UniqueConstraint(columnNames = {"attr_release_policy_id", "implementation_id"}))
+ joinColumns =
+ @JoinColumn(name = "attr_release_policy_id"),
+ inverseJoinColumns =
+ @JoinColumn(name = "implementation_id"),
+ uniqueConstraints =
+ @UniqueConstraint(columnNames = { "attr_release_policy_id", "implementation_id" }))
private List<JPAImplementation> configurations = new ArrayList<>();
@Override
@@ -76,6 +76,6 @@ public class JPAAttrReleasePolicy extends AbstractPolicy implements AttrReleaseP
checkType(configuration, JPAImplementation.class);
checkImplementationType(configuration, AMImplementationType.ATTR_RELEASE_POLICY_CONFIGURATIONS);
return configurations.contains((JPAImplementation) configuration)
- || configurations.add((JPAImplementation) configuration);
+ || configurations.add((JPAImplementation) configuration);
}
}
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index 5857d2c..1fcaf58 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -63,7 +63,7 @@ under the License.
<Implementation id="AllowedAttrReleasePolicyConf" type="ATTR_RELEASE_CONFIGURATIONS" engine="JAVA"
body='{"@class":"org.apache.syncope.common.lib.attrs.AllowedAttrReleasePolicyConf","name":"AllowedAttrReleasePolicy","allowedAttributes":["cn","givenName","uid"]}'/>
<AttrReleasePolicy id="319935c7-deb3-40b3-8a9a-683037e523a2" name="AllowedAttrReleasePolicy"
- description="allowed attribute release policy policy" />
+ description="allowed attribute release policy policy" />
<Implementation id="DenyAttrReleasePolicyConf" type="ATTR_RELEASE_CONFIGURATIONS" engine="JAVA"
body='{"@class":"org.apache.syncope.common.lib.attrs.AllowedAttrReleasePolicyConf","name":"DenyAttrReleasePolicyConf"}'/>
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java
index 236027c..e42ab1d 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java
@@ -36,6 +36,9 @@ import org.apache.syncope.core.persistence.api.entity.EntityFactory;
import org.apache.syncope.core.persistence.api.entity.Implementation;
import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
import org.apache.syncope.core.persistence.api.entity.Realm;
+import org.apache.syncope.core.persistence.api.entity.policy.AccessPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.AttrReleasePolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
import org.apache.syncope.core.persistence.api.entity.policy.Policy;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
import org.apache.syncope.core.provisioning.api.data.RealmDataBinder;
@@ -67,9 +70,6 @@ public class RealmDataBinderImpl implements RealmDataBinder {
@Autowired
private EntityFactory entityFactory;
- @Autowired
- private TemplateUtils templateUtils;
-
private void setTemplates(final RealmTO realmTO, final Realm realm) {
// validate JEXL expressions from templates and proceed if fine
TemplateUtils.check(realmTO.getTemplates(), ClientExceptionType.InvalidRealm);
@@ -123,6 +123,39 @@ public class RealmDataBinderImpl implements RealmDataBinder {
throw sce;
}
}
+ if (realmTO.getAuthenticationPolicy() != null) {
+ Policy policy = policyDAO.find(realmTO.getAuthenticationPolicy());
+ if (policy instanceof AuthenticationPolicy) {
+ realm.setAuthenticationPolicy((AuthenticationPolicy) policy);
+ } else {
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
+ sce.getElements().add("Expected " + AuthenticationPolicy.class.getSimpleName()
+ + ", found " + policy.getClass().getSimpleName());
+ throw sce;
+ }
+ }
+ if (realmTO.getAccessPolicy() != null) {
+ Policy policy = policyDAO.find(realmTO.getAccessPolicy());
+ if (policy instanceof AccessPolicy) {
+ realm.setAccessPolicy((AccessPolicy) policy);
+ } else {
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
+ sce.getElements().add("Expected " + AccessPolicy.class.getSimpleName()
+ + ", found " + policy.getClass().getSimpleName());
+ throw sce;
+ }
+ }
+ if (realmTO.getAttrReleasePolicy() != null) {
+ Policy policy = policyDAO.find(realmTO.getAttrReleasePolicy());
+ if (policy instanceof AttrReleasePolicy) {
+ realm.setAttrReleasePolicy((AttrReleasePolicy) policy);
+ } else {
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
+ sce.getElements().add("Expected " + AttrReleasePolicy.class.getSimpleName()
+ + ", found " + policy.getClass().getSimpleName());
+ throw sce;
+ }
+ }
realmTO.getActions().forEach(logicActionsKey -> {
Implementation logicAction = implementationDAO.find(logicActionsKey);
@@ -180,6 +213,48 @@ public class RealmDataBinderImpl implements RealmDataBinder {
}
}
+ if (realmTO.getAuthenticationPolicy() == null) {
+ realm.setAuthenticationPolicy(null);
+ } else {
+ Policy policy = policyDAO.find(realmTO.getAuthenticationPolicy());
+ if (policy instanceof AuthenticationPolicy) {
+ realm.setAuthenticationPolicy((AuthenticationPolicy) policy);
+ } else {
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
+ sce.getElements().add("Expected " + AuthenticationPolicy.class.getSimpleName()
+ + ", found " + policy.getClass().getSimpleName());
+ throw sce;
+ }
+ }
+
+ if (realmTO.getAccessPolicy() == null) {
+ realm.setAccessPolicy(null);
+ } else {
+ Policy policy = policyDAO.find(realmTO.getAccessPolicy());
+ if (policy instanceof AccessPolicy) {
+ realm.setAccessPolicy((AccessPolicy) policy);
+ } else {
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
+ sce.getElements().add("Expected " + AccessPolicy.class.getSimpleName()
+ + ", found " + policy.getClass().getSimpleName());
+ throw sce;
+ }
+ }
+
+ if (realmTO.getAttrReleasePolicy() == null) {
+ realm.setAttrReleasePolicy(null);
+ } else {
+ Policy policy = policyDAO.find(realmTO.getAttrReleasePolicy());
+ if (policy instanceof AttrReleasePolicy) {
+ realm.setAttrReleasePolicy((AttrReleasePolicy) policy);
+ } else {
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
+ sce.getElements().add("Expected " + AttrReleasePolicy.class.getSimpleName()
+ + ", found " + policy.getClass().getSimpleName());
+ throw sce;
+ }
+ }
+
realmTO.getActions().forEach(logicActionsKey -> {
Implementation logicActions = implementationDAO.find(logicActionsKey);
if (logicActions == null) {
@@ -228,6 +303,11 @@ public class RealmDataBinderImpl implements RealmDataBinder {
if (admin) {
realmTO.setAccountPolicy(realm.getAccountPolicy() == null ? null : realm.getAccountPolicy().getKey());
realmTO.setPasswordPolicy(realm.getPasswordPolicy() == null ? null : realm.getPasswordPolicy().getKey());
+ realmTO.setAuthenticationPolicy(
+ realm.getAuthenticationPolicy() == null ? null : realm.getAuthenticationPolicy().getKey());
+ realmTO.setAccessPolicy(realm.getAccessPolicy() == null ? null : realm.getAccessPolicy().getKey());
+ realmTO.setAttrReleasePolicy(
+ realm.getAttrReleasePolicy() == null ? null : realm.getAttrReleasePolicy().getKey());
realm.getActions().forEach(action -> realmTO.getActions().add(action.getKey()));
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 be722ba..7102f4b 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
@@ -69,7 +69,7 @@ public class PolicyITCase extends AbstractITCase {
ImplementationTO implementationTO = null;
try {
implementationTO = implementationService.read(
- AMImplementationType.AUTH_POLICY_CONFIGURATIONS, authPolicyName);
+ AMImplementationType.AUTH_POLICY_CONFIGURATIONS, authPolicyName);
} catch (SyncopeClientException e) {
if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
implementationTO = new ImplementationTO();
@@ -83,7 +83,7 @@ public class PolicyITCase extends AbstractITCase {
Response response = implementationService.create(implementationTO);
implementationTO = implementationService.read(
- implementationTO.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
+ implementationTO.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(implementationTO);
}
}
@@ -100,7 +100,7 @@ public class PolicyITCase extends AbstractITCase {
ImplementationTO implementationTO = null;
try {
implementationTO = implementationService.read(
- AMImplementationType.ATTR_RELEASE_POLICY_CONFIGURATIONS, policyName);
+ AMImplementationType.ATTR_RELEASE_POLICY_CONFIGURATIONS, policyName);
} catch (SyncopeClientException e) {
if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
implementationTO = new ImplementationTO();
@@ -115,7 +115,7 @@ public class PolicyITCase extends AbstractITCase {
Response response = implementationService.create(implementationTO);
implementationTO = implementationService.read(
- implementationTO.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
+ implementationTO.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(implementationTO);
}
}
@@ -134,7 +134,7 @@ public class PolicyITCase extends AbstractITCase {
ImplementationTO implementationTO = null;
try {
implementationTO = implementationService.read(
- AMImplementationType.ACCESS_POLICY_CONFIGURATIONS, accessPolicyName);
+ AMImplementationType.ACCESS_POLICY_CONFIGURATIONS, accessPolicyName);
} catch (SyncopeClientException e) {
if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
implementationTO = new ImplementationTO();
@@ -150,7 +150,7 @@ public class PolicyITCase extends AbstractITCase {
Response response = implementationService.create(implementationTO);
implementationTO = implementationService.read(
- implementationTO.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
+ implementationTO.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(implementationTO);
}
}
@@ -174,10 +174,10 @@ public class PolicyITCase extends AbstractITCase {
corrRule.setEngine(ImplementationEngine.GROOVY);
corrRule.setType(IdMImplementationType.PULL_CORRELATION_RULE);
corrRule.setBody(IOUtils.toString(
- getClass().getResourceAsStream("/TestPullRule.groovy"), StandardCharsets.UTF_8));
+ getClass().getResourceAsStream("/TestPullRule.groovy"), StandardCharsets.UTF_8));
Response response = implementationService.create(corrRule);
corrRule = implementationService.read(
- corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
+ corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(corrRule);
}
}
@@ -201,10 +201,10 @@ public class PolicyITCase extends AbstractITCase {
corrRule.setEngine(ImplementationEngine.GROOVY);
corrRule.setType(IdMImplementationType.PUSH_CORRELATION_RULE);
corrRule.setBody(IOUtils.toString(
- getClass().getResourceAsStream("/TestPushRule.groovy"), StandardCharsets.UTF_8));
+ getClass().getResourceAsStream("/TestPushRule.groovy"), StandardCharsets.UTF_8));
Response response = implementationService.create(corrRule);
corrRule = implementationService.read(
- corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
+ corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(corrRule);
}
}
@@ -254,7 +254,7 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void getAuthenticationPolicy() {
AuthenticationPolicyTO policyTO =
- policyService.read(PolicyType.AUTHENTICATION, "659b9906-4b6e-4bc0-aca0-6809dff346d4");
+ policyService.read(PolicyType.AUTHENTICATION, "659b9906-4b6e-4bc0-aca0-6809dff346d4");
assertNotNull(policyTO);
assertTrue(policyTO.getUsedByRealms().isEmpty());
@@ -263,7 +263,16 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void getAccessPolicy() {
AccessPolicyTO policyTO =
- policyService.read(PolicyType.ACCESS, "419935c7-deb3-40b3-8a9a-683037e523a2");
+ policyService.read(PolicyType.ACCESS, "419935c7-deb3-40b3-8a9a-683037e523a2");
+
+ assertNotNull(policyTO);
+ assertTrue(policyTO.getUsedByRealms().isEmpty());
+ }
+
+ @Test
+ public void getAttributeReleasePolicy() {
+ AttrReleasePolicyTO policyTO =
+ policyService.read(PolicyType.ATTR_RELEASE, "319935c7-deb3-40b3-8a9a-683037e523a2");
assertNotNull(policyTO);
assertTrue(policyTO.getUsedByRealms().isEmpty());
@@ -280,7 +289,7 @@ public class PolicyITCase extends AbstractITCase {
assertEquals("TestPushRule", pushPolicyTO.getCorrelationRules().get(AnyTypeKind.USER.name()));
AuthenticationPolicyTO authenticationPolicyTO = createPolicy(PolicyType.AUTHENTICATION,
- buildAuthenticationPolicyTO());
+ buildAuthenticationPolicyTO());
assertNotNull(authenticationPolicyTO);
assertEquals("Test Authentication policy", authenticationPolicyTO.getDescription());
@@ -302,7 +311,7 @@ public class PolicyITCase extends AbstractITCase {
assertNotEquals("ce93fcda-dc3a-4369-a7b0-a6108c261c85", policy.getKey());
ImplementationTO rule = implementationService.read(
- IdRepoImplementationType.PASSWORD_RULE, policy.getRules().get(0));
+ IdRepoImplementationType.PASSWORD_RULE, policy.getRules().get(0));
assertNotNull(rule);
DefaultPasswordRuleConf ruleConf = POJOHelper.deserialize(rule.getBody(), DefaultPasswordRuleConf.class);
@@ -326,12 +335,12 @@ public class PolicyITCase extends AbstractITCase {
newAuthPolicyTO = createPolicy(PolicyType.AUTHENTICATION, newAuthPolicyTO);
ImplementationTO authPolicyImplementationTO = implementationService.read(
- AMImplementationType.AUTH_POLICY_CONFIGURATIONS, "MyDefaultAuthenticationPolicyConf");
+ AMImplementationType.AUTH_POLICY_CONFIGURATIONS, "MyDefaultAuthenticationPolicyConf");
assertNotNull(authPolicyImplementationTO);
assertFalse(StringUtils.isBlank(authPolicyImplementationTO.getBody()));
DefaultAuthenticationPolicyConf authPolicyConf =
- POJOHelper.deserialize(authPolicyImplementationTO.getBody(), DefaultAuthenticationPolicyConf.class);
+ POJOHelper.deserialize(authPolicyImplementationTO.getBody(), DefaultAuthenticationPolicyConf.class);
assertNotNull(authPolicyConf);
authPolicyConf.getAuthenticationModules().add("LdapAuthentication");
authPolicyImplementationTO.setBody(POJOHelper.serialize(authPolicyConf));
@@ -341,7 +350,8 @@ public class PolicyITCase extends AbstractITCase {
newAuthPolicyTO = policyService.read(PolicyType.AUTHENTICATION, newAuthPolicyTO.getKey());
assertNotNull(newAuthPolicyTO);
- authPolicyConf = POJOHelper.deserialize(authPolicyImplementationTO.getBody(), DefaultAuthenticationPolicyConf.class);
+ authPolicyConf = POJOHelper.deserialize(authPolicyImplementationTO.getBody(),
+ DefaultAuthenticationPolicyConf.class);
assertNotNull(authPolicyConf);
assertEquals(2, authPolicyConf.getAuthenticationModules().size());
assertTrue(authPolicyConf.getAuthenticationModules().contains("LdapAuthentication"));
@@ -350,7 +360,7 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void updateAccessPolicy() {
AccessPolicyTO globalAccessPolicyTO =
- policyService.read(PolicyType.ACCESS, "419935c7-deb3-40b3-8a9a-683037e523a2");
+ policyService.read(PolicyType.ACCESS, "419935c7-deb3-40b3-8a9a-683037e523a2");
assertNotNull(globalAccessPolicyTO);
AccessPolicyTO newAccessPolicyTO = buildAccessPolicyTO();
@@ -358,12 +368,12 @@ public class PolicyITCase extends AbstractITCase {
assertNotNull(newAccessPolicyTO);
ImplementationTO accessPolicyImplementationTO = implementationService.read(
- AMImplementationType.ACCESS_POLICY_CONFIGURATIONS, "MyDefaultAccessPolicyConf");
+ AMImplementationType.ACCESS_POLICY_CONFIGURATIONS, "MyDefaultAccessPolicyConf");
assertNotNull(accessPolicyImplementationTO);
assertFalse(StringUtils.isBlank(accessPolicyImplementationTO.getBody()));
DefaultAccessPolicyConf accessPolicyConf =
- POJOHelper.deserialize(accessPolicyImplementationTO.getBody(), DefaultAccessPolicyConf.class);
+ POJOHelper.deserialize(accessPolicyImplementationTO.getBody(), DefaultAccessPolicyConf.class);
assertNotNull(accessPolicyConf);
accessPolicyConf.getRequiredAttributes().put("ou", List.of("test"));
accessPolicyConf.getRequiredAttributes().put("cn", List.of("admin", "Admin"));
@@ -384,7 +394,7 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void updateAttrReleasePolicy() {
AttrReleasePolicyTO policyTO =
- policyService.read(PolicyType.ATTR_RELEASE, "319935c7-deb3-40b3-8a9a-683037e523a2");
+ policyService.read(PolicyType.ATTR_RELEASE, "319935c7-deb3-40b3-8a9a-683037e523a2");
assertNotNull(policyTO);
final String policyName = "TestAttrReleasePolicy" + getUUIDString();
@@ -393,12 +403,12 @@ public class PolicyITCase extends AbstractITCase {
assertNotNull(newPolicyTO);
ImplementationTO implementationTO = implementationService.read(
- AMImplementationType.ATTR_RELEASE_POLICY_CONFIGURATIONS, policyName);
+ AMImplementationType.ATTR_RELEASE_POLICY_CONFIGURATIONS, policyName);
assertNotNull(implementationTO);
assertFalse(StringUtils.isBlank(implementationTO.getBody()));
AllowedAttrReleasePolicyConf policyConf =
- POJOHelper.deserialize(implementationTO.getBody(), AllowedAttrReleasePolicyConf.class);
+ POJOHelper.deserialize(implementationTO.getBody(), AllowedAttrReleasePolicyConf.class);
assertNotNull(policyConf);
policyConf.setAllowedAttributes(List.of("cn", "givenName", "postalCode"));
implementationTO.setBody(POJOHelper.serialize(policyConf));
@@ -464,7 +474,7 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void getPullCorrelationRuleJavaClasses() {
Set<String> classes = syncopeService.platform().
- getJavaImplInfo(IdMImplementationType.PULL_CORRELATION_RULE).get().getClasses();
+ getJavaImplInfo(IdMImplementationType.PULL_CORRELATION_RULE).get().getClasses();
assertEquals(1, classes.size());
assertEquals(DummyPullCorrelationRule.class.getName(), classes.iterator().next());
}
@@ -472,7 +482,7 @@ public class PolicyITCase extends AbstractITCase {
@Test
public void getPushCorrelationRuleJavaClasses() {
Set<String> classes = syncopeService.platform().
- getJavaImplInfo(IdMImplementationType.PUSH_CORRELATION_RULE).get().getClasses();
+ getJavaImplInfo(IdMImplementationType.PUSH_CORRELATION_RULE).get().getClasses();
assertEquals(1, classes.size());
assertEquals(DummyPushCorrelationRule.class.getName(), classes.iterator().next());
}
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RealmITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RealmITCase.java
index 1d8d5bc..7f3f7e4 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RealmITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RealmITCase.java
@@ -99,11 +99,17 @@ public class RealmITCase extends AbstractITCase {
// 2. update setting policies
actual.setAccountPolicy("06e2ed52-6966-44aa-a177-a0ca7434201f");
actual.setPasswordPolicy("986d1236-3ac5-4a19-810c-5ab21d79cba1");
+ actual.setAuthenticationPolicy("b912a0d4-a890-416f-9ab8-84ab077eb028");
+ actual.setAccessPolicy("419935c7-deb3-40b3-8a9a-683037e523a2");
+ actual.setAttrReleasePolicy("319935c7-deb3-40b3-8a9a-683037e523a2");
realmService.update(actual);
actual = getRealm(actual.getFullPath()).get();
assertNotNull(actual.getAccountPolicy());
assertNotNull(actual.getPasswordPolicy());
+ assertNotNull(actual.getAuthenticationPolicy());
+ assertNotNull(actual.getAccessPolicy());
+ assertNotNull(actual.getAttrReleasePolicy());
// 3. update changing parent
actual.setParent(getRealm("/odd").get().getKey());