From 2316657c64d7a096428c3f3286af264540a5893d Mon Sep 17 00:00:00 2001 From: jgomer2001 Date: Mon, 25 Jul 2022 09:09:19 -0500 Subject: [PATCH 1/3] feat: add bulk parameters to scim configuration #1819 --- .../templates/jans-scim/dynamic-conf.json | 2 ++ .../scim2/provider/config/BulkConfig.java | 8 ++++---- .../jans/scim/ws/rs/scim2/BulkWebService.java | 18 ++++++++---------- .../ws/rs/scim2/ServiceProviderConfigWS.java | 2 ++ .../jans/scim/model/conf/AppConfiguration.java | 18 ++++++++++++++++++ 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/jans-linux-setup/jans_setup/templates/jans-scim/dynamic-conf.json b/jans-linux-setup/jans_setup/templates/jans-scim/dynamic-conf.json index 38ce9dc506f..6b7ffe17f58 100644 --- a/jans-linux-setup/jans_setup/templates/jans-scim/dynamic-conf.json +++ b/jans-linux-setup/jans_setup/templates/jans-scim/dynamic-conf.json @@ -10,6 +10,8 @@ "umaIssuer":"https://%(hostname)s", "maxCount": 200, + "bulkMaxOperations": 30, + "bulkMaxPayloadSize": 3072000, "userExtensionSchemaURI": "urn:ietf:params:scim:schemas:extension:gluu:2.0:User", "useLocalCache":true, diff --git a/jans-scim/model/src/main/java/io/jans/scim/model/scim2/provider/config/BulkConfig.java b/jans-scim/model/src/main/java/io/jans/scim/model/scim2/provider/config/BulkConfig.java index 71ada679edc..3c532f6c36b 100644 --- a/jans-scim/model/src/main/java/io/jans/scim/model/scim2/provider/config/BulkConfig.java +++ b/jans-scim/model/src/main/java/io/jans/scim/model/scim2/provider/config/BulkConfig.java @@ -27,7 +27,7 @@ public class BulkConfig { isRequired = true, mutability = AttributeDefinition.Mutability.READ_ONLY, type = AttributeDefinition.Type.INTEGER) - private long maxOperations; + private int maxOperations; @Attribute(description = " An integer value specifying the maximum payload size in bytes", isRequired = true, @@ -46,7 +46,7 @@ public BulkConfig(){ } * @param maxOperations Specifies the maximum number of operations supported per bulk. * @param maxPayloadSize Specifies the maximum payload size in bytes supported per bulk. */ - public BulkConfig(boolean supported, long maxOperations, long maxPayloadSize) { + public BulkConfig(boolean supported, int maxOperations, long maxPayloadSize) { this.supported = supported; this.maxOperations = maxOperations; this.maxPayloadSize = maxPayloadSize; @@ -64,7 +64,7 @@ public boolean isSupported() { * Retrieves the maximum number of operations supported in a bulk. * @return The maximum number of operations. */ - public long getMaxOperations() { + public int getMaxOperations() { return maxOperations; } @@ -80,7 +80,7 @@ public void setSupported(boolean supported) { this.supported = supported; } - public void setMaxOperations(long maxOperations) { + public void setMaxOperations(int maxOperations) { this.maxOperations = maxOperations; } diff --git a/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/BulkWebService.java b/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/BulkWebService.java index e1d8bffc64d..d46483aca0f 100644 --- a/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/BulkWebService.java +++ b/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/BulkWebService.java @@ -1,7 +1,5 @@ package io.jans.scim.ws.rs.scim2; -import static io.jans.scim.model.scim2.Constants.MAX_BULK_OPERATIONS; -import static io.jans.scim.model.scim2.Constants.MAX_BULK_PAYLOAD_SIZE; import static io.jans.scim.model.scim2.Constants.MEDIA_TYPE_SCIM_JSON; import static io.jans.scim.model.scim2.Constants.UTF8_CHARSET_FRAGMENT; import static io.jans.scim.ws.rs.scim2.BulkWebService.Verb.DELETE; @@ -178,7 +176,7 @@ private Response prepareRequest(BulkRequest request, String contentLength) { Response response=null; if (request.getFailOnErrors()==null) - request.setFailOnErrors(MAX_BULK_OPERATIONS); + request.setFailOnErrors(appConfiguration.getBulkMaxOperations()); List operations=request.getOperations(); @@ -186,25 +184,25 @@ private Response prepareRequest(BulkRequest request, String contentLength) { response=getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_VALUE, "No operations supplied"); else { - int contentLen; + long contentLen; try{ //log.debug("CONT LEN {}", contentLength); - contentLen=Integer.valueOf(contentLength); + contentLen=Long.valueOf(contentLength); } catch (Exception e){ - contentLen=MAX_BULK_PAYLOAD_SIZE; + contentLen=appConfiguration.getBulkMaxPayloadSize(); } - boolean payloadExceeded=contentLen > MAX_BULK_PAYLOAD_SIZE; - boolean operationsExceeded=operations.size() > MAX_BULK_OPERATIONS; + boolean payloadExceeded=contentLen > appConfiguration.getBulkMaxPayloadSize(); + boolean operationsExceeded=operations.size() > appConfiguration.getBulkMaxOperations(); StringBuilder sb=new StringBuilder(); if (payloadExceeded) sb.append("The size of the bulk operation exceeds the maxPayloadSize ("). - append(MAX_BULK_PAYLOAD_SIZE).append(" bytes). "); + append(appConfiguration.getBulkMaxPayloadSize()).append(" bytes). "); if (operationsExceeded) sb.append("The number of operations exceed the maxOperations value ("). - append(MAX_BULK_OPERATIONS).append("). "); + append(appConfiguration.getBulkMaxOperations()).append("). "); if (sb.length()>0) response=getErrorResponse(REQUEST_ENTITY_TOO_LARGE, sb.toString()); diff --git a/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/ServiceProviderConfigWS.java b/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/ServiceProviderConfigWS.java index a567dfb57be..3b99902915f 100644 --- a/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/ServiceProviderConfigWS.java +++ b/jans-scim/server/src/main/java/io/jans/scim/ws/rs/scim2/ServiceProviderConfigWS.java @@ -39,6 +39,8 @@ public Response serve(){ try { ServiceProviderConfig serviceProviderConfig = new ServiceProviderConfig(); serviceProviderConfig.getFilter().setMaxResults(appConfiguration.getMaxCount()); + serviceProviderConfig.getBulk().setMaxOperations(appConfiguration.getBulkMaxOperations()); + serviceProviderConfig.getBulk().setMaxPayloadSize(appConfiguration.getBulkMaxPayloadSize()); Meta meta = new Meta(); meta.setLocation(endpointUrl); diff --git a/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java b/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java index b6a9ac80c13..348b01410a8 100644 --- a/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java +++ b/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java @@ -34,6 +34,8 @@ public class AppConfiguration implements Configuration, Serializable { private ScimMode protectionMode; private int maxCount; + private int bulkMaxOperations; + private long bulkMaxPayloadSize; private String userExtensionSchemaURI; private String loggingLevel; @@ -102,6 +104,22 @@ public int getMaxCount() { public void setMaxCount(int maxCount) { this.maxCount = maxCount; } + + public int getBulkMaxOperations() { + return bulkMaxOperations; + } + + public void setBulkMaxOperations(int bulkMaxOperations) { + this.bulkMaxOperations = bulkMaxOperations; + } + + public long getBulkMaxPayloadSize() { + return bulkMaxPayloadSize; + } + + public void setBulkMaxPayloadSize() { + this.bulkMaxPayloadSize = bulkMaxPayloadSize; + } public String getUserExtensionSchemaURI() { return userExtensionSchemaURI; From 1243deaeb9ec2b804bd62c4c987b22c3cbf889c0 Mon Sep 17 00:00:00 2001 From: jgomer2001 Date: Mon, 25 Jul 2022 09:15:34 -0500 Subject: [PATCH 2/3] docs: no docs #1819 --- docs/admin/scim.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/admin/scim.md b/docs/admin/scim.md index 23c82ce64a6..c3ae1c974bf 100644 --- a/docs/admin/scim.md +++ b/docs/admin/scim.md @@ -13,3 +13,4 @@ ## OAuth Protection ## Security Considerations + From 88d73b73852da7fa45b9eb3944e560911f4c1b0b Mon Sep 17 00:00:00 2001 From: jgomer2001 Date: Mon, 25 Jul 2022 09:34:20 -0500 Subject: [PATCH 3/3] fix: fix setter #1819 --- .../src/main/java/io/jans/scim/model/conf/AppConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java b/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java index 348b01410a8..3e3b9b3ff34 100644 --- a/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java +++ b/jans-scim/service/src/main/java/io/jans/scim/model/conf/AppConfiguration.java @@ -117,7 +117,7 @@ public long getBulkMaxPayloadSize() { return bulkMaxPayloadSize; } - public void setBulkMaxPayloadSize() { + public void setBulkMaxPayloadSize(long bulkMaxPayloadSize) { this.bulkMaxPayloadSize = bulkMaxPayloadSize; }