Repository: syncope
Updated Branches:
  refs/heads/master e7656e11b -> 79d51b332


[SYNCOPE-1213] externalized max file size, for plain attributes binary fields, 
to properties file


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

Branch: refs/heads/master
Commit: 79d51b332855de2d07bbfc2afb639d74bd1cb27e
Parents: e7656e1
Author: Andrea Patricelli <andreapatrice...@apache.org>
Authored: Thu Sep 28 17:42:56 2017 +0200
Committer: Andrea Patricelli <andreapatrice...@apache.org>
Committed: Thu Sep 28 17:43:33 2017 +0200

----------------------------------------------------------------------
 .../console/SyncopeConsoleApplication.java      |  7 +++
 .../markup/html/form/BinaryFieldPanel.java      |  3 +-
 .../src/main/resources/console.properties       |  1 +
 .../enduser/SyncopeEnduserApplication.java      |  7 +++
 .../enduser/adapters/PlatformInfoAdapter.java   |  1 +
 .../enduser/model/PlatformInfoRequest.java      | 10 ++++
 .../resources/META-INF/resources/app/js/app.js  |  9 ++-
 .../resources/app/js/directives/fileInput.js    | 62 ++++++++++----------
 .../src/main/resources/enduser.properties       |  1 +
 .../src/main/resources/console.properties       |  1 +
 .../src/test/resources/console.properties       |  1 +
 .../src/main/resources/enduser.properties       |  1 +
 .../src/test/resources/enduser.properties       |  1 +
 13 files changed, 71 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
index 467312c..94ab154 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
@@ -104,6 +104,8 @@ public class SyncopeConsoleApplication extends 
AuthenticatedWebApplication {
 
     private String useGZIPCompression;
 
+    private Integer maxFileSizeMB;
+
     private List<String> domains;
 
     private Map<String, Class<? extends BasePage>> pageClasses;
@@ -153,6 +155,7 @@ public class SyncopeConsoleApplication extends 
AuthenticatedWebApplication {
         Args.notNull(rootPath, "<rootPath>");
         useGZIPCompression = props.getProperty("useGZIPCompression");
         Args.notNull(useGZIPCompression, "<useGZIPCompression>");
+        maxFileSizeMB = Integer.valueOf(props.getProperty("maxFileSizeMB", 
"4"));
 
         String csrf = props.getProperty("csrf");
 
@@ -280,6 +283,10 @@ public class SyncopeConsoleApplication extends 
AuthenticatedWebApplication {
         return reconciliationReportKey;
     }
 
+    public Integer getMaxFileSizeMB() {
+        return maxFileSizeMB;
+    }
+
     public SyncopeClientFactoryBean newClientFactory() {
         return new SyncopeClientFactoryBean().
                 setAddress(scheme + "://" + host + ":" + port + "/" + 
rootPath).

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
index 659140f..753b2c6 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleApplication;
 import org.apache.syncope.client.console.SyncopeConsoleSession;
 import org.apache.syncope.client.console.commons.Constants;
 import org.apache.syncope.client.console.commons.HttpResourceStream;
@@ -91,7 +92,7 @@ public class BinaryFieldPanel extends FieldPanel<String> {
 
         uploadForm = new StatelessForm<>("uploadForm");
         uploadForm.setMultiPart(true);
-        uploadForm.setMaxSize(Bytes.megabytes(4));
+        
uploadForm.setMaxSize(Bytes.megabytes(SyncopeConsoleApplication.get().getMaxFileSizeMB()));
         add(uploadForm);
 
         container = new WebMarkupContainer("previewContainer") {

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/console/src/main/resources/console.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/console.properties 
b/client/console/src/main/resources/console.properties
index c2da7e3..44801b4 100644
--- a/client/console/src/main/resources/console.properties
+++ b/client/console/src/main/resources/console.properties
@@ -26,6 +26,7 @@ host=localhost
 port=8080
 rootPath=/syncope/rest/
 useGZIPCompression=true
+maxFileSizeMB=5
 
 csrf=true
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java
----------------------------------------------------------------------
diff --git 
a/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java
 
b/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java
index 5871842..19fcc6c 100644
--- 
a/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java
+++ 
b/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java
@@ -82,6 +82,8 @@ public class SyncopeEnduserApplication extends WebApplication 
implements Seriali
 
     private boolean xsrfEnabled;
 
+    private Integer maxFileSizeMB;
+    
     private SyncopeClientFactoryBean clientFactory;
 
     private Map<String, CustomAttributesInfo> customForm;
@@ -119,6 +121,7 @@ public class SyncopeEnduserApplication extends 
WebApplication implements Seriali
         Args.notNull(rootPath, "<rootPath>");
         String useGZIPCompression = props.getProperty("useGZIPCompression");
         Args.notNull(useGZIPCompression, "<useGZIPCompression>");
+        maxFileSizeMB = Integer.valueOf(props.getProperty("maxFileSizeMB", 
"4"));
 
         clientFactory = new SyncopeClientFactoryBean().
                 setAddress(scheme + "://" + host + ":" + port + "/" + 
rootPath).
@@ -266,6 +269,10 @@ public class SyncopeEnduserApplication extends 
WebApplication implements Seriali
         return xsrfEnabled;
     }
 
+    public Integer getMaxFileSizeMB() {
+        return maxFileSizeMB;
+    }
+    
     public Map<String, CustomAttributesInfo> getCustomForm() {
         return customForm;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/enduser/src/main/java/org/apache/syncope/client/enduser/adapters/PlatformInfoAdapter.java
----------------------------------------------------------------------
diff --git 
a/client/enduser/src/main/java/org/apache/syncope/client/enduser/adapters/PlatformInfoAdapter.java
 
b/client/enduser/src/main/java/org/apache/syncope/client/enduser/adapters/PlatformInfoAdapter.java
index a961576..999f496 100644
--- 
a/client/enduser/src/main/java/org/apache/syncope/client/enduser/adapters/PlatformInfoAdapter.java
+++ 
b/client/enduser/src/main/java/org/apache/syncope/client/enduser/adapters/PlatformInfoAdapter.java
@@ -34,6 +34,7 @@ public final class PlatformInfoAdapter {
         
request.setPwdResetRequiringSecurityQuestions(platformInfo.isPwdResetRequiringSecurityQuestions());
         request.setVersion(platformInfo.getVersion());
         
request.setCaptchaEnabled(SyncopeEnduserApplication.get().isCaptchaEnabled());
+        
request.setMaxFileSizeMB(SyncopeEnduserApplication.get().getMaxFileSizeMB());
         request.setCustomForm(customForm);
 
         return request;

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/enduser/src/main/java/org/apache/syncope/client/enduser/model/PlatformInfoRequest.java
----------------------------------------------------------------------
diff --git 
a/client/enduser/src/main/java/org/apache/syncope/client/enduser/model/PlatformInfoRequest.java
 
b/client/enduser/src/main/java/org/apache/syncope/client/enduser/model/PlatformInfoRequest.java
index a75ae53..5480e10 100644
--- 
a/client/enduser/src/main/java/org/apache/syncope/client/enduser/model/PlatformInfoRequest.java
+++ 
b/client/enduser/src/main/java/org/apache/syncope/client/enduser/model/PlatformInfoRequest.java
@@ -35,6 +35,8 @@ public class PlatformInfoRequest implements Serializable {
 
     private boolean captchaEnabled;
 
+    private int maxFileSizeMB;
+
     private Map<String, CustomAttributesInfo> customForm;
 
     public PlatformInfoRequest() {
@@ -64,6 +66,10 @@ public class PlatformInfoRequest implements Serializable {
         this.version = version;
     }
 
+     public int getMaxFileSizeMB() {
+        return maxFileSizeMB;
+    }
+    
     public void setSelfRegAllowed(final boolean selfRegAllowed) {
         this.selfRegAllowed = selfRegAllowed;
     }
@@ -80,6 +86,10 @@ public class PlatformInfoRequest implements Serializable {
         this.captchaEnabled = captchaEnabled;
     }
 
+    public void setMaxFileSizeMB(final int maxFileSizeMB) {
+        this.maxFileSizeMB = maxFileSizeMB;
+    }
+
     public Map<String, CustomAttributesInfo> getCustomForm() {
         return customForm;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js 
b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
index 253609a..2616398 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
@@ -359,6 +359,7 @@ app.controller('ApplicationController', ['$scope', 
'$rootScope', '$location', 'I
       $rootScope.pwdResetRequiringSecurityQuestions = false;
       $rootScope.captchaEnabled = false;
       $rootScope.validationEnabled = true;
+      $rootScope.maxFileSizeMB = 4;
       $rootScope.saml2idps = {
         available: [],
         selected: {}
@@ -371,6 +372,7 @@ app.controller('ApplicationController', ['$scope', 
'$rootScope', '$location', 'I
                 $rootScope.version = response.version;
                 $rootScope.pwdResetRequiringSecurityQuestions = 
response.pwdResetRequiringSecurityQuestions;
                 $rootScope.captchaEnabled = response.captchaEnabled;
+                $rootScope.maxFileSizeMB = response.maxFileSizeMB;
                 /* 
                  * USER form customization JSON
                  */
@@ -399,13 +401,16 @@ app.controller('ApplicationController', ['$scope', 
'$rootScope', '$location', 'I
       };
       $rootScope.saml2spExtAvailable = function () {
         return $rootScope.saml2idps.available.length > 0;
-      }
+      };
       $rootScope.saml2login = function () {
         window.location.href = '../saml2sp/login?idp=' + 
$rootScope.saml2idps.selected.entityID;
-      }
+      };
       $rootScope.getVersion = function () {
         return $rootScope.version;
       };
+      $rootScope.getMaxFileSizeMB = function () {
+        return $rootScope.maxFileSizeMB;
+      };
       /* 
        * USER Attributes sorting strategies
        */

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/enduser/src/main/resources/META-INF/resources/app/js/directives/fileInput.js
----------------------------------------------------------------------
diff --git 
a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/fileInput.js
 
b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/fileInput.js
index 130a2e4..d1a173d 100644
--- 
a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/fileInput.js
+++ 
b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/fileInput.js
@@ -19,37 +19,37 @@
 
 'use strict';
 angular.module('self')
-        .directive('fileInput', function () {
-          return {
-            restrict: 'A',
-            link: function ($scope, element, attrs) {
-              var previewImgComposite;
-              if ($scope.previewImg) {
-                previewImgComposite = "data:image/png;base64," + 
$scope.previewImg;
-              } else
-                previewImgComposite = null;
-              $(element).fileinput({
-                showUpload: false,
-                showCaption: false,
-                showCancel: false,
-                showClose: true,
-                showRemove: false,
-                fileActionSettings: {'showZoom': false, indicatorNew: '', 
'removeTitle': 'boh'},
-                removeClass: "btn btn-default",
-                browseClass: "btn btn-default",
-                browseLabel: '',
-                dragIcon: '',
-                browseIcon: '',
-                initialPreviewAsData: true,
-                overwriteInitial: true,
+        .directive('fileInput', ['$rootScope', function ($rootScope) {
+            return {
+              restrict: 'A',
+              link: function ($scope, element, attrs) {
+                var previewImgComposite;
+                if ($scope.previewImg) {
+                  previewImgComposite = "data:image/png;base64," + 
$scope.previewImg;
+                } else
+                  previewImgComposite = null;
+                $(element).fileinput({
+                  showUpload: false,
+                  showCaption: false,
+                  showCancel: false,
+                  showClose: true,
+                  showRemove: false,
+                  fileActionSettings: {'showZoom': false, indicatorNew: '', 
'removeTitle': 'boh'},
+                  removeClass: "btn btn-default",
+                  browseClass: "btn btn-default",
+                  browseLabel: '',
+                  dragIcon: '',
+                  browseIcon: '',
+                  initialPreviewAsData: true,
+                  overwriteInitial: true,
 //                maxFileCount: 1,
 //                'previewFileType': 'any',
-                initialPreview: [
-                  previewImgComposite
-                ],
-                'maxFileSize': 5120
-              });
-            }
-          };
-        });
+                  initialPreview: [
+                    previewImgComposite
+                  ],
+                  'maxFileSize': parseInt($rootScope.maxFileSizeMB) * 1000
+                });
+              }
+            };
+          }]);
         
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/client/enduser/src/main/resources/enduser.properties
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/enduser.properties 
b/client/enduser/src/main/resources/enduser.properties
index df51b73..30a6d0e 100644
--- a/client/enduser/src/main/resources/enduser.properties
+++ b/client/enduser/src/main/resources/enduser.properties
@@ -22,6 +22,7 @@ anonymousUser=${anonymousUser}
 anonymousKey=${anonymousKey}
 adminUser=${adminUser}
 useGZIPCompression=true
+maxFileSizeMB=4
 
 scheme=http
 host=localhost

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/fit/console-reference/src/main/resources/console.properties
----------------------------------------------------------------------
diff --git a/fit/console-reference/src/main/resources/console.properties 
b/fit/console-reference/src/main/resources/console.properties
index 418f2f0..5f55551 100644
--- a/fit/console-reference/src/main/resources/console.properties
+++ b/fit/console-reference/src/main/resources/console.properties
@@ -26,6 +26,7 @@ host=localhost
 port=9080
 rootPath=/syncope/rest/
 useGZIPCompression=true
+maxFileSizeMB=5
 
 csrf=true
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/fit/core-reference/src/test/resources/console.properties
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/resources/console.properties 
b/fit/core-reference/src/test/resources/console.properties
index addbf5e..12d0879 100644
--- a/fit/core-reference/src/test/resources/console.properties
+++ b/fit/core-reference/src/test/resources/console.properties
@@ -26,6 +26,7 @@ host=localhost
 port=9080
 rootPath=/syncope/rest/
 useGZIPCompression=true
+maxFileSizeMB=5
 
 csrf=false
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/fit/enduser-reference/src/main/resources/enduser.properties
----------------------------------------------------------------------
diff --git a/fit/enduser-reference/src/main/resources/enduser.properties 
b/fit/enduser-reference/src/main/resources/enduser.properties
index b42cc34..6e90d65 100644
--- a/fit/enduser-reference/src/main/resources/enduser.properties
+++ b/fit/enduser-reference/src/main/resources/enduser.properties
@@ -22,6 +22,7 @@ anonymousUser=${anonymousUser}
 anonymousKey=${anonymousKey}
 adminUser=${adminUser}
 useGZIPCompression=true
+maxFileSizeMB=4
 
 scheme=http
 host=localhost

http://git-wip-us.apache.org/repos/asf/syncope/blob/79d51b33/fit/enduser-reference/src/test/resources/enduser.properties
----------------------------------------------------------------------
diff --git a/fit/enduser-reference/src/test/resources/enduser.properties 
b/fit/enduser-reference/src/test/resources/enduser.properties
index 7387c0d..a906d15 100644
--- a/fit/enduser-reference/src/test/resources/enduser.properties
+++ b/fit/enduser-reference/src/test/resources/enduser.properties
@@ -22,6 +22,7 @@ anonymousUser=${anonymousUser}
 anonymousKey=${anonymousKey}
 adminUser=${adminUser}
 useGZIPCompression=true
+maxFileSizeMB=4
 
 scheme=http
 host=localhost

Reply via email to