Jersey 2: Replace ContainerRequest.getFormParameters()

There is no direct replacement for ContainerRequest.getFormParameters().
The simple solution is to reimplement it with the same behaviour of
Jersey 1.x.

See also:
https://github.com/javaee/jersey-1.x/blob/1.19.3/jersey-server/src/main/java/com/sun/jersey/spi/container/ContainerRequest.java#L591-L615
https://github.com/eclipse-ee4j/jersey/blob/2.37/core-server/src/main/java/org/glassfish/jersey/server/internal/inject/FormParamValueParamProvider.java#L184-L202
diff --git a/core/src/main/java/de/ids_mannheim/korap/utils/JerseyUtils.java b/core/src/main/java/de/ids_mannheim/korap/utils/JerseyUtils.java
new file mode 100644
index 0000000..0a8623f
--- /dev/null
+++ b/core/src/main/java/de/ids_mannheim/korap/utils/JerseyUtils.java
@@ -0,0 +1,38 @@
+package de.ids_mannheim.korap.utils;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.MediaType;
+
+import org.glassfish.jersey.message.internal.MediaTypes;
+import org.glassfish.jersey.server.ContainerRequest;
+
+public class JerseyUtils {
+
+    /**
+     * Get the form parameters of the request entity.
+     * <p>
+     * This method will ensure that the request entity is buffered
+     * such that it may be consumed by the application.
+     *
+     * @return the form parameters, if there is a request entity and the
+     * content type is "application/x-www-form-urlencoded", otherwise an
+     * instance containing no parameters will be returned.
+     */
+    public static Form getFormParameters (ContainerRequestContext requestContext) {
+        if (requestContext instanceof ContainerRequest) {
+            return getFormParameters((ContainerRequest) requestContext);
+        }
+        return new Form();
+    }
+
+    private static Form getFormParameters (ContainerRequest request) {
+        if (MediaTypes.typeEqual(MediaType.APPLICATION_FORM_URLENCODED_TYPE, request.getMediaType())) {
+            request.bufferEntity();
+            Form form = request.readEntity(Form.class);
+            return (form == null ? new Form() : form);
+        } else {
+            return new Form();
+        }
+    }
+}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java
index ccaf31b..1201529 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java
@@ -14,6 +14,7 @@
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
 import de.ids_mannheim.korap.security.context.TokenContext;
+import de.ids_mannheim.korap.utils.JerseyUtils;
 import de.ids_mannheim.korap.web.KustvaktResponseHandler;
 
 /**
@@ -37,7 +38,7 @@
         String username = "guest";
         
         // legacy support for kustvakt core
-        String adminToken = superRequest.getFormParameters().getFirst("token");
+        String adminToken = JerseyUtils.getFormParameters(context).asMap().getFirst("token");
         if (adminToken != null && !adminToken.isEmpty()) {
             // startswith token=
             // adminToken = adminToken.substring(6);