Jersey 2: Define priorities for request filters.
It is a good practice to define priorities for request filters; Otherwise,
the execution order of filters with the same priority is implementation-defined.
References:
https://eclipse-ee4j.github.io/jersey.github.io/documentation/2.37/filters-and-interceptors.html#d0e10195
https://jakartaee.github.io/rest/apidocs/2.1.6/javax/ws/rs/Priorities.html
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java
index 44d3114..9434016 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java
@@ -2,6 +2,7 @@
import java.util.List;
+import javax.annotation.Priority;
import javax.ws.rs.core.PathSegment;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,7 @@
*
*/
@Component
+@Priority(Integer.MIN_VALUE)
public class APIVersionFilter
implements ContainerRequestFilter {
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 9149362..ccaf31b 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
@@ -1,6 +1,8 @@
package de.ids_mannheim.korap.web.filter;
+import javax.annotation.Priority;
import javax.servlet.ServletContext;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
@@ -20,6 +22,7 @@
* @see {@link AuthenticationFilter}
*/
@Component
+@Priority(Priorities.AUTHENTICATION)
public class AdminFilter extends AuthenticationFilter {
private @Context ServletContext servletContext;
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
index 26ec359..0635c78 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
@@ -4,6 +4,8 @@
import org.springframework.stereotype.Component;
import org.glassfish.jersey.server.ContainerRequest;
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
@@ -28,6 +30,7 @@
* @last update 12/2017
*/
@Component
+@Priority(Priorities.AUTHENTICATION)
public class AuthenticationFilter
implements ContainerRequestFilter {
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/BlockingFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/BlockingFilter.java
index 5db14e8..7c1a625 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/BlockingFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/BlockingFilter.java
@@ -3,6 +3,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
@@ -19,6 +21,7 @@
* anonymous access should be allowed!
*/
@Component
+@Priority(Priorities.AUTHORIZATION)
public class BlockingFilter implements ContainerRequestFilter {
@Autowired
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoFilter.java
index b63c799..d28bd39 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoFilter.java
@@ -1,5 +1,7 @@
package de.ids_mannheim.korap.web.filter;
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.SecurityContext;
@@ -16,6 +18,7 @@
* @author hanl
* @date 08/02/2016
*/
+@Priority(Priorities.AUTHENTICATION)
public class DemoFilter implements ContainerRequestFilter {
@Override
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoUserFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoUserFilter.java
index deb93cb..8a88a2d 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoUserFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/DemoUserFilter.java
@@ -2,6 +2,8 @@
import java.security.Principal;
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Context;
@@ -23,6 +25,7 @@
* Created by hanl on 7/15/14.
*/
@Component
+@Priority(Priorities.AUTHENTICATION)
public class DemoUserFilter implements ContainerRequestFilter {
@Context
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/NonDemoBlockingFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/NonDemoBlockingFilter.java
index a396b87..feadf45 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/NonDemoBlockingFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/NonDemoBlockingFilter.java
@@ -3,6 +3,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
@@ -21,6 +23,7 @@
* anonymous access should be allowed!
*/
@Component
+@Priority(Priorities.AUTHORIZATION)
public class NonDemoBlockingFilter
implements ContainerRequestFilter {
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
index adfdb3c..93d97ff 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
@@ -15,6 +15,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
@@ -39,6 +41,7 @@
* @date 13/05/2014
*/
@Component
+@Priority(Priorities.AUTHORIZATION)
public class PiwikFilter implements ContainerRequestFilter {
private WebTarget service;