You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/12/13 08:36:42 UTC
[2/2] syncope git commit: [SYNCOPE-152] Password management,
serviceProviderConfig alignment
[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/5d259dae
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/5d259dae
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/5d259dae
Branch: refs/heads/master
Commit: 5d259daee8eb0753b686d1ce0de23b8b39c172de
Parents: fba4a8b
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Dec 13 09:36:18 2017 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Dec 13 09:36:31 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/5d259dae/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 c72c9bd..80c90d9 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
@@ -445,6 +445,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/5d259dae/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/5d259dae/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/5d259dae/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 6e2715f5..cb8bb5f 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/5d259dae/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 7e01a3a..290f888 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 {
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);