syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: [SYNCOPE-152] Password management, serviceProviderConfig alignment
Date Wed, 13 Dec 2017 08:36:41 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 80ee9b9cd -> 1609e2022
  refs/heads/master fba4a8bdc -> 5d259daee


[SYNCOPE-152] Password management, serviceProviderConfig alignment


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

Branch: refs/heads/2_0_X
Commit: 1609e20226d09f122a6e51cfad2b266da9997cf3
Parents: 80ee9b9
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Wed Dec 13 09:36:18 2017 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Wed Dec 13 09:36:18 2017 +0100

----------------------------------------------------------------------
 .../org/apache/syncope/core/logic/SCIMDataBinder.java |  1 +
 .../java/org/apache/syncope/core/logic/SCIMLogic.java |  2 +-
 .../ext/scimv2/api/data/SCIMSearchRequest.java        |  8 ++++----
 .../ext/scimv2/cxf/service/AbstractService.java       | 14 ++++++++++++--
 .../java/org/apache/syncope/fit/core/SCIMITCase.java  | 12 +++++++++++-
 5 files changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/1609e202/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
index 598de65..6a89169 100644
--- a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
+++ b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
@@ -452,6 +452,7 @@ public class SCIMDataBinder {
         UserTO userTO = new UserTO();
         userTO.setRealm(SyncopeConstants.ROOT_REALM);
         userTO.setKey(user.getId());
+        userTO.setPassword(user.getPassword());
         userTO.setUsername(user.getUserName());
 
         SCIMConf conf = confManager.get();

http://git-wip-us.apache.org/repos/asf/syncope/blob/1609e202/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
index 34eded0..04757f2 100644
--- a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
+++ b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
@@ -102,7 +102,7 @@ public class SCIMLogic extends AbstractLogic<AbstractBaseBean> {
                                 conf.getLastChangeDate(),
                                 conf.getETagValue(),
                                 uriBuilder.build().toASCIIString()),
-                        new ConfigurationOption(true),
+                        new ConfigurationOption(false),
                         new BulkConfigurationOption(false, conf.getBulkMaxOperations(), conf.getBulkMaxPayloadSize()),
                         new FilterConfigurationOption(true, conf.getFilterMaxResults()),
                         new ConfigurationOption(true),

http://git-wip-us.apache.org/repos/asf/syncope/blob/1609e202/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/data/SCIMSearchRequest.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/data/SCIMSearchRequest.java
b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/data/SCIMSearchRequest.java
index 570ee3a..2fb73c6 100644
--- a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/data/SCIMSearchRequest.java
+++ b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/data/SCIMSearchRequest.java
@@ -85,12 +85,12 @@ public class SCIMSearchRequest extends SCIMBean {
         return sortOrder;
     }
 
-    public Integer getStartIndex() {
-        return startIndex;
+    public int getStartIndex() {
+        return startIndex == null ? 1 : startIndex;
     }
 
-    public Integer getCount() {
-        return count;
+    public int getCount() {
+        return count == null ? 25 : count;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/1609e202/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
index c39c2e3..94531a4 100644
--- a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
+++ b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
@@ -46,9 +46,11 @@ 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.dao.search.OrderByClause;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
+import org.apache.syncope.ext.scimv2.api.BadRequestException;
 import org.apache.syncope.ext.scimv2.api.data.ListResponse;
 import org.apache.syncope.ext.scimv2.api.data.SCIMResource;
 import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
+import org.apache.syncope.ext.scimv2.api.type.ErrorType;
 import org.apache.syncope.ext.scimv2.api.type.Resource;
 import org.apache.syncope.ext.scimv2.api.type.SortOrder;
 import org.slf4j.Logger;
@@ -187,13 +189,17 @@ abstract class AbstractService<R extends SCIMResource> {
             throw new UnsupportedOperationException();
         }
 
+        if (request.getCount() > confManager().get().getFilterMaxResults()) {
+            throw new BadRequestException(ErrorType.tooMany, "Too many results requested");
+        }
+
         SearchCondVisitor visitor = new SearchCondVisitor(type, confManager().get());
 
-        int startIndex = request.getStartIndex() == null || request.getStartIndex() <=
1
+        int startIndex = request.getStartIndex() <= 1
                 ? 1
                 : (request.getStartIndex() / AnyDAO.DEFAULT_PAGE_SIZE) + 1;
 
-        int itemsPerPage = request.getCount() == null ? AnyDAO.DEFAULT_PAGE_SIZE : request.getCount();
+        int itemsPerPage = request.getCount() <= 1 ? AnyDAO.DEFAULT_PAGE_SIZE : request.getCount();
 
         List<OrderByClause> sort;
         if (request.getSortBy() == null) {
@@ -217,6 +223,10 @@ abstract class AbstractService<R extends SCIMResource> {
                 SyncopeConstants.ROOT_REALM,
                 false);
 
+        if (result.getLeft() > confManager().get().getFilterMaxResults()) {
+            throw new BadRequestException(ErrorType.tooMany, "Too many results found");
+        }
+
         ListResponse<R> response = new ListResponse<>(
                 result.getLeft(), startIndex == 1 ? 1 : startIndex - 1, itemsPerPage);
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/1609e202/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
index e808709..640bef6 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
@@ -124,7 +124,11 @@ public class SCIMITCase extends AbstractITCase {
 
         ServiceProviderConfig serviceProviderConfig = response.readEntity(ServiceProviderConfig.class);
         assertNotNull(serviceProviderConfig);
+        assertFalse(serviceProviderConfig.getPatch().isSupported());
+        assertFalse(serviceProviderConfig.getBulk().isSupported());
+        assertTrue(serviceProviderConfig.getChangePassword().isSupported());
         assertTrue(serviceProviderConfig.getEtag().isSupported());
+        assertTrue(serviceProviderConfig.getSort().isSupported());
     }
 
     @Test
@@ -238,7 +242,12 @@ public class SCIMITCase extends AbstractITCase {
     public void list() throws IOException {
         Assume.assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
 
-        Response response = webClient().path("Groups").
+        Response response = webClient().path("Groups").query("count", 1100000).get();
+        assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+        SCIMError error = response.readEntity(SCIMError.class);
+        assertEquals(ErrorType.tooMany, error.getScimType());
+
+        response = webClient().path("Groups").
                 query("sortBy", "displayName").
                 query("count", 11).
                 get();
@@ -327,6 +336,7 @@ public class SCIMITCase extends AbstractITCase {
 
     private SCIMUser getSampleUser(final String username) {
         SCIMUser user = new SCIMUser(null, Collections.singletonList(Resource.User.schema()),
null, username, true);
+        user.setPassword("password123");
 
         SCIMUserName name = new SCIMUserName();
         name.setGivenName(username);


Mime
View raw message