syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [04/13] syncope git commit: [SYNCOPE-620] server logic in, tests missing
Date Thu, 08 Jan 2015 13:17:24 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAConfDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAConfDAO.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAConfDAO.java
index d38b1cd..5e7bc83 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAConfDAO.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAConfDAO.java
@@ -22,10 +22,10 @@ import org.apache.syncope.common.lib.types.AttributableType;
 import org.apache.syncope.persistence.api.dao.ConfDAO;
 import org.apache.syncope.persistence.api.dao.PlainAttrDAO;
 import org.apache.syncope.persistence.api.dao.PlainSchemaDAO;
+import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
 import org.apache.syncope.persistence.api.entity.conf.CPlainAttr;
 import org.apache.syncope.persistence.api.entity.conf.CPlainSchema;
 import org.apache.syncope.persistence.api.entity.conf.Conf;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttr;
 import org.apache.syncope.persistence.jpa.entity.conf.JPAConf;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +41,9 @@ public class JPAConfDAO extends AbstractDAO<Conf, Long> implements ConfDAO {
     @Autowired
     private PlainAttrDAO attrDAO;
 
+    @Autowired
+    private AttributableUtilFactory attrUtilFactory;
+
     @Override
     public Conf get() {
         Conf instance = entityManager.find(JPAConf.class, 1L);
@@ -68,7 +71,7 @@ public class JPAConfDAO extends AbstractDAO<Conf, Long> implements ConfDAO {
             result = new JPACPlainAttr();
             result.setSchema(schemaDAO.find(key, CPlainSchema.class));
 
-            result.addValue(defaultValue, JPAAttributableUtil.getInstance(AttributableType.CONFIGURATION));
+            result.addValue(defaultValue, attrUtilFactory.getInstance(AttributableType.CONFIGURATION));
         }
 
         return result;

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPARoleDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPARoleDAO.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPARoleDAO.java
index 5e6209c..8ac1423 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPARoleDAO.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPARoleDAO.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import javax.persistence.TypedQuery;
@@ -31,12 +32,14 @@ import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.persistence.api.RoleEntitlementUtil;
 import org.apache.syncope.persistence.api.dao.DerAttrDAO;
 import org.apache.syncope.persistence.api.dao.EntitlementDAO;
+import org.apache.syncope.persistence.api.dao.NotFoundException;
 import org.apache.syncope.persistence.api.dao.PlainAttrDAO;
 import org.apache.syncope.persistence.api.dao.RoleDAO;
 import org.apache.syncope.persistence.api.dao.UserDAO;
 import org.apache.syncope.persistence.api.dao.VirAttrDAO;
 import org.apache.syncope.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.persistence.api.entity.AttrTemplate;
+import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
 import org.apache.syncope.persistence.api.entity.DerAttr;
 import org.apache.syncope.persistence.api.entity.Entitlement;
 import org.apache.syncope.persistence.api.entity.ExternalResource;
@@ -60,9 +63,10 @@ import org.apache.syncope.persistence.api.entity.role.RVirAttr;
 import org.apache.syncope.persistence.api.entity.role.RVirAttrTemplate;
 import org.apache.syncope.persistence.api.entity.role.Role;
 import org.apache.syncope.persistence.api.entity.user.User;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.apache.syncope.persistence.jpa.entity.membership.JPAMembership;
 import org.apache.syncope.persistence.jpa.entity.role.JPARole;
+import org.apache.syncope.server.security.AuthContextUtil;
+import org.apache.syncope.server.security.UnauthorizedRoleException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
@@ -85,6 +89,9 @@ public class JPARoleDAO extends AbstractSubjectDAO<RPlainAttr, RDerAttr, RVirAtt
     @Autowired
     private EntitlementDAO entitlementDAO;
 
+    @Autowired
+    private AttributableUtilFactory attrUtilFactory;
+
     @Override
     protected Subject<RPlainAttr, RDerAttr, RVirAttr> findInternal(final Long key) {
         return find(key);
@@ -321,27 +328,27 @@ public class JPARoleDAO extends AbstractSubjectDAO<RPlainAttr, RDerAttr, RVirAtt
     @Override
     public List<Role> findByAttrValue(final String schemaName, final RPlainAttrValue attrValue) {
         return (List<Role>) findByAttrValue(
-                schemaName, attrValue, JPAAttributableUtil.getInstance(AttributableType.ROLE));
+                schemaName, attrValue, attrUtilFactory.getInstance(AttributableType.ROLE));
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public Role findByAttrUniqueValue(final String schemaName, final RPlainAttrValue attrUniqueValue) {
         return (Role) findByAttrUniqueValue(schemaName, attrUniqueValue,
-                JPAAttributableUtil.getInstance(AttributableType.ROLE));
+                attrUtilFactory.getInstance(AttributableType.ROLE));
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public List<Role> findByDerAttrValue(final String schemaName, final String value) {
         return (List<Role>) findByDerAttrValue(
-                schemaName, value, JPAAttributableUtil.getInstance(AttributableType.ROLE));
+                schemaName, value, attrUtilFactory.getInstance(AttributableType.ROLE));
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public List<Role> findByResource(final ExternalResource resource) {
-        return (List<Role>) findByResource(resource, JPAAttributableUtil.getInstance(AttributableType.ROLE));
+        return (List<Role>) findByResource(resource, attrUtilFactory.getInstance(AttributableType.ROLE));
     }
 
     @Override
@@ -528,4 +535,23 @@ public class JPARoleDAO extends AbstractSubjectDAO<RPlainAttr, RDerAttr, RVirAtt
 
         delete(role);
     }
+
+    @Override
+    public Role authFetchRole(Long key) {
+        if (key == null) {
+            throw new NotFoundException("Null role id");
+        }
+
+        Role role = find(key);
+        if (role == null) {
+            throw new NotFoundException("Role " + key);
+        }
+
+        Set<Long> allowedRoleIds = RoleEntitlementUtil.getRoleKeys(AuthContextUtil.getOwnedEntitlementNames());
+        if (!allowedRoleIds.contains(role.getKey())) {
+            throw new UnauthorizedRoleException(role.getKey());
+        }
+        return role;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPASubjectSearchDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPASubjectSearchDAO.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPASubjectSearchDAO.java
index 86e596f..e71488d 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPASubjectSearchDAO.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPASubjectSearchDAO.java
@@ -46,10 +46,10 @@ import org.apache.syncope.persistence.api.dao.search.ResourceCond;
 import org.apache.syncope.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.persistence.api.dao.search.SubjectCond;
 import org.apache.syncope.persistence.api.entity.AttributableUtil;
+import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
 import org.apache.syncope.persistence.api.entity.PlainAttrValue;
 import org.apache.syncope.persistence.api.entity.PlainSchema;
 import org.apache.syncope.persistence.api.entity.Subject;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
@@ -69,6 +69,9 @@ public class JPASubjectSearchDAO extends AbstractDAO<Subject<?, ?, ?>, Long> imp
     @Autowired
     private PlainSchemaDAO schemaDAO;
 
+    @Autowired
+    private AttributableUtilFactory attrUtilFactory;
+
     private String getAdminRolesFilter(final Set<Long> adminRoles, final SubjectType type) {
         final StringBuilder adminRolesFilter = new StringBuilder();
 
@@ -272,7 +275,7 @@ public class JPASubjectSearchDAO extends AbstractDAO<Subject<?, ?, ?>, Long> imp
     private OrderBySupport parseOrderBy(final SubjectType type, final SearchSupport svs,
             final List<OrderByClause> orderByClauses) {
 
-        final AttributableUtil attrUtil = JPAAttributableUtil.getInstance(type.asAttributableType());
+        final AttributableUtil attrUtil = attrUtilFactory.getInstance(type.asAttributableType());
 
         OrderBySupport orderBySupport = new OrderBySupport();
 
@@ -598,7 +601,7 @@ public class JPASubjectSearchDAO extends AbstractDAO<Subject<?, ?, ?>, Long> imp
     private String getQuery(final AttributeCond cond, final boolean not, final List<Object> parameters,
             final SubjectType type, final SearchSupport svs) {
 
-        final AttributableUtil attrUtil = JPAAttributableUtil.getInstance(type.asAttributableType());
+        final AttributableUtil attrUtil = attrUtilFactory.getInstance(type.asAttributableType());
 
         PlainSchema schema = schemaDAO.find(cond.getSchema(), attrUtil.plainSchemaClass());
         if (schema == null) {
@@ -647,7 +650,7 @@ public class JPASubjectSearchDAO extends AbstractDAO<Subject<?, ?, ?>, Long> imp
     private String getQuery(final SubjectCond cond, final boolean not, final List<Object> parameters,
             final SubjectType type, final SearchSupport svs) {
 
-        final AttributableUtil attrUtil = JPAAttributableUtil.getInstance(type.asAttributableType());
+        final AttributableUtil attrUtil = attrUtilFactory.getInstance(type.asAttributableType());
 
         Field subjectField = ReflectionUtils.findField(attrUtil.attributableClass(), cond.getSchema());
         if (subjectField == null) {
@@ -664,7 +667,7 @@ public class JPASubjectSearchDAO extends AbstractDAO<Subject<?, ?, ?>, Long> imp
         }
 
         // Deal with subject Integer fields logically mapping to boolean values
-        // (SyncopeRole.inheritAttrs, for example)
+        // (SyncopeRole.inheritPlainAttrs, for example)
         boolean foundBooleanMin = false;
         boolean foundBooleanMax = false;
         if (Integer.class.equals(subjectField.getType())) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAUserDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAUserDAO.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAUserDAO.java
index 2c141a6..fd28fcd 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAUserDAO.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/JPAUserDAO.java
@@ -21,10 +21,13 @@ package org.apache.syncope.persistence.jpa.dao;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import javax.annotation.Resource;
 import javax.persistence.NoResultException;
 import javax.persistence.TypedQuery;
 import org.apache.syncope.common.lib.types.AttributableType;
 import org.apache.syncope.common.lib.types.SubjectType;
+import org.apache.syncope.persistence.api.RoleEntitlementUtil;
+import org.apache.syncope.persistence.api.dao.NotFoundException;
 import org.apache.syncope.persistence.api.dao.RoleDAO;
 import org.apache.syncope.persistence.api.dao.SubjectSearchDAO;
 import org.apache.syncope.persistence.api.dao.UserDAO;
@@ -32,6 +35,7 @@ import org.apache.syncope.persistence.api.dao.search.AttributeCond;
 import org.apache.syncope.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.persistence.api.dao.search.SubjectCond;
+import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
 import org.apache.syncope.persistence.api.entity.ExternalResource;
 import org.apache.syncope.persistence.api.entity.Subject;
 import org.apache.syncope.persistence.api.entity.VirAttr;
@@ -42,8 +46,9 @@ import org.apache.syncope.persistence.api.entity.user.UPlainAttr;
 import org.apache.syncope.persistence.api.entity.user.UPlainAttrValue;
 import org.apache.syncope.persistence.api.entity.user.UVirAttr;
 import org.apache.syncope.persistence.api.entity.user.User;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.apache.syncope.persistence.jpa.entity.user.JPAUser;
+import org.apache.syncope.server.security.AuthContextUtil;
+import org.apache.syncope.server.security.UnauthorizedRoleException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
@@ -56,6 +61,12 @@ public class JPAUserDAO extends AbstractSubjectDAO<UPlainAttr, UDerAttr, UVirAtt
     @Autowired
     private RoleDAO roleDAO;
 
+    @Resource(name = "anonymousUser")
+    private String anonymousUser;
+
+    @Autowired
+    private AttributableUtilFactory attrUtilFactory;
+
     @Override
     protected Subject<UPlainAttr, UDerAttr, UVirAttr> findInternal(Long key) {
         return find(key);
@@ -138,27 +149,27 @@ public class JPAUserDAO extends AbstractSubjectDAO<UPlainAttr, UDerAttr, UVirAtt
     @Override
     public List<User> findByAttrValue(final String schemaName, final UPlainAttrValue attrValue) {
         return (List<User>) findByAttrValue(
-                schemaName, attrValue, JPAAttributableUtil.getInstance(AttributableType.USER));
+                schemaName, attrValue, attrUtilFactory.getInstance(AttributableType.USER));
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public User findByAttrUniqueValue(final String schemaName, final UPlainAttrValue attrUniqueValue) {
         return (User) findByAttrUniqueValue(schemaName, attrUniqueValue,
-                JPAAttributableUtil.getInstance(AttributableType.USER));
+                attrUtilFactory.getInstance(AttributableType.USER));
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public List<User> findByDerAttrValue(final String schemaName, final String value) {
         return (List<User>) findByDerAttrValue(
-                schemaName, value, JPAAttributableUtil.getInstance(AttributableType.USER));
+                schemaName, value, attrUtilFactory.getInstance(AttributableType.USER));
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public List<User> findByResource(final ExternalResource resource) {
-        return (List<User>) findByResource(resource, JPAAttributableUtil.getInstance(AttributableType.USER));
+        return (List<User>) findByResource(resource, attrUtilFactory.getInstance(AttributableType.USER));
     }
 
     @Override
@@ -222,4 +233,52 @@ public class JPAUserDAO extends AbstractSubjectDAO<UPlainAttr, UDerAttr, UVirAtt
 
         entityManager.remove(user);
     }
+
+    private void securityChecks(final User user) {
+        // Allows anonymous (during self-registration) and self (during self-update) to read own SyncopeUser,
+        // otherwise goes thorugh security checks to see if needed role entitlements are owned
+        if (!AuthContextUtil.getAuthenticatedUsername().equals(anonymousUser)
+                && !AuthContextUtil.getAuthenticatedUsername().equals(user.getUsername())) {
+
+            Set<Long> roleIds = user.getRoleIds();
+            Set<Long> adminRoleIds = RoleEntitlementUtil.getRoleKeys(AuthContextUtil.getOwnedEntitlementNames());
+            roleIds.removeAll(adminRoleIds);
+            if (!roleIds.isEmpty()) {
+                throw new UnauthorizedRoleException(roleIds);
+            }
+        }
+    }
+
+    @Override
+    public User authFecthUser(final Long key) {
+        if (key == null) {
+            throw new NotFoundException("Null user id");
+        }
+
+        User user = find(key);
+        if (user == null) {
+            throw new NotFoundException("User " + key);
+        }
+
+        securityChecks(user);
+
+        return user;
+    }
+
+    @Override
+    public User authFecthUser(final String username) {
+        if (username == null) {
+            throw new NotFoundException("Null username");
+        }
+
+        User user = find(username);
+        if (user == null) {
+            throw new NotFoundException("User " + username);
+        }
+
+        securityChecks(user);
+
+        return user;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractEntity.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractEntity.java
index 720b62b..8bde455 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractEntity.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractEntity.java
@@ -19,7 +19,6 @@
 package org.apache.syncope.persistence.jpa.entity;
 
 import java.beans.PropertyDescriptor;
-import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.HashSet;
@@ -31,7 +30,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 
-public abstract class AbstractEntity<KEY> implements Entity<KEY>, Serializable {
+public abstract class AbstractEntity<KEY> implements Entity<KEY> {
 
     private static final long serialVersionUID = -9017214159540857901L;
 
@@ -41,7 +40,7 @@ public abstract class AbstractEntity<KEY> implements Entity<KEY>, Serializable {
     protected static final Logger LOG = LoggerFactory.getLogger(AbstractEntity.class);
 
     protected void checkType(final Object object, final Class<?> clazz) {
-        if (object !=null && !clazz.isInstance(object)) {
+        if (object != null && !clazz.isInstance(object)) {
             throw new ClassCastException("Expected " + clazz.getName() + ", got " + object.getClass().getName());
         }
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
index 2705285..8b42b17 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
@@ -21,6 +21,12 @@ package org.apache.syncope.persistence.jpa.entity;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import org.apache.syncope.common.lib.to.AbstractAttributableTO;
+import org.apache.syncope.common.lib.to.AbstractSubjectTO;
+import org.apache.syncope.common.lib.to.ConfTO;
+import org.apache.syncope.common.lib.to.MembershipTO;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.lib.types.AttributableType;
 import org.apache.syncope.common.lib.types.IntMappingType;
 import org.apache.syncope.common.lib.types.MappingPurpose;
@@ -36,10 +42,6 @@ import org.apache.syncope.persistence.api.entity.PlainAttrValue;
 import org.apache.syncope.persistence.api.entity.PlainSchema;
 import org.apache.syncope.persistence.api.entity.VirAttr;
 import org.apache.syncope.persistence.api.entity.VirSchema;
-import org.apache.syncope.persistence.api.entity.conf.Conf;
-import org.apache.syncope.persistence.api.entity.membership.Membership;
-import org.apache.syncope.persistence.api.entity.role.Role;
-import org.apache.syncope.persistence.api.entity.user.User;
 import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttr;
 import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttrUniqueValue;
 import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttrValue;
@@ -81,7 +83,6 @@ import org.apache.syncope.persistence.jpa.entity.user.JPAUVirAttr;
 import org.apache.syncope.persistence.jpa.entity.user.JPAUVirSchema;
 import org.apache.syncope.persistence.jpa.entity.user.JPAUser;
 import org.apache.syncope.server.spring.BeanUtils;
-import org.identityconnectors.framework.common.objects.ObjectClass;
 import org.identityconnectors.framework.common.objects.Uid;
 import org.slf4j.LoggerFactory;
 
@@ -93,55 +94,9 @@ public class JPAAttributableUtil implements AttributableUtil {
      */
     private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(AttributableUtil.class);
 
-    public static AttributableUtil getInstance(final AttributableType type) {
-        return new JPAAttributableUtil(type);
-    }
-
-    public static AttributableUtil valueOf(final String name) {
-        return new JPAAttributableUtil(AttributableType.valueOf(name));
-    }
-
-    public static AttributableUtil getInstance(final ObjectClass objectClass) {
-        AttributableType type = null;
-        if (ObjectClass.ACCOUNT.equals(objectClass)) {
-            type = AttributableType.USER;
-        }
-        if (ObjectClass.GROUP.equals(objectClass)) {
-            type = AttributableType.ROLE;
-        }
-
-        if (type == null) {
-            throw new IllegalArgumentException("ObjectClass not supported: " + objectClass);
-        }
-
-        return new JPAAttributableUtil(type);
-    }
-
-    public static AttributableUtil getInstance(final Attributable attributable) {
-        AttributableType type = null;
-        if (attributable instanceof User) {
-            type = AttributableType.USER;
-        }
-        if (attributable instanceof Role) {
-            type = AttributableType.ROLE;
-        }
-        if (attributable instanceof Membership) {
-            type = AttributableType.MEMBERSHIP;
-        }
-        if (attributable instanceof Conf) {
-            type = AttributableType.CONFIGURATION;
-        }
-
-        if (type == null) {
-            throw new IllegalArgumentException("Attributable type not supported: " + attributable.getClass().getName());
-        }
-
-        return new JPAAttributableUtil(type);
-    }
-
     private final AttributableType type;
 
-    private JPAAttributableUtil(final AttributableType type) {
+    protected JPAAttributableUtil(final AttributableType type) {
         this.type = type;
     }
 
@@ -723,7 +678,7 @@ public class JPAAttributableUtil implements AttributableUtil {
             }
         }
 
-        final List<T> result = new ArrayList<T>();
+        final List<T> result = new ArrayList<>();
 
         switch (purpose) {
             case SYNCHRONIZATION:
@@ -879,4 +834,46 @@ public class JPAAttributableUtil implements AttributableUtil {
         return result;
     }
 
+    @Override
+    public <T extends AbstractAttributableTO> T newAttributableTO() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new UserTO();
+                break;
+            case ROLE:
+                result = (T) new RoleTO();
+                break;
+            case MEMBERSHIP:
+                result = (T) new MembershipTO();
+                break;
+            case CONFIGURATION:
+                result = (T) new ConfTO();
+                break;
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends AbstractSubjectTO> T newSubjectTO() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new UserTO();
+                break;
+            case ROLE:
+                result = (T) new RoleTO();
+                break;
+            case MEMBERSHIP:
+            case CONFIGURATION:
+            default:
+                break;
+        }
+
+        return result;
+    }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntityFactory.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntityFactory.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntityFactory.java
index c404c53..8e772b8 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntityFactory.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntityFactory.java
@@ -20,6 +20,7 @@ package org.apache.syncope.persistence.jpa.entity;
 
 import org.apache.syncope.persistence.api.entity.AccountPolicy;
 import org.apache.syncope.persistence.api.entity.ConnInstance;
+import org.apache.syncope.persistence.api.entity.ConnPoolConf;
 import org.apache.syncope.persistence.api.entity.Entitlement;
 import org.apache.syncope.persistence.api.entity.Entity;
 import org.apache.syncope.persistence.api.entity.EntityFactory;
@@ -134,8 +135,8 @@ import org.springframework.stereotype.Component;
 @Component
 public class JPAEntityFactory implements EntityFactory {
 
-    @Override
     @SuppressWarnings("unchecked")
+    @Override
     public <KEY, T extends Entity<KEY>> T newEntity(final Class<T> reference) {
         T result;
 
@@ -258,6 +259,7 @@ public class JPAEntityFactory implements EntityFactory {
         return result;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <T extends Policy> T newPolicy(final Class<T> reference, final boolean global) {
         T result;
@@ -277,4 +279,9 @@ public class JPAEntityFactory implements EntityFactory {
         return result;
     }
 
+    @Override
+    public ConnPoolConf newConnPoolConf() {
+        return new JPAConnPoolConf();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAPushPolicy.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAPushPolicy.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAPushPolicy.java
index 1a661a9..b221330 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAPushPolicy.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAPushPolicy.java
@@ -25,7 +25,7 @@ import org.apache.syncope.persistence.api.entity.PushPolicy;
 @Entity
 public class JPAPushPolicy extends JPAPolicy implements PushPolicy {
 
-    private static final long serialVersionUID = -6090413855809521279L;
+    private static final long serialVersionUID = -5875589156893921113L;
 
     public JPAPushPolicy() {
         this(false);

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPASecurityQuestion.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPASecurityQuestion.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPASecurityQuestion.java
index bfe76bc..4ce7d5e 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPASecurityQuestion.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPASecurityQuestion.java
@@ -28,7 +28,7 @@ import org.apache.syncope.persistence.api.entity.user.SecurityQuestion;
 @Table(name = JPASecurityQuestion.TABLE)
 public class JPASecurityQuestion extends AbstractEntity<Long> implements SecurityQuestion {
 
-    private static final long serialVersionUID = -7646140284033489392L;
+    private static final long serialVersionUID = 7675321820453579744L;
 
     public static final String TABLE = "SecurityQuestion";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAttributableUtilFactory.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAttributableUtilFactory.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAttributableUtilFactory.java
new file mode 100644
index 0000000..6962b41
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAttributableUtilFactory.java
@@ -0,0 +1,85 @@
+/*
+ * 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.persistence.jpa.entity;
+
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.persistence.api.entity.Attributable;
+import org.apache.syncope.persistence.api.entity.AttributableUtil;
+import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
+import org.apache.syncope.persistence.api.entity.conf.Conf;
+import org.apache.syncope.persistence.api.entity.membership.Membership;
+import org.apache.syncope.persistence.api.entity.role.Role;
+import org.apache.syncope.persistence.api.entity.user.User;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.springframework.stereotype.Component;
+
+@Component
+public class JPAttributableUtilFactory implements AttributableUtilFactory {
+
+    @Override
+    public AttributableUtil getInstance(final AttributableType type) {
+        return new JPAAttributableUtil(type);
+    }
+
+    @Override
+    public AttributableUtil getInstance(final String attributableType) {
+        return new JPAAttributableUtil(AttributableType.valueOf(attributableType));
+    }
+
+    @Override
+    public AttributableUtil getInstance(final ObjectClass objectClass) {
+        AttributableType type = null;
+        if (ObjectClass.ACCOUNT.equals(objectClass)) {
+            type = AttributableType.USER;
+        }
+        if (ObjectClass.GROUP.equals(objectClass)) {
+            type = AttributableType.ROLE;
+        }
+
+        if (type == null) {
+            throw new IllegalArgumentException("ObjectClass not supported: " + objectClass);
+        }
+
+        return new JPAAttributableUtil(type);
+    }
+
+    @Override
+    public AttributableUtil getInstance(final Attributable<?, ?, ?> attributable) {
+        AttributableType type = null;
+        if (attributable instanceof User) {
+            type = AttributableType.USER;
+        }
+        if (attributable instanceof Role) {
+            type = AttributableType.ROLE;
+        }
+        if (attributable instanceof Membership) {
+            type = AttributableType.MEMBERSHIP;
+        }
+        if (attributable instanceof Conf) {
+            type = AttributableType.CONFIGURATION;
+        }
+
+        if (type == null) {
+            throw new IllegalArgumentException("Attributable type not supported: " + attributable.getClass().getName());
+        }
+
+        return new JPAAttributableUtil(type);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttr.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttr.java
index 74c7d66..3e0d404 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttr.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttr.java
@@ -48,7 +48,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractPlainAttr;
 @Table(name = JPACPlainAttr.TABLE)
 public class JPACPlainAttr extends AbstractPlainAttr implements CPlainAttr {
 
-    private static final long serialVersionUID = 6333601983691157406L;
+    private static final long serialVersionUID = 8022331942314540648L;
 
     public static final String TABLE = "CPlainAttr";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
index 13e8e04..8cc830c 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
@@ -35,7 +35,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractPlainAttrValue;
 @Table(name = JPACPlainAttrUniqueValue.TABLE)
 public class JPACPlainAttrUniqueValue extends AbstractPlainAttrValue implements CPlainAttrUniqueValue {
 
-    private static final long serialVersionUID = -64080804563305387L;
+    private static final long serialVersionUID = -2072445894710677162L;
 
     public static final String TABLE = "CPlainAttrUniqueValue";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrValue.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrValue.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrValue.java
index 70e30f3..ff0a8ae 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrValue.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPACPlainAttrValue.java
@@ -35,7 +35,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractPlainAttrValue;
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 public class JPACPlainAttrValue extends AbstractPlainAttrValue implements CPlainAttrValue {
 
-    private static final long serialVersionUID = -6259576015647897446L;
+    private static final long serialVersionUID = -4029895248193486171L;
 
     public static final String TABLE = "CPlainAttrValue";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPAConf.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPAConf.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPAConf.java
index 3bfa884..0438543 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPAConf.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/conf/JPAConf.java
@@ -39,7 +39,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractAttributable;
 @Cacheable
 public class JPAConf extends AbstractAttributable<CPlainAttr, DerAttr, VirAttr> implements Conf {
 
-    private static final long serialVersionUID = -5281258853142421875L;
+    private static final long serialVersionUID = 7671699609879382195L;
 
     public static final String TABLE = "SyncopeConf";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMDerAttrTemplate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMDerAttrTemplate.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMDerAttrTemplate.java
index 7ec7fcf..1b35470 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMDerAttrTemplate.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMDerAttrTemplate.java
@@ -32,7 +32,7 @@ import org.apache.syncope.persistence.jpa.entity.role.JPARole;
 @Table(name = JPAMDerAttrTemplate.TABLE)
 public class JPAMDerAttrTemplate extends AbstractAttrTemplate<MDerSchema> implements MDerAttrTemplate {
 
-    private static final long serialVersionUID = -3424574558427502145L;
+    private static final long serialVersionUID = -4465930976210263434L;
 
     public static final String TABLE = "MDerAttrTemplate";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMPlainAttrTemplate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMPlainAttrTemplate.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMPlainAttrTemplate.java
index fb8e728..ad6d2c2 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMPlainAttrTemplate.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMPlainAttrTemplate.java
@@ -32,7 +32,7 @@ import org.apache.syncope.persistence.jpa.entity.role.JPARole;
 @Table(name = JPAMPlainAttrTemplate.TABLE)
 public class JPAMPlainAttrTemplate extends AbstractAttrTemplate<MPlainSchema> implements MPlainAttrTemplate {
 
-    private static final long serialVersionUID = -3424574558427502145L;
+    private static final long serialVersionUID = -8768086609963244514L;
 
     public static final String TABLE = "MPlainAttrTemplate";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMVirAttrTemplate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMVirAttrTemplate.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMVirAttrTemplate.java
index 7bd60db..6840686 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMVirAttrTemplate.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/membership/JPAMVirAttrTemplate.java
@@ -32,7 +32,7 @@ import org.apache.syncope.persistence.jpa.entity.role.JPARole;
 @Table(name = JPAMVirAttrTemplate.TABLE)
 public class JPAMVirAttrTemplate extends AbstractAttrTemplate<MVirSchema> implements MVirAttrTemplate {
 
-    private static final long serialVersionUID = -3424574558427502145L;
+    private static final long serialVersionUID = 6618560912535667392L;
 
     public static final String TABLE = "MVirAttrTemplate";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARDerAttrTemplate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARDerAttrTemplate.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARDerAttrTemplate.java
index ba565a7..3b382bb 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARDerAttrTemplate.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARDerAttrTemplate.java
@@ -31,7 +31,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractAttrTemplate;
 @Table(name = JPARDerAttrTemplate.TABLE)
 public class JPARDerAttrTemplate extends AbstractAttrTemplate<RDerSchema> implements RDerAttrTemplate {
 
-    private static final long serialVersionUID = -3424574558427502145L;
+    private static final long serialVersionUID = 624868884107016649L;
 
     public static final String TABLE = "RDerAttrTemplate";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARPlainAttrTemplate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARPlainAttrTemplate.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARPlainAttrTemplate.java
index 90ac153..7d88bf7 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARPlainAttrTemplate.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARPlainAttrTemplate.java
@@ -31,7 +31,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractAttrTemplate;
 @Table(name = JPARPlainAttrTemplate.TABLE)
 public class JPARPlainAttrTemplate extends AbstractAttrTemplate<RPlainSchema> implements RPlainAttrTemplate {
 
-    private static final long serialVersionUID = -3424574558427502145L;
+    private static final long serialVersionUID = 6943917051517266268L;
 
     public static final String TABLE = "RPlainAttrTemplate";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARVirAttrTemplate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARVirAttrTemplate.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARVirAttrTemplate.java
index a5e41bd..2228663 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARVirAttrTemplate.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARVirAttrTemplate.java
@@ -31,7 +31,7 @@ import org.apache.syncope.persistence.jpa.entity.AbstractAttrTemplate;
 @Table(name = JPARVirAttrTemplate.TABLE)
 public class JPARVirAttrTemplate extends AbstractAttrTemplate<RVirSchema> implements RVirAttrTemplate {
 
-    private static final long serialVersionUID = -3424574558427502145L;
+    private static final long serialVersionUID = 4896495904794493479L;
 
     public static final String TABLE = "RVirAttrTemplate";
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARole.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARole.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARole.java
index 05c9e9f..50bcf42 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARole.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/role/JPARole.java
@@ -156,7 +156,7 @@ public class JPARole extends AbstractSubject<RPlainAttr, RDerAttr, RVirAttr> imp
     @Basic(optional = true)
     @Min(0)
     @Max(1)
-    private Integer inheritAttrs;
+    private Integer inheritPlainAttrs;
 
     @Basic(optional = true)
     @Min(0)
@@ -213,7 +213,7 @@ public class JPARole extends AbstractSubject<RPlainAttr, RDerAttr, RVirAttr> imp
 
         inheritOwner = getBooleanAsInteger(false);
         inheritTemplates = getBooleanAsInteger(false);
-        inheritAttrs = getBooleanAsInteger(false);
+        inheritPlainAttrs = getBooleanAsInteger(false);
         inheritDerAttrs = getBooleanAsInteger(false);
         inheritVirAttrs = getBooleanAsInteger(false);
         inheritPasswordPolicy = getBooleanAsInteger(false);
@@ -423,13 +423,13 @@ public class JPARole extends AbstractSubject<RPlainAttr, RDerAttr, RVirAttr> imp
     }
 
     @Override
-    public boolean isInheritAttrs() {
-        return isBooleanAsInteger(inheritAttrs);
+    public boolean isInheritPlainAttrs() {
+        return isBooleanAsInteger(inheritPlainAttrs);
     }
 
     @Override
-    public void setInheritAttrs(final boolean inheritAttrs) {
-        this.inheritAttrs = getBooleanAsInteger(inheritAttrs);
+    public void setInheritPlainAttrs(final boolean inheritPlainAttrs) {
+        this.inheritPlainAttrs = getBooleanAsInteger(inheritPlainAttrs);
     }
 
     /**
@@ -441,10 +441,10 @@ public class JPARole extends AbstractSubject<RPlainAttr, RDerAttr, RVirAttr> imp
     public List<? extends RPlainAttr> findLastInheritedAncestorPlainAttrs() {
         final Map<JPARPlainSchema, RPlainAttr> result = new HashMap<>();
 
-        if (!isInheritAttrs()) {
+        if (!isInheritPlainAttrs()) {
             return plainAttrs;
         }
-        if (isInheritAttrs() && getParent() != null) {
+        if (isInheritPlainAttrs() && getParent() != null) {
             final Map<PlainSchema, RPlainAttr> attrMap = getPlainAttrMap();
 
             // Add inherit attributes

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPASchedTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPASchedTask.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPASchedTask.java
index 649664d..ef03fd7 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPASchedTask.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPASchedTask.java
@@ -30,7 +30,7 @@ import org.apache.syncope.persistence.jpa.validation.entity.SchedTaskCheck;
 @SchedTaskCheck
 public class JPASchedTask extends JPATask implements SchedTask {
 
-    private static final long serialVersionUID = -4141057723006682562L;
+    private static final long serialVersionUID = 7596236684832602180L;
 
     protected String cronExpression;
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtil.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtil.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtil.java
new file mode 100644
index 0000000..3fae881
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtil.java
@@ -0,0 +1,132 @@
+/*
+ * 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.persistence.jpa.entity.task;
+
+import org.apache.syncope.common.lib.to.AbstractTaskTO;
+import org.apache.syncope.common.lib.to.NotificationTaskTO;
+import org.apache.syncope.common.lib.to.PropagationTaskTO;
+import org.apache.syncope.common.lib.to.PushTaskTO;
+import org.apache.syncope.common.lib.to.SchedTaskTO;
+import org.apache.syncope.common.lib.to.SyncTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.persistence.api.entity.task.NotificationTask;
+import org.apache.syncope.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.persistence.api.entity.task.PushTask;
+import org.apache.syncope.persistence.api.entity.task.SchedTask;
+import org.apache.syncope.persistence.api.entity.task.SyncTask;
+import org.apache.syncope.persistence.api.entity.task.Task;
+import org.apache.syncope.persistence.api.entity.task.TaskUtil;
+
+@SuppressWarnings("unchecked")
+public final class JPATaskUtil implements TaskUtil {
+
+    private final TaskType type;
+
+    protected JPATaskUtil(final TaskType type) {
+        this.type = type;
+    }
+
+    @Override
+    public TaskType getType() {
+        return type;
+    }
+
+    @Override
+    public <T extends Task> Class<T> taskClass() {
+        Class<T> result = null;
+
+        switch (type) {
+            case PROPAGATION:
+                result = (Class<T>) PropagationTask.class;
+                break;
+
+            case SCHEDULED:
+                result = (Class<T>) SchedTask.class;
+                break;
+
+            case SYNCHRONIZATION:
+                result = (Class<T>) SyncTask.class;
+                break;
+
+            case PUSH:
+                result = (Class<T>) PushTask.class;
+                break;
+
+            case NOTIFICATION:
+                result = (Class<T>) NotificationTask.class;
+                break;
+
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends Task> T newTask() {
+        final Class<T> taskClass = taskClass();
+        try {
+            return taskClass == null ? null : taskClass.newInstance();
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    @Override
+    public <T extends AbstractTaskTO> Class<T> taskTOClass() {
+        Class<T> result = null;
+
+        switch (type) {
+            case PROPAGATION:
+                result = (Class<T>) PropagationTaskTO.class;
+                break;
+
+            case SCHEDULED:
+                result = (Class<T>) SchedTaskTO.class;
+                break;
+
+            case SYNCHRONIZATION:
+                result = (Class<T>) SyncTaskTO.class;
+                break;
+
+            case PUSH:
+                result = (Class<T>) PushTaskTO.class;
+                break;
+
+            case NOTIFICATION:
+                result = (Class<T>) NotificationTaskTO.class;
+                break;
+
+            default:
+        }
+
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends AbstractTaskTO> T newTaskTO() {
+        final Class<T> taskClass = taskTOClass();
+        try {
+            return taskClass == null ? null : taskClass.newInstance();
+        } catch (Exception e) {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtilFactory.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtilFactory.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtilFactory.java
new file mode 100644
index 0000000..62f5dab
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/task/JPATaskUtilFactory.java
@@ -0,0 +1,91 @@
+/*
+ * 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.persistence.jpa.entity.task;
+
+import org.apache.syncope.common.lib.to.AbstractTaskTO;
+import org.apache.syncope.common.lib.to.NotificationTaskTO;
+import org.apache.syncope.common.lib.to.PropagationTaskTO;
+import org.apache.syncope.common.lib.to.PushTaskTO;
+import org.apache.syncope.common.lib.to.SchedTaskTO;
+import org.apache.syncope.common.lib.to.SyncTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.persistence.api.entity.task.NotificationTask;
+import org.apache.syncope.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.persistence.api.entity.task.PushTask;
+import org.apache.syncope.persistence.api.entity.task.SchedTask;
+import org.apache.syncope.persistence.api.entity.task.SyncTask;
+import org.apache.syncope.persistence.api.entity.task.Task;
+import org.apache.syncope.persistence.api.entity.task.TaskUtil;
+import org.apache.syncope.persistence.api.entity.task.TaskUtilFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class JPATaskUtilFactory implements TaskUtilFactory {
+
+    @Override
+    public TaskUtil getInstance(final TaskType type) {
+        return new JPATaskUtil(type);
+    }
+
+    @Override
+    public TaskUtil getInstance(final Task task) {
+        TaskType type;
+        if (task instanceof SyncTask) {
+            type = TaskType.SYNCHRONIZATION;
+        } else if (task instanceof PushTask) {
+            type = TaskType.PUSH;
+        } else if (task instanceof SchedTask) {
+            type = TaskType.SCHEDULED;
+        } else if (task instanceof PropagationTask) {
+            type = TaskType.PROPAGATION;
+        } else if (task instanceof NotificationTask) {
+            type = TaskType.NOTIFICATION;
+        } else {
+            throw new IllegalArgumentException("Invalid task: " + task);
+        }
+
+        return getInstance(type);
+    }
+
+    @Override
+    public TaskUtil getInstance(final Class<? extends AbstractTaskTO> taskClass) {
+        TaskType type;
+        if (taskClass == PropagationTaskTO.class) {
+            type = TaskType.PROPAGATION;
+        } else if (taskClass == NotificationTaskTO.class) {
+            type = TaskType.NOTIFICATION;
+        } else if (taskClass == SchedTaskTO.class) {
+            type = TaskType.SCHEDULED;
+        } else if (taskClass == SyncTaskTO.class) {
+            type = TaskType.SYNCHRONIZATION;
+        } else if (taskClass == PushTaskTO.class) {
+            type = TaskType.PUSH;
+        } else {
+            throw new IllegalArgumentException("Invalid TaskTO class: " + taskClass.getName());
+        }
+
+        return getInstance(type);
+    }
+
+    @Override
+    public TaskUtil getInstance(final AbstractTaskTO taskTO) {
+        return getInstance(taskTO.getClass());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/user/JPAUser.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/user/JPAUser.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/user/JPAUser.java
index ec28d6c..efc66ec 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/user/JPAUser.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/user/JPAUser.java
@@ -62,9 +62,10 @@ import org.apache.syncope.persistence.api.entity.user.User;
 import org.apache.syncope.persistence.jpa.validation.entity.UserCheck;
 import org.apache.syncope.persistence.jpa.entity.AbstractSubject;
 import org.apache.syncope.persistence.jpa.entity.JPAExternalResource;
+import org.apache.syncope.persistence.jpa.entity.JPASecurityQuestion;
 import org.apache.syncope.persistence.jpa.entity.membership.JPAMembership;
 import org.apache.syncope.server.security.Encryptor;
-import org.apache.syncope.server.security.SecureRandomUtil;
+import org.apache.syncope.server.utils.SecureRandomUtil;
 
 /**
  * Syncope user bean.
@@ -170,7 +171,7 @@ public class JPAUser extends AbstractSubject<UPlainAttr, UDerAttr, UVirAttr> imp
     private Set<JPAExternalResource> resources;
 
     @ManyToOne(fetch = FetchType.EAGER, optional = true)
-    private SecurityQuestion securityQuestion;
+    private JPASecurityQuestion securityQuestion;
 
     @Column(nullable = true)
     private String securityAnswer;
@@ -520,7 +521,8 @@ public class JPAUser extends AbstractSubject<UPlainAttr, UDerAttr, UVirAttr> imp
 
     @Override
     public void setSecurityQuestion(final SecurityQuestion securityQuestion) {
-        this.securityQuestion = securityQuestion;
+        checkType(securityQuestion, JPASecurityQuestion.class);
+        this.securityQuestion = (JPASecurityQuestion) securityQuestion;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/validation/entity/ConnInstanceValidator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/validation/entity/ConnInstanceValidator.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/validation/entity/ConnInstanceValidator.java
index ba60ae4..c2bdb3a 100644
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/validation/entity/ConnInstanceValidator.java
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/validation/entity/ConnInstanceValidator.java
@@ -22,7 +22,7 @@ import javax.validation.ConstraintValidatorContext;
 import org.apache.syncope.common.lib.types.EntityViolationType;
 import org.apache.syncope.persistence.api.entity.ConnInstance;
 import org.apache.syncope.persistence.jpa.entity.JPAConnPoolConf;
-import org.apache.syncope.server.utils.URIUtil;
+import org.apache.syncope.provisioning.api.URIUtil;
 import org.apache.syncope.provisioning.api.ConnPoolConfUtil;
 
 public class ConnInstanceValidator extends AbstractValidator<ConnInstanceCheck, ConnInstance> {

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/AbstractTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/AbstractTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/AbstractTest.java
index 2c78453..afb405a 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/AbstractTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/AbstractTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.persistence.jpa;
 
+import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
 import org.apache.syncope.persistence.api.entity.EntityFactory;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,4 +32,7 @@ public abstract class AbstractTest {
     @Autowired
     protected EntityFactory entityFactory;
 
+    @Autowired
+    protected AttributableUtilFactory attrUtilFactory;
+
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/AttrTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/AttrTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/AttrTest.java
index f751b77..0b5ccf1 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/AttrTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/AttrTest.java
@@ -87,15 +87,15 @@ public class AttrTest extends AbstractTest {
 
         Exception thrown = null;
         try {
-            attribute.addValue("john.doe@gmail.com", JPAAttributableUtil.getInstance(AttributableType.USER));
-            attribute.addValue("mario.rossi@gmail.com", JPAAttributableUtil.getInstance(AttributableType.USER));
+            attribute.addValue("john.doe@gmail.com", attrUtilFactory.getInstance(AttributableType.USER));
+            attribute.addValue("mario.rossi@gmail.com", attrUtilFactory.getInstance(AttributableType.USER));
         } catch (ValidationException e) {
             thrown = e;
         }
         assertNull("no validation exception expected here ", thrown);
 
         try {
-            attribute.addValue("http://www.apache.org", JPAAttributableUtil.getInstance(AttributableType.USER));
+            attribute.addValue("http://www.apache.org", attrUtilFactory.getInstance(AttributableType.USER));
         } catch (ValidationException e) {
             thrown = e;
         }
@@ -119,13 +119,13 @@ public class AttrTest extends AbstractTest {
         Exception thrown = null;
 
         try {
-            attribute.addValue("A", JPAAttributableUtil.getInstance(AttributableType.USER));
+            attribute.addValue("A", attrUtilFactory.getInstance(AttributableType.USER));
         } catch (ValidationException e) {
             thrown = e;
         }
         assertNotNull("validation exception expected here ", thrown);
 
-        attribute.addValue("M", JPAAttributableUtil.getInstance(AttributableType.USER));
+        attribute.addValue("M", attrUtilFactory.getInstance(AttributableType.USER));
 
         InvalidEntityException iee = null;
         try {
@@ -183,7 +183,7 @@ public class AttrTest extends AbstractTest {
 
         UPlainAttr attribute = entityFactory.newEntity(UPlainAttr.class);
         attribute.setSchema(obscureSchema);
-        attribute.addValue("testvalue", JPAAttributableUtil.getInstance(AttributableType.USER));
+        attribute.addValue("testvalue", attrUtilFactory.getInstance(AttributableType.USER));
         attribute.setOwner(user);
         user.addPlainAttr(attribute);
 
@@ -210,7 +210,7 @@ public class AttrTest extends AbstractTest {
 
         UPlainAttr attribute = entityFactory.newEntity(UPlainAttr.class);
         attribute.setSchema(photoSchema);
-        attribute.addValue(photoB64Value, JPAAttributableUtil.getInstance(AttributableType.USER));
+        attribute.addValue(photoB64Value, attrUtilFactory.getInstance(AttributableType.USER));
         attribute.setOwner(user);
         user.addPlainAttr(attribute);
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/ConfTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/ConfTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/ConfTest.java
index ab662b7..143a4fe 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/ConfTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/ConfTest.java
@@ -72,7 +72,7 @@ public class ConfTest extends AbstractTest {
         // 2. create conf
         CPlainAttr newConf = entityFactory.newEntity(CPlainAttr.class);
         newConf.setSchema(useless);
-        newConf.addValue("2014-06-20", JPAAttributableUtil.getInstance(AttributableType.CONFIGURATION));
+        newConf.addValue("2014-06-20", attrUtilFactory.getInstance(AttributableType.CONFIGURATION));
         confDAO.save(newConf);
 
         CPlainAttr actual = confDAO.find("useless");
@@ -80,7 +80,7 @@ public class ConfTest extends AbstractTest {
 
         // 3. update conf
         newConf.getValues().clear();
-        newConf.addValue("2014-06-20", JPAAttributableUtil.getInstance(AttributableType.CONFIGURATION));
+        newConf.addValue("2014-06-20", attrUtilFactory.getInstance(AttributableType.CONFIGURATION));
         confDAO.save(newConf);
 
         actual = confDAO.find("useless");

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/DerSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/DerSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/DerSchemaTest.java
index 19af5e9..94c61aa 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/DerSchemaTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/DerSchemaTest.java
@@ -73,7 +73,7 @@ public class DerSchemaTest extends AbstractTest {
         UDerSchema cn = derSchemaDAO.find("cn", UDerSchema.class);
         assertNotNull(cn);
 
-        derSchemaDAO.delete(cn.getKey(), JPAAttributableUtil.getInstance(AttributableType.USER));
+        derSchemaDAO.delete(cn.getKey(), attrUtilFactory.getInstance(AttributableType.USER));
 
         DerSchema actual = derSchemaDAO.find("cn", UDerSchema.class);
         assertNull("delete did not work", actual);
@@ -82,7 +82,7 @@ public class DerSchemaTest extends AbstractTest {
         RDerSchema rderiveddata = derSchemaDAO.find("rderiveddata", RDerSchema.class);
         assertNotNull(rderiveddata);
 
-        derSchemaDAO.delete(rderiveddata.getKey(), JPAAttributableUtil.getInstance(AttributableType.ROLE));
+        derSchemaDAO.delete(rderiveddata.getKey(), attrUtilFactory.getInstance(AttributableType.ROLE));
 
         actual = derSchemaDAO.find("rderiveddata", RDerSchema.class);
         assertNull("delete did not work", actual);

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/PlainSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/PlainSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/PlainSchemaTest.java
index 4e47087..652d32e 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/PlainSchemaTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/PlainSchemaTest.java
@@ -139,7 +139,7 @@ public class PlainSchemaTest extends AbstractTest {
     public void delete() {
         UPlainSchema fullnam = plainSchemaDAO.find("fullname", UPlainSchema.class);
 
-        plainSchemaDAO.delete(fullnam.getKey(), JPAAttributableUtil.getInstance(AttributableType.USER));
+        plainSchemaDAO.delete(fullnam.getKey(), attrUtilFactory.getInstance(AttributableType.USER));
 
         UPlainSchema actual = plainSchemaDAO.find("fullname", UPlainSchema.class);
         assertNull("delete did not work", actual);

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/VirSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/VirSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/VirSchemaTest.java
index 9ae9e48..df60909 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/VirSchemaTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/entity/VirSchemaTest.java
@@ -72,7 +72,7 @@ public class VirSchemaTest extends AbstractTest {
     public void delete() {
         UVirSchema virtualdata = virSchemaDAO.find("virtualdata", UVirSchema.class);
 
-        virSchemaDAO.delete(virtualdata.getKey(), JPAAttributableUtil.getInstance(AttributableType.USER));
+        virSchemaDAO.delete(virtualdata.getKey(), attrUtilFactory.getInstance(AttributableType.USER));
 
         VirSchema actual = virSchemaDAO.find("virtualdata", UVirSchema.class);
         assertNull("delete did not work", actual);
@@ -81,7 +81,7 @@ public class VirSchemaTest extends AbstractTest {
         RVirSchema rvirtualdata = virSchemaDAO.find("rvirtualdata", RVirSchema.class);
         assertNotNull(rvirtualdata);
 
-        virSchemaDAO.delete(rvirtualdata.getKey(), JPAAttributableUtil.getInstance(AttributableType.ROLE));
+        virSchemaDAO.delete(rvirtualdata.getKey(), attrUtilFactory.getInstance(AttributableType.ROLE));
 
         actual = virSchemaDAO.find("rvirtualdata", RVirSchema.class);
         assertNull("delete did not work", actual);

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/AttrTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/AttrTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/AttrTest.java
index 1074726..a74e3a1 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/AttrTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/AttrTest.java
@@ -47,7 +47,6 @@ import org.apache.syncope.persistence.api.entity.user.UPlainAttr;
 import org.apache.syncope.persistence.api.entity.user.UPlainAttrValue;
 import org.apache.syncope.persistence.api.entity.user.User;
 import org.apache.syncope.persistence.jpa.AbstractTest;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -125,7 +124,7 @@ public class AttrTest extends AbstractTest {
         MPlainAttr attr = entityFactory.newEntity(MPlainAttr.class);
         attr.setTemplate(template);
         attr.setOwner(membership);
-        attr.addValue("yellow", JPAAttributableUtil.getInstance(AttributableType.MEMBERSHIP));
+        attr.addValue("yellow", attrUtilFactory.getInstance(AttributableType.MEMBERSHIP));
         membership.addPlainAttr(attr);
 
         MPlainAttr actualAttribute = userDAO.save(user).getMembership(1L).getPlainAttr("color");

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/DerSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/DerSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/DerSchemaTest.java
index 685c2e2..2982423 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/DerSchemaTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/DerSchemaTest.java
@@ -27,7 +27,6 @@ import org.apache.syncope.persistence.api.dao.UserDAO;
 import org.apache.syncope.persistence.api.entity.user.UDerAttr;
 import org.apache.syncope.persistence.api.entity.user.UDerSchema;
 import org.apache.syncope.persistence.jpa.AbstractTest;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -48,7 +47,7 @@ public class DerSchemaTest extends AbstractTest {
     public void test() {
         UDerSchema schema = derSchemaDAO.find("cn", UDerSchema.class);
 
-        derSchemaDAO.delete(schema.getKey(), JPAAttributableUtil.getInstance(AttributableType.USER));
+        derSchemaDAO.delete(schema.getKey(), attrUtilFactory.getInstance(AttributableType.USER));
 
         derSchemaDAO.flush();
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/PlainSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/PlainSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/PlainSchemaTest.java
index 29fb41e..710444c 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/PlainSchemaTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/PlainSchemaTest.java
@@ -36,7 +36,6 @@ import org.apache.syncope.persistence.api.entity.MappingItem;
 import org.apache.syncope.persistence.api.entity.user.UPlainAttr;
 import org.apache.syncope.persistence.api.entity.user.UPlainSchema;
 import org.apache.syncope.persistence.jpa.AbstractTest;
-import org.apache.syncope.persistence.jpa.entity.JPAAttributableUtil;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -86,7 +85,7 @@ public class PlainSchemaTest extends AbstractTest {
         assertFalse(mapItems.isEmpty());
 
         // delete user schema fullname
-        plainSchemaDAO.delete("fullname", JPAAttributableUtil.getInstance(AttributableType.USER));
+        plainSchemaDAO.delete("fullname", attrUtilFactory.getInstance(AttributableType.USER));
 
         plainSchemaDAO.flush();
 
@@ -135,7 +134,7 @@ public class PlainSchemaTest extends AbstractTest {
         assertFalse(mappings.isEmpty());
 
         // delete user schema fullname
-        plainSchemaDAO.delete("surname", JPAAttributableUtil.getInstance(AttributableType.USER));
+        plainSchemaDAO.delete("surname", attrUtilFactory.getInstance(AttributableType.USER));
 
         plainSchemaDAO.flush();
 
@@ -148,7 +147,7 @@ public class PlainSchemaTest extends AbstractTest {
     public void deleteALong() {
         assertEquals(6, resourceDAO.find("resource-db-sync").getUmapping().getItems().size());
 
-        plainSchemaDAO.delete("aLong", JPAAttributableUtil.getInstance(AttributableType.USER));
+        plainSchemaDAO.delete("aLong", attrUtilFactory.getInstance(AttributableType.USER));
         assertNull(plainSchemaDAO.find("aLong", UPlainSchema.class));
 
         plainSchemaDAO.flush();

http://git-wip-us.apache.org/repos/asf/syncope/blob/99369c31/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/SecurityQuestionTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/SecurityQuestionTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/SecurityQuestionTest.java
index 8fcac93..e4231b7 100644
--- a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/SecurityQuestionTest.java
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/persistence/jpa/relationship/SecurityQuestionTest.java
@@ -40,6 +40,8 @@ public class SecurityQuestionTest extends AbstractTest {
     @Test
     public void test() {
         User user = userDAO.find(4L);
+        assertNull(user.getSecurityQuestion());
+        assertNull(user.getSecurityAnswer());
 
         user.setSecurityQuestion(securityQuestionDAO.find(1L));
         user.setSecurityAnswer("Rossi");
@@ -54,5 +56,6 @@ public class SecurityQuestionTest extends AbstractTest {
         user = userDAO.find(4L);
 
         assertNull(user.getSecurityQuestion());
+        assertNull(user.getSecurityAnswer());
     }
 }


Mime
View raw message