summaryrefslogtreecommitdiffstats
path: root/infra
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-10-12 13:06:42 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-10-13 07:16:38 +0000
commitaac97df16e967ca97d5825218766787bdf1b627d (patch)
tree405bb0d270d66cd87ccfbf7cbb30a7aa08ff50da /infra
parent51d14eec11a226a11beb607421ef7ff656a7be0c (diff)
HONEYCOMB-168 Replace deprecated GZip filter with handler
Change-Id: Idb82d23d3e79289f356a875c3729c80bb53f2567 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra')
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java2
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java2
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java26
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java1
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java4
-rw-r--r--infra/minimal-distribution/src/test/resources/WEB-INF/web.xml15
6 files changed, 21 insertions, 29 deletions
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java
index e3c9577e7..f298df1d5 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpConnectorProvider.java
@@ -22,7 +22,7 @@ import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
-public final class HttpConnectorProvider extends ProviderTrait<ServerConnector> {
+final class HttpConnectorProvider extends ProviderTrait<ServerConnector> {
@Inject
private HoneycombConfiguration cfg;
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java
index 8dca157a6..68c0fb5ac 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java
@@ -27,7 +27,7 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.util.ssl.SslContextFactory;
-public final class HttpsConnectorProvider extends ProviderTrait<ServerConnector> {
+final class HttpsConnectorProvider extends ProviderTrait<ServerConnector> {
@Inject
private HoneycombConfiguration cfg;
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java
index 6d055bf81..bc5fe8bc3 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java
@@ -26,14 +26,21 @@ import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
-public final class JettyServerProvider extends ProviderTrait<Server> {
+final class JettyServerProvider extends ProviderTrait<Server> {
- public static final String REALM = "HCRealm";
+ private static final String REALM = "HCRealm";
+ // Mime types to be compressed when requested
+ private static final String[] GZIP_MIME_TYPES = {"application/xml",
+ "xml",
+ "application/yang.data+xml",
+ "application/json",
+ "application/yang.data+json"};
@Inject
private HoneycombConfiguration cfg;
@@ -42,7 +49,6 @@ public final class JettyServerProvider extends ProviderTrait<Server> {
protected Server create() {
Server server = new Server(new QueuedThreadPool(cfg.restPoolMaxSize.get(), cfg.restPoolMinSize.get()));
-
// Load Realm for basic auth
HashLoginService service = new HashLoginService(REALM);
// Reusing the name as role
@@ -52,15 +58,18 @@ public final class JettyServerProvider extends ProviderTrait<Server> {
final URL resource = getClass().getResource("/");
WebAppContext webapp = new WebAppContext(resource.getPath(), cfg.restconfRootPath.get());
- ConstraintSecurityHandler security = getBaseAuth(service, webapp);
- server.setHandler(security);
-
+ server.setHandler(getGzip(service, webapp));
return server;
}
- private ConstraintSecurityHandler getBaseAuth(HashLoginService service, WebAppContext webapp) {
- ConstraintSecurityHandler security = new ConstraintSecurityHandler();
+ private GzipHandler getGzip(final HashLoginService service, final WebAppContext webapp) {
+ final GzipHandler gzipHandler = new GzipHandler();
+ gzipHandler.setIncludedMimeTypes(GZIP_MIME_TYPES);
+ gzipHandler.setHandler(getBaseAuth(service, webapp));
+ return gzipHandler;
+ }
+ private ConstraintSecurityHandler getBaseAuth(HashLoginService service, WebAppContext webapp) {
Constraint constraint = new Constraint();
constraint.setName("auth");
constraint.setAuthenticate(true);
@@ -70,6 +79,7 @@ public final class JettyServerProvider extends ProviderTrait<Server> {
mapping.setPathSpec("/*");
mapping.setConstraint(constraint);
+ ConstraintSecurityHandler security = new ConstraintSecurityHandler();
security.setConstraintMappings(Collections.singletonList(mapping));
security.setAuthenticator(new BasicAuthenticator());
security.setLoginService(service);
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java
index 846ed1b03..7799d7fde 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.java
@@ -23,7 +23,6 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.opendaylight.netconf.sal.rest.api.RestConnector;
-
public class RestconfModule extends AbstractModule {
public static final String RESTCONF_HTTP = "restconf-http";
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java
index 16a33ecbb..94d508c99 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.java
@@ -24,9 +24,7 @@ import org.opendaylight.netconf.sal.rest.api.RestConnector;
import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-
-
-public class RestconfProvider extends ProviderTrait<RestConnector> {
+final class RestconfProvider extends ProviderTrait<RestConnector> {
@Inject
private HoneycombConfiguration cfg;
diff --git a/infra/minimal-distribution/src/test/resources/WEB-INF/web.xml b/infra/minimal-distribution/src/test/resources/WEB-INF/web.xml
index 45fcce741..6cf487170 100644
--- a/infra/minimal-distribution/src/test/resources/WEB-INF/web.xml
+++ b/infra/minimal-distribution/src/test/resources/WEB-INF/web.xml
@@ -33,21 +33,6 @@
<servlet-name>JAXRSRestconf</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
-
- <filter>
- <filter-name>GzipFilter</filter-name>
- <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
- <init-param>
- <param-name>mimeTypes</param-name>
- <param-value>application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json</param-value>
- </init-param>
- </filter>
- <!-- TODO HONEYCOMB-168 gzip filter is deprecated -->
- <filter-mapping>
- <filter-name>GzipFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
<filter>
<filter-name>cross-origin-restconf</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>