summaryrefslogtreecommitdiffstats
path: root/infra/minimal-distribution/src/main/java/io
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/minimal-distribution/src/main/java/io
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/minimal-distribution/src/main/java/io')
-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
5 files changed, 21 insertions, 14 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;