|
9 | 9 | */ |
10 | 10 | package org.openmrs.module.web.filter; |
11 | 11 |
|
12 | | -import java.io.IOException; |
| 12 | +import org.openmrs.api.context.Context; |
| 13 | +import org.openmrs.util.ConfigUtil; |
| 14 | +import org.openmrs.web.user.UserProperties; |
13 | 15 |
|
14 | 16 | import javax.servlet.Filter; |
15 | 17 | import javax.servlet.FilterChain; |
|
18 | 20 | import javax.servlet.ServletRequest; |
19 | 21 | import javax.servlet.ServletResponse; |
20 | 22 | import javax.servlet.http.HttpServletRequest; |
21 | | -import javax.servlet.http.HttpServletResponse; |
22 | | - |
23 | | -import org.openmrs.api.context.Context; |
24 | | -import org.openmrs.web.user.UserProperties; |
| 23 | +import java.io.IOException; |
25 | 24 |
|
26 | 25 | /** |
27 | 26 | * This filter checks if an authenticated user has been flagged by the admin to change his password |
|
30 | 29 | */ |
31 | 30 | public class ForcePasswordChangeFilter implements Filter { |
32 | 31 |
|
33 | | - private static boolean enabled = true; |
| 32 | + private boolean enabled = true; |
34 | 33 |
|
35 | 34 | private String excludeURL; |
36 | 35 |
|
@@ -90,16 +89,14 @@ private boolean shouldNotAllowAccessToUrl(String requestURI) { |
90 | 89 | */ |
91 | 90 | public void init(FilterConfig config) throws ServletException { |
92 | 91 | this.config = config; |
93 | | - excludeURL = config.getInitParameter("excludeURL"); |
| 92 | + enabled = !"false".equalsIgnoreCase(getParameter("enabled")); |
| 93 | + excludeURL = getParameter("excludeURL"); |
94 | 94 | excludedURLs = excludeURL.split(","); |
95 | | - changePasswordForm = config.getInitParameter("changePasswordForm"); |
96 | | - } |
97 | | - |
98 | | - public static boolean isEnabled() { |
99 | | - return enabled; |
| 95 | + changePasswordForm = getParameter("changePasswordForm"); |
100 | 96 | } |
101 | 97 |
|
102 | | - public static void setEnabled(boolean enabled) { |
103 | | - ForcePasswordChangeFilter.enabled = enabled; |
| 98 | + private String getParameter(String name) { |
| 99 | + String propertyName = "legacyui.passwordChangeFilter." + name; |
| 100 | + return ConfigUtil.getProperty(propertyName, name); |
104 | 101 | } |
105 | 102 | } |
0 commit comments