| | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import javax.servlet.DispatcherType; |
| | | import jakarta.servlet.DispatcherType; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Configuration |
| | | @ConditionalOnProperty(value = "xss.enabled", havingValue = "true") |
| | | public class FilterConfig { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @SuppressWarnings({"rawtypes", "unchecked"}) |
| | | @Bean |
| | | @ConditionalOnProperty(value = "xss.enabled", havingValue = "true") |
| | | public FilterRegistrationBean xssFilterRegistration() { |
| | | FilterRegistrationBean registration = new FilterRegistrationBean(); |
| | | registration.setDispatcherTypes(DispatcherType.REQUEST); |
| | | registration.setFilter(new XssFilter()); |
| | | registration.addUrlPatterns(StringUtils.splitToArray(xssProperties.getUrlPatterns(), ",")); |
| | | registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), ",")); |
| | | registration.setName("xssFilter"); |
| | | registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE); |
| | | Map<String, String> initParameters = new HashMap<String, String>(); |