|
34 | 34 | package fr.paris.lutece.portal.web.upload; |
35 | 35 |
|
36 | 36 | import fr.paris.lutece.portal.service.util.AppLogService; |
| 37 | +import fr.paris.lutece.portal.service.util.AppPropertiesService; |
37 | 38 |
|
38 | 39 | import java.io.IOException; |
39 | 40 |
|
|
54 | 55 | */ |
55 | 56 | public class DosGuardFilter implements Filter |
56 | 57 | { |
| 58 | + // properties |
| 59 | + private static String PROPERTY_DOSGUARDFILTER_MINCONTENTLENGTH = "lutece.upload.dosguard.minContentLength"; |
| 60 | + private static String PROPERTY_DOSGUARDFILTER_MININTERVAL = "lutece.upload.dosguard.minInterval"; |
| 61 | + |
| 62 | + // constants |
| 63 | + private static int CONSTANT_DEFAULT_DOSGUARDFILTER_MINCONTENTLENGTH = 10240 ; |
| 64 | + private static int CONSTANT_DEFAULT_DOSGUARDFILTER_MININTERVAL = 2000 ; |
| 65 | + |
57 | 66 | // Initial capacity of the HashMap |
58 | 67 | private static final int INITIAL_CAPACITY = 100; |
59 | 68 | private FilterConfig _filterConfig; |
@@ -81,28 +90,9 @@ public void init( FilterConfig config ) throws ServletException |
81 | 90 | _mapLastRequestTimes = new HashMap<String, Long>( INITIAL_CAPACITY ); |
82 | 91 | _listOrderedRequests = new LinkedList<Entry>( ); |
83 | 92 |
|
84 | | - try |
85 | | - { |
86 | | - String paramValue = _filterConfig.getInitParameter( "minContentLength" ); |
87 | | - |
88 | | - if ( paramValue != null ) |
89 | | - { |
90 | | - _nMinContentLength = Integer.parseInt( paramValue ); |
91 | | - } |
92 | | - |
93 | | - paramValue = _filterConfig.getInitParameter( "minInterval" ); |
| 93 | + _nMinContentLength = AppPropertiesService.getPropertyInt( PROPERTY_DOSGUARDFILTER_MINCONTENTLENGTH, CONSTANT_DEFAULT_DOSGUARDFILTER_MINCONTENTLENGTH ) ; |
| 94 | + _nMinInterval = AppPropertiesService.getPropertyInt( PROPERTY_DOSGUARDFILTER_MININTERVAL, CONSTANT_DEFAULT_DOSGUARDFILTER_MININTERVAL ) ; |
94 | 95 |
|
95 | | - if ( paramValue != null ) |
96 | | - { |
97 | | - _nMinInterval = Integer.parseInt( paramValue ); |
98 | | - } |
99 | | - } |
100 | | - catch( NumberFormatException ex ) |
101 | | - { |
102 | | - ServletException servletEx = new ServletException( ex.getMessage( ) ); |
103 | | - servletEx.initCause( ex ); |
104 | | - throw servletEx; |
105 | | - } |
106 | 96 | } |
107 | 97 |
|
108 | 98 | /** |
|
0 commit comments