[SYNCOPE-1193] Now read, update and delete works both with key and (user)name 
for Users, Groups and Any Objects


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/81515d7e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/81515d7e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/81515d7e

Branch: refs/heads/master
Commit: 81515d7e243e8116409e2be2cb6bf036a305f988
Parents: 8839116
Author: Francesco Chicchiriccò <ilgro...@apache.org>
Authored: Fri Aug 11 16:06:42 2017 +0200
Committer: Francesco Chicchiriccò <ilgro...@apache.org>
Committed: Fri Aug 11 16:06:54 2017 +0200

----------------------------------------------------------------------
 .../common/rest/api/service/AnyService.java     | 12 ++---
 .../syncope/core/logic/AbstractAnyLogic.java    |  3 --
 .../syncope/core/logic/AnyObjectLogic.java      | 13 ------
 .../apache/syncope/core/logic/GroupLogic.java   | 11 -----
 .../apache/syncope/core/logic/UserLogic.java    | 12 -----
 .../core/persistence/api/dao/AnyDAO.java        |  2 +
 .../core/persistence/api/dao/AnyObjectDAO.java  |  2 -
 .../core/persistence/api/dao/GroupDAO.java      |  2 -
 .../core/persistence/api/dao/UserDAO.java       |  2 -
 .../persistence/jpa/dao/AbstractAnyDAO.java     | 17 +++++++
 .../persistence/jpa/dao/JPAAnyObjectDAO.java    | 24 +++-------
 .../core/persistence/jpa/dao/JPAGroupDAO.java   | 24 +++-------
 .../core/persistence/jpa/dao/JPAUserDAO.java    | 25 +++-------
 .../provisioning/api/data/UserDataBinder.java   |  2 -
 .../java/data/AnyObjectDataBinderImpl.java      |  5 +-
 .../java/data/GroupDataBinderImpl.java          |  5 +-
 .../java/data/UserDataBinderImpl.java           | 11 +----
 .../rest/cxf/service/AbstractAnyService.java    | 49 ++++++++++++++++----
 .../rest/cxf/service/AnyObjectServiceImpl.java  | 10 ++++
 .../core/rest/cxf/service/GroupServiceImpl.java | 10 ++++
 .../core/rest/cxf/service/UserServiceImpl.java  | 12 ++++-
 .../apache/syncope/core/logic/SAML2SPLogic.java |  4 +-
 .../core/logic/saml2/SAML2ReaderWriter.java     |  2 +-
 fit/core-reference/pom.xml                      |  2 -
 .../apache/syncope/fit/core/SAML2ITCase.java    | 20 ++++----
 .../org/apache/syncope/fit/core/UserITCase.java | 11 +++++
 pom.xml                                         |  8 +++-
 27 files changed, 151 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java
----------------------------------------------------------------------
diff --git 
a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java
 
b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java
index d288e59..ac2fc20 100644
--- 
a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java
+++ 
b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java
@@ -50,7 +50,7 @@ public interface AnyService<TO extends AnyTO, P extends 
AnyPatch> extends JAXRSS
      * Note that for the UserService, GroupService and AnyObjectService 
subclasses, if the key parameter
      * looks like a UUID then it is interpreted as as key, otherwise as a 
(user)name.
      *
-     * @param key any object key
+     * @param key any object key or name
      * @param schemaType schema type
      * @return list of attributes, owned by the given any object, for the 
given schema type
      */
@@ -65,7 +65,7 @@ public interface AnyService<TO extends AnyTO, P extends 
AnyPatch> extends JAXRSS
      * Note that for the UserService, GroupService and AnyObjectService 
subclasses, if the key parameter
      * looks like a UUID then it is interpreted as as key, otherwise as a 
(user)name.
      *
-     * @param key any object key
+     * @param key any object key or name
      * @param schemaType schema type
      * @param schema schema
      * @return attribute, owned by the given any object, for the given schema 
type and schema
@@ -84,7 +84,7 @@ public interface AnyService<TO extends AnyTO, P extends 
AnyPatch> extends JAXRSS
      * Note that for the UserService, GroupService and AnyObjectService 
subclasses, if the key parameter
      * looks like a UUID then it is interpreted as as key, otherwise as a 
(user)name.
      *
-     * @param key key of any object to be read
+     * @param key any object key or name
      * @return any object with matching key
      */
     @GET
@@ -130,7 +130,7 @@ public interface AnyService<TO extends AnyTO, P extends 
AnyPatch> extends JAXRSS
     /**
      * Adds or replaces the attribute, owned by the given any object, for the 
given schema type and schema.
      *
-     * @param key any object key
+     * @param key any object key or name
      * @param schemaType schema type
      * @param attrTO attribute
      * @return Response object featuring the updated any object attribute - as 
Entity
@@ -160,7 +160,7 @@ public interface AnyService<TO extends AnyTO, P extends 
AnyPatch> extends JAXRSS
     /**
      * Deletes the attribute, owned by the given any object, for the given 
schema type and schema.
      *
-     * @param key any object key
+     * @param key any object key or name
      * @param schemaType schema type
      * @param schema schema
      */
@@ -176,7 +176,7 @@ public interface AnyService<TO extends AnyTO, P extends 
AnyPatch> extends JAXRSS
     /**
      * Deletes any object matching provided key.
      *
-     * @param key key of any object to be deleted
+     * @param key any object key or name
      * @return Response object featuring the deleted any object enriched with 
propagation status information
      * - ProvisioningResult as Entity
      */

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
----------------------------------------------------------------------
diff --git 
a/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java 
b/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
index 9755e1f..fd7e5f2 100644
--- 
a/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
+++ 
b/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
@@ -19,7 +19,6 @@
 package org.apache.syncope.core.logic;
 
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -259,8 +258,6 @@ public abstract class AbstractAnyLogic<TO extends AnyTO, P 
extends AnyPatch> ext
         return IterableUtils.matchesAny(effectiveRealms, new 
RealmUtils.DynRealmsPredicate());
     }
 
-    public abstract Date findLastChange(String key);
-
     public abstract TO read(String key);
 
     public abstract ProvisioningResult<TO> create(TO anyTO, boolean 
nullPriorityAsync);

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
----------------------------------------------------------------------
diff --git 
a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java 
b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
index 8cab1aa..e5621be 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
@@ -21,7 +21,6 @@ package org.apache.syncope.core.logic;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -41,7 +40,6 @@ import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
@@ -73,17 +71,6 @@ public class AnyObjectLogic extends 
AbstractAnyLogic<AnyObjectTO, AnyObjectPatch
 
     @Transactional(readOnly = true)
     @Override
-    public Date findLastChange(final String key) {
-        Date etag = anyObjectDAO.findLastChange(key);
-        if (etag == null) {
-            throw new NotFoundException("AnyObject " + key);
-        }
-
-        return etag;
-    }
-
-    @Transactional(readOnly = true)
-    @Override
     public AnyObjectTO read(final String key) {
         return binder.getAnyObjectTO(key);
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
----------------------------------------------------------------------
diff --git 
a/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java 
b/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
index 8098de0..898113d 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
@@ -127,17 +127,6 @@ public class GroupLogic extends AbstractAnyLogic<GroupTO, 
GroupPatch> {
         return IterableUtils.matchesAny(effectiveRealms, new 
RealmUtils.DynRealmsPredicate());
     }
 
-    @Transactional(readOnly = true)
-    @Override
-    public Date findLastChange(final String key) {
-        Date etag = groupDAO.findLastChange(key);
-        if (etag == null) {
-            throw new NotFoundException("Group " + key);
-        }
-
-        return etag;
-    }
-
     @PreAuthorize("hasRole('" + StandardEntitlement.GROUP_READ + "')")
     @Transactional(readOnly = true)
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
----------------------------------------------------------------------
diff --git 
a/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java 
b/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
index ffca88b..f889780 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -81,17 +80,6 @@ public class UserLogic extends AbstractAnyLogic<UserTO, 
UserPatch> {
     @Autowired
     protected SyncopeLogic syncopeLogic;
 
-    @Transactional(readOnly = true)
-    @Override
-    public Date findLastChange(final String key) {
-        Date etag = userDAO.findLastChange(key);
-        if (etag == null) {
-            throw new NotFoundException("User " + key);
-        }
-
-        return etag;
-    }
-
     @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
     public Pair<String, UserTO> selfRead() {

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
index 60f865f..3415377 100644
--- 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
+++ 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
@@ -31,6 +31,8 @@ public interface AnyDAO<A extends Any<?>> extends DAO<A> {
 
     int DEFAULT_PAGE_SIZE = 10;
 
+    String findKey(String name);
+
     Date findLastChange(String key);
 
     A authFind(String key);

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyObjectDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyObjectDAO.java
 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyObjectDAO.java
index 6368da5..3749440 100644
--- 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyObjectDAO.java
+++ 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyObjectDAO.java
@@ -41,8 +41,6 @@ public interface AnyObjectDAO extends AnyDAO<AnyObject> {
 
     AnyObject findByName(String name);
 
-    AnyObject authFindByName(String name);
-
     List<Group> findDynGroups(String key);
 
     List<ARelationship> findAllRelationships(AnyObject anyObject);

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/GroupDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/GroupDAO.java
 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/GroupDAO.java
index 04ff490..580fe32 100644
--- 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/GroupDAO.java
+++ 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/GroupDAO.java
@@ -34,8 +34,6 @@ public interface GroupDAO extends AnyDAO<Group> {
 
     Group findByName(String name);
 
-    Group authFindByName(String name);
-
     List<Group> findOwnedByUser(String userKey);
 
     List<Group> findOwnedByGroup(String groupKey);

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
index 92ba692..7f1932a 100644
--- 
a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
+++ 
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
@@ -34,8 +34,6 @@ public interface UserDAO extends AnyDAO<User> {
 
     Map<String, Integer> countByStatus();
 
-    User authFindByUsername(String username);
-
     User findByUsername(String username);
 
     User findByToken(String token);

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
index 6ef6826..15b79da 100644
--- 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
+++ 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
@@ -63,6 +63,7 @@ import 
org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.user.UMembership;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPAUser;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationEventPublisher;
@@ -120,6 +121,22 @@ public abstract class AbstractAnyDAO<A extends Any<?>> 
extends AbstractDAO<A> im
         return anyUtils;
     }
 
+    protected String findKey(final String name, final String table) {
+        Query query = entityManager().createNativeQuery(
+                "SELECT id FROM " + table + " WHERE " + 
(JPAUser.TABLE.equals(table) ? "username" : "name") + "=?");
+        query.setParameter(1, name);
+
+        String key = null;
+
+        for (Object resultKey : query.getResultList()) {
+            key = resultKey instanceof Object[]
+                    ? (String) ((Object[]) resultKey)[0]
+                    : ((String) resultKey);
+        }
+
+        return key;
+    }
+
     protected Date findLastChange(final String key, final String table) {
         Query query = entityManager().createNativeQuery(
                 "SELECT creationDate, lastChangeDate FROM " + table + " WHERE 
id=?");

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
index 046d9ea..32c655c 100644
--- 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
+++ 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
@@ -43,7 +43,6 @@ import 
org.apache.syncope.core.spring.security.DelegatedAdministrationException;
 import org.apache.syncope.core.provisioning.api.utils.EntityUtils;
 import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.AnyUtils;
@@ -95,6 +94,13 @@ public class JPAAnyObjectDAO extends 
AbstractAnyDAO<AnyObject> implements AnyObj
         return new JPAAnyUtilsFactory().getInstance(AnyTypeKind.ANY_OBJECT);
     }
 
+    @Transactional(readOnly = true)
+    @Override
+    public String findKey(final String username) {
+        return findKey(username, JPAAnyObject.TABLE);
+    }
+
+    @Transactional(readOnly = true)
     @Override
     public Date findLastChange(final String key) {
         return findLastChange(key, JPAAnyObject.TABLE);
@@ -170,22 +176,6 @@ public class JPAAnyObjectDAO extends 
AbstractAnyDAO<AnyObject> implements AnyObj
     }
 
     @Override
-    public AnyObject authFindByName(final String name) {
-        if (name == null) {
-            throw new NotFoundException("Null name");
-        }
-
-        AnyObject anyObject = findByName(name);
-        if (anyObject == null) {
-            throw new NotFoundException("Any Object " + name);
-        }
-
-        securityChecks(anyObject);
-
-        return anyObject;
-    }
-
-    @Override
     public List<ARelationship> findAllRelationships(final AnyObject anyObject) 
{
         TypedQuery<ARelationship> query = entityManager().createQuery(
                 "SELECT e FROM " + JPAARelationship.class.getSimpleName()

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
index 9d28074..dca8d69 100644
--- 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
+++ 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
@@ -46,7 +46,6 @@ import 
org.apache.syncope.core.spring.security.AuthContextUtils;
 import 
org.apache.syncope.core.spring.security.DelegatedAdministrationException;
 import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
 import org.apache.syncope.core.persistence.api.dao.search.AssignableCond;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
@@ -142,6 +141,13 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> 
implements GroupDAO {
         return new JPAAnyUtilsFactory().getInstance(AnyTypeKind.GROUP);
     }
 
+    @Transactional(readOnly = true)
+    @Override
+    public String findKey(final String username) {
+        return findKey(username, JPAGroup.TABLE);
+    }
+
+    @Transactional(readOnly = true)
     @Override
     public Date findLastChange(final String key) {
         return findLastChange(key, JPAGroup.TABLE);
@@ -207,22 +213,6 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> 
implements GroupDAO {
         return result;
     }
 
-    @Override
-    public Group authFindByName(final String name) {
-        if (name == null) {
-            throw new NotFoundException("Null name");
-        }
-
-        Group group = findByName(name);
-        if (group == null) {
-            throw new NotFoundException("Group " + name);
-        }
-
-        securityChecks(group);
-
-        return group;
-    }
-
     @Transactional(readOnly = true)
     @Override
     public List<Group> findOwnedByUser(final String userKey) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
----------------------------------------------------------------------
diff --git 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
index 7523681..e1bfaf1 100644
--- 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
+++ 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
@@ -55,7 +55,6 @@ import 
org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntit
 import org.apache.syncope.core.persistence.api.dao.AccessTokenDAO;
 import org.apache.syncope.core.persistence.api.dao.AccountRule;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.PasswordRule;
 import org.apache.syncope.core.persistence.api.dao.RealmDAO;
 import org.apache.syncope.core.persistence.api.dao.RoleDAO;
@@ -130,6 +129,13 @@ public class JPAUserDAO extends AbstractAnyDAO<User> 
implements UserDAO {
         return new JPAAnyUtilsFactory().getInstance(AnyTypeKind.USER);
     }
 
+    @Transactional(readOnly = true)
+    @Override
+    public String findKey(final String username) {
+        return findKey(username, JPAUser.TABLE);
+    }
+
+    @Transactional(readOnly = true)
     @Override
     public Date findLastChange(final String key) {
         return findLastChange(key, JPAUser.TABLE);
@@ -198,23 +204,6 @@ public class JPAUserDAO extends AbstractAnyDAO<User> 
implements UserDAO {
         }
     }
 
-    @Transactional(readOnly = true)
-    @Override
-    public User authFindByUsername(final String username) {
-        if (username == null) {
-            throw new NotFoundException("Null username");
-        }
-
-        User user = findByUsername(username);
-        if (user == null) {
-            throw new NotFoundException("User " + username);
-        }
-
-        securityChecks(user);
-
-        return user;
-    }
-
     @Override
     public User findByUsername(final String username) {
         TypedQuery<User> query = entityManager().createQuery("SELECT e FROM " 
+ JPAUser.class.getSimpleName()

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/UserDataBinder.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/UserDataBinder.java
 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/UserDataBinder.java
index 3b0c449..3f55a23 100644
--- 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/UserDataBinder.java
+++ 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/UserDataBinder.java
@@ -45,7 +45,5 @@ public interface UserDataBinder {
      */
     PropagationByResource update(User toBeUpdated, UserPatch userPatch);
 
-    boolean verifyPassword(String username, String password);
-
     boolean verifyPassword(User user, String password);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
index 501ebf4..d2d7314 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
@@ -29,7 +29,6 @@ import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.SyncopeClientCompositeException;
 import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.patch.AnyObjectPatch;
 import org.apache.syncope.common.lib.patch.AttrPatch;
 import org.apache.syncope.common.lib.patch.MembershipPatch;
@@ -78,9 +77,7 @@ public class AnyObjectDataBinderImpl extends 
AbstractAnyDataBinder implements An
     @Transactional(readOnly = true)
     @Override
     public AnyObjectTO getAnyObjectTO(final String key) {
-        return SyncopeConstants.UUID_PATTERN.matcher(key).matches()
-                ? getAnyObjectTO(anyObjectDAO.authFind(key), true)
-                : getAnyObjectTO(anyObjectDAO.authFindByName(key), true);
+        return getAnyObjectTO(anyObjectDAO.authFind(key), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
index 467874d..787353c 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
@@ -28,7 +28,6 @@ import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.SyncopeClientCompositeException;
 import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.patch.GroupPatch;
 import org.apache.syncope.common.lib.to.GroupTO;
 import org.apache.syncope.common.lib.to.TypeExtensionTO;
@@ -383,9 +382,7 @@ public class GroupDataBinderImpl extends 
AbstractAnyDataBinder implements GroupD
     @Transactional(readOnly = true)
     @Override
     public GroupTO getGroupTO(final String key) {
-        return SyncopeConstants.UUID_PATTERN.matcher(key).matches()
-                ? getGroupTO(groupDAO.authFind(key), true)
-                : getGroupTO(groupDAO.authFindByName(key), true);
+        return getGroupTO(groupDAO.authFind(key), true);
     }
 
     private void populateTransitiveResources(

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
index 3721371..fa9fa5f 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
@@ -33,7 +33,6 @@ import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.SyncopeClientCompositeException;
 import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.patch.AttrPatch;
 import org.apache.syncope.common.lib.patch.MembershipPatch;
 import org.apache.syncope.common.lib.patch.PasswordPatch;
@@ -146,12 +145,6 @@ public class UserDataBinderImpl extends 
AbstractAnyDataBinder implements UserDat
 
     @Transactional(readOnly = true)
     @Override
-    public boolean verifyPassword(final String username, final String 
password) {
-        return verifyPassword(userDAO.authFindByUsername(username), password);
-    }
-
-    @Transactional(readOnly = true)
-    @Override
     public boolean verifyPassword(final User user, final String password) {
         return ENCRYPTOR.verify(password, user.getCipherAlgorithm(), 
user.getPassword());
     }
@@ -636,9 +629,7 @@ public class UserDataBinderImpl extends 
AbstractAnyDataBinder implements UserDat
     @Transactional(readOnly = true)
     @Override
     public UserTO getUserTO(final String key) {
-        return SyncopeConstants.UUID_PATTERN.matcher(key).matches()
-                ? getUserTO(userDAO.authFind(key), true)
-                : getUserTO(userDAO.authFindByUsername(key), true);
+        return getUserTO(userDAO.authFind(key), true);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
----------------------------------------------------------------------
diff --git 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
index 2cc2413..1b7e7f2 100644
--- 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
+++ 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
@@ -51,6 +51,7 @@ import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.service.AnyService;
 import org.apache.syncope.core.logic.AbstractAnyLogic;
 import org.apache.syncope.core.logic.UserLogic;
+import org.apache.syncope.core.persistence.api.dao.AnyDAO;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 
@@ -58,10 +59,24 @@ public abstract class AbstractAnyService<TO extends AnyTO, 
P extends AnyPatch>
         extends AbstractServiceImpl
         implements AnyService<TO, P> {
 
+    protected abstract AnyDAO<?> getAnyDAO();
+
     protected abstract AbstractAnyLogic<TO, P> getAnyLogic();
 
     protected abstract P newPatch(String key);
 
+    private String getActualKey(final String key) {
+        String actualKey = key;
+        if (!SyncopeConstants.UUID_PATTERN.matcher(key).matches()) {
+            actualKey = getAnyDAO().findKey(key);
+            if (actualKey == null) {
+                throw new NotFoundException("User, Group or Any Object for " + 
key);
+            }
+        }
+
+        return actualKey;
+    }
+
     @Override
     public Set<AttrTO> read(final String key, final SchemaType schemaType) {
         TO any = read(key);
@@ -110,7 +125,7 @@ public abstract class AbstractAnyService<TO extends AnyTO, 
P extends AnyPatch>
 
     @Override
     public TO read(final String key) {
-        return getAnyLogic().read(key);
+        return getAnyLogic().read(getActualKey(key));
     }
 
     @Override
@@ -143,9 +158,19 @@ public abstract class AbstractAnyService<TO extends AnyTO, 
P extends AnyPatch>
         return createResponse(created);
     }
 
+    protected Date findLastChange(final String key) {
+        Date lastChange = getAnyDAO().findLastChange(key);
+        if (lastChange == null) {
+            throw new NotFoundException("User, Group or Any Object for " + 
key);
+        }
+
+        return lastChange;
+    }
+
     @Override
     public Response update(final P anyPatch) {
-        Date etagDate = getAnyLogic().findLastChange(anyPatch.getKey());
+        anyPatch.setKey(getActualKey(anyPatch.getKey()));
+        Date etagDate = findLastChange(anyPatch.getKey());
         checkETag(String.valueOf(etagDate.getTime()));
 
         ProvisioningResult<TO> updated = getAnyLogic().update(anyPatch, 
isNullPriorityAsync());
@@ -179,12 +204,14 @@ public abstract class AbstractAnyService<TO extends 
AnyTO, P extends AnyPatch>
 
     @Override
     public Response update(final String key, final SchemaType schemaType, 
final AttrTO attrTO) {
-        addUpdateOrReplaceAttr(key, schemaType, attrTO, 
PatchOperation.ADD_REPLACE);
-        return modificationResponse(read(key, schemaType, attrTO.getSchema()));
+        String actualKey = getActualKey(key);
+        addUpdateOrReplaceAttr(actualKey, schemaType, attrTO, 
PatchOperation.ADD_REPLACE);
+        return modificationResponse(read(actualKey, schemaType, 
attrTO.getSchema()));
     }
 
     @Override
     public Response update(final TO anyTO) {
+        anyTO.setKey(getActualKey(anyTO.getKey()));
         TO before = getAnyLogic().read(anyTO.getKey());
 
         checkETag(before.getETagValue());
@@ -196,21 +223,25 @@ public abstract class AbstractAnyService<TO extends 
AnyTO, P extends AnyPatch>
 
     @Override
     public void delete(final String key, final SchemaType schemaType, final 
String schema) {
-        addUpdateOrReplaceAttr(key, schemaType, new 
AttrTO.Builder().schema(schema).build(), PatchOperation.DELETE);
+        String actualKey = getActualKey(key);
+        addUpdateOrReplaceAttr(
+                actualKey, schemaType, new 
AttrTO.Builder().schema(schema).build(), PatchOperation.DELETE);
     }
 
     @Override
     public Response delete(final String key) {
-        Date etagDate = getAnyLogic().findLastChange(key);
+        String actualKey = getActualKey(key);
+
+        Date etagDate = findLastChange(actualKey);
         checkETag(String.valueOf(etagDate.getTime()));
 
-        ProvisioningResult<TO> deleted = getAnyLogic().delete(key, 
isNullPriorityAsync());
+        ProvisioningResult<TO> deleted = getAnyLogic().delete(actualKey, 
isNullPriorityAsync());
         return modificationResponse(deleted);
     }
 
     @Override
     public Response deassociate(final DeassociationPatch patch) {
-        Date etagDate = getAnyLogic().findLastChange(patch.getKey());
+        Date etagDate = findLastChange(patch.getKey());
         checkETag(String.valueOf(etagDate.getTime()));
 
         ProvisioningResult<TO> updated;
@@ -254,7 +285,7 @@ public abstract class AbstractAnyService<TO extends AnyTO, 
P extends AnyPatch>
 
     @Override
     public Response associate(final AssociationPatch patch) {
-        Date etagDate = getAnyLogic().findLastChange(patch.getKey());
+        Date etagDate = findLastChange(patch.getKey());
         checkETag(String.valueOf(etagDate.getTime()));
 
         ProvisioningResult<TO> updated;

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AnyObjectServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AnyObjectServiceImpl.java
 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AnyObjectServiceImpl.java
index ba7334b..cf17f80 100644
--- 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AnyObjectServiceImpl.java
+++ 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AnyObjectServiceImpl.java
@@ -29,6 +29,8 @@ import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.service.AnyObjectService;
 import org.apache.syncope.core.logic.AbstractAnyLogic;
 import org.apache.syncope.core.logic.AnyObjectLogic;
+import org.apache.syncope.core.persistence.api.dao.AnyDAO;
+import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -36,9 +38,17 @@ import org.springframework.stereotype.Service;
 public class AnyObjectServiceImpl extends AbstractAnyService<AnyObjectTO, 
AnyObjectPatch> implements AnyObjectService {
 
     @Autowired
+    private AnyObjectDAO anyObjectDAO;
+
+    @Autowired
     private AnyObjectLogic logic;
 
     @Override
+    protected AnyDAO<?> getAnyDAO() {
+        return anyObjectDAO;
+    }
+
+    @Override
     protected AbstractAnyLogic<AnyObjectTO, AnyObjectPatch> getAnyLogic() {
         return logic;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
index 50ef081..94c41c4 100644
--- 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
+++ 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
@@ -26,6 +26,8 @@ import 
org.apache.syncope.common.lib.types.BulkMembersActionType;
 import org.apache.syncope.common.rest.api.service.GroupService;
 import org.apache.syncope.core.logic.AbstractAnyLogic;
 import org.apache.syncope.core.logic.GroupLogic;
+import org.apache.syncope.core.persistence.api.dao.AnyDAO;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -33,9 +35,17 @@ import org.springframework.stereotype.Service;
 public class GroupServiceImpl extends AbstractAnyService<GroupTO, GroupPatch> 
implements GroupService {
 
     @Autowired
+    private GroupDAO groupDAO;
+
+    @Autowired
     private GroupLogic logic;
 
     @Override
+    protected AnyDAO<?> getAnyDAO() {
+        return groupDAO;
+    }
+
+    @Override
     protected AbstractAnyLogic<GroupTO, GroupPatch> getAnyLogic() {
         return logic;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
index b8a6feb..90c706a 100644
--- 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
+++ 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
@@ -27,6 +27,8 @@ import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.rest.api.service.UserService;
 import org.apache.syncope.core.logic.AbstractAnyLogic;
 import org.apache.syncope.core.logic.UserLogic;
+import org.apache.syncope.core.persistence.api.dao.AnyDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -34,9 +36,17 @@ import org.springframework.stereotype.Service;
 public class UserServiceImpl extends AbstractAnyService<UserTO, UserPatch> 
implements UserService {
 
     @Autowired
+    private UserDAO userDAO;
+
+    @Autowired
     private UserLogic logic;
 
     @Override
+    protected AnyDAO<?> getAnyDAO() {
+        return userDAO;
+    }
+
+    @Override
     protected AbstractAnyLogic<UserTO, UserPatch> getAnyLogic() {
         return logic;
     }
@@ -56,7 +66,7 @@ public class UserServiceImpl extends 
AbstractAnyService<UserTO, UserPatch> imple
 
     @Override
     public Response status(final StatusPatch statusPatch) {
-        Date etagDate = getAnyLogic().findLastChange(statusPatch.getKey());
+        Date etagDate = findLastChange(statusPatch.getKey());
         checkETag(String.valueOf(etagDate.getTime()));
 
         ProvisioningResult<UserTO> updated = logic.status(statusPatch, 
isNullPriorityAsync());

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
----------------------------------------------------------------------
diff --git 
a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
 
b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
index 03576ab..07e8e19 100644
--- 
a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
+++ 
b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
@@ -397,7 +397,7 @@ public class SAML2SPLogic extends 
AbstractSAML2Logic<AbstractBaseBean> {
         NameID nameID = assertion.getSubject().getNameID();
         String keyValue = null;
         if (StringUtils.isNotBlank(nameID.getValue())
-            && idp.getConnObjectKeyItem().getExtAttrName().equals("NameID")) {
+                && 
idp.getConnObjectKeyItem().getExtAttrName().equals("NameID")) {
 
             keyValue = nameID.getValue();
         }
@@ -419,7 +419,7 @@ public class SAML2SPLogic extends 
AbstractSAML2Logic<AbstractBaseBean> {
                 if (!attr.getAttributeValues().isEmpty()) {
                     String attrName = attr.getFriendlyName() == null ? 
attr.getName() : attr.getFriendlyName();
                     if 
(attrName.equals(idp.getConnObjectKeyItem().getExtAttrName())
-                        && attr.getAttributeValues().get(0) instanceof 
XSString) {
+                            && attr.getAttributeValues().get(0) instanceof 
XSString) {
 
                         keyValue = ((XSString) 
attr.getAttributeValues().get(0)).getValue();
                     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ReaderWriter.java
----------------------------------------------------------------------
diff --git 
a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ReaderWriter.java
 
b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ReaderWriter.java
index 3c2d547..4aebdbb 100644
--- 
a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ReaderWriter.java
+++ 
b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/saml2/SAML2ReaderWriter.java
@@ -227,7 +227,7 @@ public class SAML2ReaderWriter {
         ssoResponseValidator.setRequestId(requestId);
         ssoResponseValidator.setSpIdentifier(spEntityID);
         SSOValidatorResponse validatorResponse =
-            ssoResponseValidator.validateSamlResponse(samlResponse, 
idp.getBindingType() == SAML2BindingType.POST);
+                ssoResponseValidator.validateSamlResponse(samlResponse, 
idp.getBindingType() == SAML2BindingType.POST);
 
         if (LOG.isDebugEnabled()) {
             try {

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index 45a6214..a415b84 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -179,10 +179,8 @@ under the License.
     <dependency>
       <groupId>org.bouncycastle</groupId>
       <artifactId>bcpkix-jdk15on</artifactId>
-      <version>${bouncycastle.version}</version>
       <scope>test</scope>
     </dependency>
-
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
index 9ee5653..07ead35 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
@@ -47,7 +47,6 @@ import java.util.Optional;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.xml.namespace.QName;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
@@ -103,7 +102,9 @@ import org.w3c.dom.Element;
 public class SAML2ITCase extends AbstractITCase {
 
     private static SyncopeClient anonymous;
+
     private static Path keystorePath;
+
     private static Path truststorePath;
 
     @BeforeClass
@@ -178,15 +179,14 @@ public class SAML2ITCase extends AbstractITCase {
             // Get the signature
             QName signatureQName = new QName(SignatureConstants.XMLSIG_NS, 
"Signature");
             Element signatureElement =
-                
DOMUtils.getFirstChildWithName(responseDoc.getDocumentElement(), 
signatureQName);
+                    
DOMUtils.getFirstChildWithName(responseDoc.getDocumentElement(), 
signatureQName);
             assertNotNull(signatureElement);
 
             // Validate the signature
             XMLSignature signature = new XMLSignature(signatureElement, null);
             KeyStore keystore = KeyStore.getInstance("JKS");
             keystore.load(Loader.getResourceAsStream("keystore"), 
"changeit".toCharArray());
-            
assertTrue(signature.checkSignatureValue((X509Certificate)keystore.getCertificate("sp")));
-
+            assertTrue(signature.checkSignatureValue((X509Certificate) 
keystore.getCertificate("sp")));
         } catch (Exception e) {
             LOG.error("During SAML 2.0 SP metadata parsing", e);
             fail(e.getMessage());
@@ -462,16 +462,18 @@ public class SAML2ITCase extends AbstractITCase {
         String subjectName = "CN=Subject";
         BigInteger serial = new BigInteger("123456");
         X509v3CertificateBuilder certBuilder =
-                        new X509v3CertificateBuilder(new 
X500Name(RFC4519Style.INSTANCE, issuerName), serial, currentDate, expiryDate,
-                                        new X500Name(RFC4519Style.INSTANCE, 
subjectName),
-                                        
SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded()));
+                new X509v3CertificateBuilder(new 
X500Name(RFC4519Style.INSTANCE, issuerName), serial, currentDate,
+                        expiryDate,
+                        new X500Name(RFC4519Style.INSTANCE, subjectName),
+                        
SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded()));
         ContentSigner contentSigner = new 
JcaContentSignerBuilder("SHA256WithRSAEncryption").build(keyPair.getPrivate());
         X509Certificate certificate = new 
JcaX509CertificateConverter().getCertificate(certBuilder.build(contentSigner));
 
         // Store Private Key + Certificate in Keystore
         KeyStore keystore = KeyStore.getInstance("JKS");
         keystore.load(null, "security".toCharArray());
-        keystore.setKeyEntry("subject", keyPair.getPrivate(), 
"security".toCharArray(), new Certificate[] {certificate});
+        keystore.setKeyEntry("subject", keyPair.getPrivate(), 
"security".toCharArray(),
+                new Certificate[] { certificate });
 
         File keystoreFile = File.createTempFile("samlkeystore", ".jks");
         try (OutputStream output = 
Files.newOutputStream(keystoreFile.toPath())) {
@@ -497,7 +499,7 @@ public class SAML2ITCase extends AbstractITCase {
         KeyStore keyStore = KeyStore.getInstance("JKS");
         InputStream input = Files.newInputStream(truststorePath);
         keyStore.load(input, "security".toCharArray());
-        X509Certificate cert = 
(X509Certificate)keyStore.getCertificate("subject");
+        X509Certificate cert = (X509Certificate) 
keyStore.getCertificate("subject");
         String certEncoded = 
java.util.Base64.getMimeEncoder().encodeToString(cert.getEncoded());
 
         // Replace the "cert-placeholder" string in the metadata with the 
actual cert

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
index bab61df..3b2aa3b 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
@@ -50,6 +50,7 @@ import org.apache.syncope.common.lib.patch.DeassociationPatch;
 import org.apache.syncope.common.lib.patch.MembershipPatch;
 import org.apache.syncope.common.lib.patch.PasswordPatch;
 import org.apache.syncope.common.lib.patch.StatusPatch;
+import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
 import org.apache.syncope.common.lib.patch.UserPatch;
 import org.apache.syncope.common.lib.policy.AccountPolicyTO;
 import org.apache.syncope.common.lib.policy.PasswordPolicyTO;
@@ -567,6 +568,16 @@ public class UserITCase extends AbstractITCase {
 
         AttrTO fullNameAttr = userTO.getPlainAttr("fullname");
         assertEquals(Collections.singletonList(newFullName), 
fullNameAttr.getValues());
+
+        // update by username
+        userPatch = new UserPatch();
+        userPatch.setKey(userTO.getUsername());
+        String newUsername = UUID.randomUUID().toString();
+        userPatch.setUsername(new 
StringReplacePatchItem.Builder().value(newUsername).build());
+
+        userTO = updateUser(userPatch).getEntity();
+        assertNotNull(userTO);
+        assertEquals(newUsername, userTO.getUsername());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/syncope/blob/81515d7e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b3eb5e5..9a57132 100644
--- a/pom.xml
+++ b/pom.xml
@@ -356,8 +356,6 @@ under the License.
   <properties>
     <syncope.version>${project.version}</syncope.version>
 
-    <bouncycastle.version>1.57</bouncycastle.version>
-
     <connid.version>1.4.3.0</connid.version>
     <connid.soap.version>1.4.2-SNAPSHOT</connid.soap.version>
     <connid.rest.version>1.0.1</connid.rest.version>
@@ -1597,6 +1595,12 @@ under the License.
         <scope>test</scope>
       </dependency>
       <dependency>
+        <groupId>org.bouncycastle</groupId>
+        <artifactId>bcpkix-jdk15on</artifactId>
+        <version>1.57</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-test</artifactId>
         <version>${spring.version}</version>

Reply via email to