diff --git a/parent/pom.xml b/parent/pom.xml
index 667255cb79b..366a4fff6b7 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -148,7 +148,7 @@
1.0
1.4.1
[9.2,10)
- 9.4.34.v20201102
+ 9.4.35.v20201120
${cxf.jetty9.version}
3.1
2.9.4
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
index 37f4cf77848..4f843e4a133 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginModule.java
@@ -78,7 +78,8 @@ public void initialize(Subject subject, CallbackHandler handler,
Map customOptions = new HashMap<>();
customOptions.put("file", fileResource);
- module.initialize(subject, handler, sharedState, customOptions);
+ // See please https://github.com/eclipse/jetty.project/issues/5486
+ BookLoginService.withInstance(() -> module.initialize(subject, handler, sharedState, customOptions));
}
public boolean login() throws LoginException {
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginService.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginService.java
new file mode 100644
index 00000000000..cfbcce4565c
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/BookLoginService.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.security;
+
+import java.lang.reflect.Field;
+
+import org.eclipse.jetty.jaas.JAASLoginService;
+
+/**
+ * Since BookLoginModule delegates to PropertyFileLoginModule, the access to JAASLoginService.INSTANCE
+ * is required 9.4.35.v20201120+ (see please https://github.com/eclipse/jetty.project/issues/5486).
+ */
+public class BookLoginService extends JAASLoginService {
+ private static JAASLoginService globalInstance;
+ private static Field instanceField;
+
+ public BookLoginService() {
+ globalInstance = this;
+
+ try {
+ instanceField = JAASLoginService.class.getField("INSTANCE");
+ } catch (final Exception ex) {
+ /* do nothing, older Jetty version where field is not available */
+ }
+ }
+
+ public static void withInstance(Runnable r) {
+ final ThreadLocal instance = getCurrentInstance();
+ boolean managed = false;
+
+ try {
+ if (instance.get() == null) {
+ instance.set(globalInstance);
+ managed = true;
+ }
+
+ r.run();
+ } finally {
+ if (managed) {
+ instance.remove();
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static ThreadLocal getCurrentInstance() {
+ if (instanceField == null) {
+ return new ThreadLocal();
+ } else {
+ try {
+ return (ThreadLocal)instanceField.get(null);
+ } catch (final Exception ex) {
+ return new ThreadLocal();
+ }
+ }
+ }
+}
diff --git a/systests/jaxrs/src/test/resources/jaxrs_jaas_security/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_jaas_security/WEB-INF/beans.xml
index 4846e8902da..73981ec27d1 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_jaas_security/WEB-INF/beans.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_jaas_security/WEB-INF/beans.xml
@@ -94,5 +94,10 @@
+
+
+
+
+
\ No newline at end of file