From 97f3607b1ceb45d65fc701042fadfffff74e87d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cocula?= Date: Sat, 24 Dec 2016 23:39:14 +0100 Subject: [PATCH] Register REST Filter --- .../libresonic/player/boot/Application.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libresonic-main/src/main/java/org/libresonic/player/boot/Application.java b/libresonic-main/src/main/java/org/libresonic/player/boot/Application.java index 28b75c8e..e9caf628 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/boot/Application.java +++ b/libresonic-main/src/main/java/org/libresonic/player/boot/Application.java @@ -1,9 +1,12 @@ package org.libresonic.player.boot; import org.directwebremoting.servlet.DwrServlet; +import org.libresonic.player.filter.RESTFilter; +import org.libresonic.player.security.RESTRequestParameterProcessingFilter; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; @@ -19,6 +22,11 @@ import org.springframework.context.annotation.ImportResource; "classpath:/libresonic-servlet.xml"}) public class Application extends SpringBootServletInitializer { + /** + * Registers the DWR servlet. + * + * @return a registration bean. + */ @Bean public ServletRegistrationBean dwrServletRegistrationBean() { ServletRegistrationBean servlet = new ServletRegistrationBean(new DwrServlet(), "/dwr/*"); @@ -26,6 +34,21 @@ public class Application extends SpringBootServletInitializer { return servlet; } + /** + * Registers the rest servlet filter. + * + * @return a registration bean. + */ + @Bean + public FilterRegistrationBean restFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new RESTFilter()); + registration.addUrlPatterns("/rest/*"); + registration.setName("RESTFilter"); + return registration; + } + + @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {