diff --git a/src/java/fr/paris/lutece/portal/web/upload/DosGuardFilter.java b/src/java/fr/paris/lutece/portal/web/upload/DosGuardFilter.java index ca64f652f6..c864d5bbb1 100644 --- a/src/java/fr/paris/lutece/portal/web/upload/DosGuardFilter.java +++ b/src/java/fr/paris/lutece/portal/web/upload/DosGuardFilter.java @@ -34,6 +34,7 @@ package fr.paris.lutece.portal.web.upload; import fr.paris.lutece.portal.service.util.AppLogService; +import fr.paris.lutece.portal.service.util.AppPropertiesService; import java.io.IOException; @@ -54,6 +55,14 @@ */ public class DosGuardFilter implements Filter { + // properties + private static String PROPERTY_DOSGUARDFILTER_MINCONTENTLENGTH = "lutece.upload.dosguard.minContentLength"; + private static String PROPERTY_DOSGUARDFILTER_MININTERVAL = "lutece.upload.dosguard.minInterval"; + + // constants + private static int CONSTANT_DEFAULT_DOSGUARDFILTER_MINCONTENTLENGTH = 10240 ; + private static int CONSTANT_DEFAULT_DOSGUARDFILTER_MININTERVAL = 2000 ; + // Initial capacity of the HashMap private static final int INITIAL_CAPACITY = 100; private FilterConfig _filterConfig; @@ -81,28 +90,9 @@ public void init( FilterConfig config ) throws ServletException _mapLastRequestTimes = new HashMap( INITIAL_CAPACITY ); _listOrderedRequests = new LinkedList( ); - try - { - String paramValue = _filterConfig.getInitParameter( "minContentLength" ); - - if ( paramValue != null ) - { - _nMinContentLength = Integer.parseInt( paramValue ); - } - - paramValue = _filterConfig.getInitParameter( "minInterval" ); + _nMinContentLength = AppPropertiesService.getPropertyInt( PROPERTY_DOSGUARDFILTER_MINCONTENTLENGTH, CONSTANT_DEFAULT_DOSGUARDFILTER_MINCONTENTLENGTH ) ; + _nMinInterval = AppPropertiesService.getPropertyInt( PROPERTY_DOSGUARDFILTER_MININTERVAL, CONSTANT_DEFAULT_DOSGUARDFILTER_MININTERVAL ) ; - if ( paramValue != null ) - { - _nMinInterval = Integer.parseInt( paramValue ); - } - } - catch( NumberFormatException ex ) - { - ServletException servletEx = new ServletException( ex.getMessage( ) ); - servletEx.initCause( ex ); - throw servletEx; - } } /** diff --git a/webapp/WEB-INF/conf/lutece.properties b/webapp/WEB-INF/conf/lutece.properties index 7ec593576b..98a6f64835 100644 --- a/webapp/WEB-INF/conf/lutece.properties +++ b/webapp/WEB-INF/conf/lutece.properties @@ -227,6 +227,13 @@ askPasswordReinitialization.admin.level=0 input.xss.characters=<>#" xss.error.message= Les caract\u00e8res < > # & et " sont interdits dans le contenu de votre message. +################################################################################# +# DosGuard upload Filter +# minContentLength: Requests below this size (in bytes) will always be allowed +# minInterval: Minimum interval (in ms) allowed between two requests from the same client +lutece.upload.dosguard.minContentLength=10240 +lutece.upload.dosguard.minInterval=2000 + ################################################################################ # Paginators # diff --git a/webapp/WEB-INF/web.xml b/webapp/WEB-INF/web.xml index 676cd990c4..6f25519b39 100644 --- a/webapp/WEB-INF/web.xml +++ b/webapp/WEB-INF/web.xml @@ -71,16 +71,6 @@ dosFilter fr.paris.lutece.portal.web.upload.DosGuardFilter - - - minContentLength - 10240 - - - - minInterval - 2000 - pluginsFilters