diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bd8f673fe41..8e1efcbd073 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -42,10 +42,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- - name: Set up JDK 17
+ - name: Set up JDK 21
uses: actions/setup-java@v5
with:
- java-version: '17'
+ java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Build
@@ -74,10 +74,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- - name: Set up JDK 17
+ - name: Set up JDK 21
uses: actions/setup-java@v5
with:
- java-version: '17'
+ java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Restore Maven Local Repository
diff --git a/archetypes/assembly/src/main/resources/archetype-resources/pom.xml b/archetypes/assembly/src/main/resources/archetype-resources/pom.xml
index 4bd78a8db18..d8f83f8bffb 100644
--- a/archetypes/assembly/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/assembly/src/main/resources/archetype-resources/pom.xml
@@ -174,7 +174,7 @@
- 17
+ 21
diff --git a/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml b/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml
index d442fecc346..cd322ff1458 100644
--- a/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml
@@ -63,8 +63,9 @@
maven-compiler-plugin
3.15.0
- 1.8
- 1.8
+ 21
+ 21
+ 21
256M
diff --git a/archetypes/bundle/pom.xml b/archetypes/bundle/pom.xml
index 3bbc2cecbac..0cb6128f97a 100644
--- a/archetypes/bundle/pom.xml
+++ b/archetypes/bundle/pom.xml
@@ -57,8 +57,9 @@
org.apache.maven.plugins
maven-compiler-plugin
- 1.8
- 1.8
+ 21
+ 21
+ 21
256M
diff --git a/archetypes/bundle/src/main/resources/archetype-resources/pom.xml b/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
index 798beaeab16..83654cd8942 100644
--- a/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
@@ -82,8 +82,9 @@
maven-compiler-plugin
3.15.0
- 1.8
- 1.8
+ 21
+ 21
+ 21
256M
diff --git a/archetypes/command/src/main/resources/archetype-resources/pom.xml b/archetypes/command/src/main/resources/archetype-resources/pom.xml
index 73ab71c704b..6a579d1cc27 100644
--- a/archetypes/command/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/command/src/main/resources/archetype-resources/pom.xml
@@ -67,8 +67,9 @@
true
3.15.0
- 1.8
- 1.8
+ 21
+ 21
+ 21
diff --git a/assemblies/apache-karaf-integration/pom.xml b/assemblies/apache-karaf-integration/pom.xml
index 0c2f744b5ce..2972fd11d6b 100644
--- a/assemblies/apache-karaf-integration/pom.xml
+++ b/assemblies/apache-karaf-integration/pom.xml
@@ -187,7 +187,7 @@
- 17
+ 21
${project.build.directory}
Apache Karaf Integration
diff --git a/assemblies/apache-karaf-minimal/pom.xml b/assemblies/apache-karaf-minimal/pom.xml
index 072afd67715..481bbedd666 100644
--- a/assemblies/apache-karaf-minimal/pom.xml
+++ b/assemblies/apache-karaf-minimal/pom.xml
@@ -145,7 +145,7 @@
!org.apache.karaf.command.acl.*,
*
- 17
+ 21
diff --git a/assemblies/apache-karaf/pom.xml b/assemblies/apache-karaf/pom.xml
index 9c05670f68f..60dd7a90911 100644
--- a/assemblies/apache-karaf/pom.xml
+++ b/assemblies/apache-karaf/pom.xml
@@ -178,7 +178,7 @@
- 17
+ 21
${project.build.directory}
Apache Karaf (full)
diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/inc b/assemblies/features/base/src/main/filtered-resources/resources/bin/inc
index 2809e8be7cf..004142ab4ba 100644
--- a/assemblies/features/base/src/main/filtered-resources/resources/bin/inc
+++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/inc
@@ -282,12 +282,6 @@ setupVendorSepcifics() {
setupDefaults() {
DEFAULT_JAVA_OPTS="-XX:+UnlockDiagnosticVMOptions "
- if [ "${VERSION}" -gt "11" ]; then
- # TODO revisit EventAdminImpl to avoid use of Subject.getSubject(AccessController.getContext());
- # -Djava.security.manager=allow is a workaround for SecurityController deprecation in JDK23+
- DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS -Djava.security.manager=allow "
- fi
-
setupVendorSepcifics
DEFAULT_JAVA_OPTS="${DEFAULT_JAVA_OPTS} ${JAVA_VENDOR_OPTS}"
diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat
index 0be0d7df37e..8f6a88694f1 100644
--- a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat
+++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat
@@ -267,10 +267,6 @@ if not exist "%JAVA_HOME%\bin\server\jvm.dll" (
)
set DEFAULT_JAVA_OPTS=-XX:+UnlockDiagnosticVMOptions
-if "%JAVA_VERSION%" GTR 11 (
- set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -Djava.security.manager=allow
-)
-
if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
diff --git a/assemblies/features/enterprise/pom.xml b/assemblies/features/enterprise/pom.xml
index 5ff00a0b820..281a0c4d0ee 100644
--- a/assemblies/features/enterprise/pom.xml
+++ b/assemblies/features/enterprise/pom.xml
@@ -214,7 +214,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ 21
framework
diff --git a/assemblies/features/integration/pom.xml b/assemblies/features/integration/pom.xml
index 54faea9360a..a4ec1f608c5 100644
--- a/assemblies/features/integration/pom.xml
+++ b/assemblies/features/integration/pom.xml
@@ -105,7 +105,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ 21
framework
diff --git a/assemblies/features/specs/pom.xml b/assemblies/features/specs/pom.xml
index 5944e6081b3..36ba1df5130 100644
--- a/assemblies/features/specs/pom.xml
+++ b/assemblies/features/specs/pom.xml
@@ -96,7 +96,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ 21
framework
@@ -149,4 +149,4 @@
-
\ No newline at end of file
+
diff --git a/assemblies/features/spring/pom.xml b/assemblies/features/spring/pom.xml
index b5abe0e26ad..c04a2ca250c 100644
--- a/assemblies/features/spring/pom.xml
+++ b/assemblies/features/spring/pom.xml
@@ -158,7 +158,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ 21
framework
diff --git a/assemblies/features/standard/pom.xml b/assemblies/features/standard/pom.xml
index 540a5919c4d..c04f77a77b3 100644
--- a/assemblies/features/standard/pom.xml
+++ b/assemblies/features/standard/pom.xml
@@ -476,7 +476,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ 21
framework
diff --git a/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml b/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml
index 0d444b96cfc..729a495cc3e 100644
--- a/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml
+++ b/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml
@@ -138,7 +138,7 @@
- 17
+ 21
@@ -194,4 +194,4 @@
-
\ No newline at end of file
+
diff --git a/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml b/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml
index 6113f130090..dbc715cc36d 100644
--- a/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml
+++ b/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml
@@ -108,7 +108,7 @@
static
true
static
- 17
+ 21
diff --git a/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml b/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml
index c684882f738..61817c99136 100644
--- a/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml
+++ b/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml
@@ -70,8 +70,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 11
- 11
+ 21
+ 21
diff --git a/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java b/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
index 7671f4c8b90..ffda6a24541 100644
--- a/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
+++ b/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
@@ -533,9 +533,6 @@ private void doStart(InstanceState instance, String name, String javaOpts) throw
" --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED" +
" --add-exports=java.security.sasl/com.sun.security.sasl=ALL-UNNAMED" +
" --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED";
- if (!System.getProperty("java.version").startsWith("11")) {
- jdkOpts += " -Djava.security.manager=allow";
- }
} else {
jdkOpts = " -Djava.endorsed.dirs=\"" + new File(new File(new File(System.getProperty("java.home"), "jre"), "lib"), "endorsed") + System.getProperty("path.separator") + new File(new File(System.getProperty("java.home"), "lib"), "endorsed") + "\""
+ " -Djava.ext.dirs=\"" + new File(new File(new File(System.getProperty("java.home"), "jre"), "lib"), "ext") + System.getProperty("path.separator") + new File(new File(System.getProperty("java.home"), "lib"), "ext") + System.getProperty("path.separator") + new File(libDir, "ext").getCanonicalPath() + "\"";
diff --git a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
index 3a9876d12b0..c0203a4b993 100644
--- a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
+++ b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
@@ -25,7 +25,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.Principal;
-import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -421,7 +420,7 @@ private String executeCommand(final String command, final Long timeout, final Lo
commandFuture = new FutureTask<>(() -> {
Subject subject = new Subject();
subject.getPrincipals().addAll(Arrays.asList(principals));
- return Subject.doAs(subject, (PrivilegedExceptionAction) commandCallable::call);
+ return Subject.callAs(subject, (Callable) commandCallable::call);
});
}
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java b/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java
index 009a9e436d3..d2cfa7a59e1 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java
@@ -34,7 +34,6 @@
import java.nio.file.StandardCopyOption;
import java.util.*;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
@@ -63,7 +62,8 @@ public Option[] config() {
// Add some extra options used by this test...
options.addAll(Arrays.asList(
editConfigurationFilePut("etc/system.properties", "java.security.policy", "${karaf.etc}/all.policy"),
- editConfigurationFilePut("etc/system.properties", "org.osgi.framework.security", "osgi"),
+ // This is no longer allowed as felix framework 7.0.5 calls System.getSecurityManager() in case it is there, see Felix.java
+ // editConfigurationFilePut("etc/system.properties", "org.osgi.framework.security", "osgi"),
editConfigurationFilePut("etc/system.properties", "org.osgi.framework.trust.repositories", "${karaf.etc}/trustStore.ks"),
editConfigurationFilePut("etc/startup.properties", "mvn:org.apache.felix/org.apache.felix.framework.security/" + version, "1"),
replaceConfigurationFile("system/org/apache/felix/org.apache.felix.framework.security/" + version + "/org.apache.felix.framework.security-" + version + ".jar", temp.toFile())));
@@ -72,8 +72,6 @@ public Option[] config() {
@Test
public void testJavaSecurity() throws Exception {
- assertNotNull("Karaf should run under a security manager", System.getSecurityManager());
-
BundleService service = getOsgiService(BundleService.class);
long tried = 0;
while (true) {
diff --git a/jaas/command/src/main/java/org/apache/karaf/jaas/command/WhoamiCommand.java b/jaas/command/src/main/java/org/apache/karaf/jaas/command/WhoamiCommand.java
index 3ce1e5dc6df..c587f166ed5 100644
--- a/jaas/command/src/main/java/org/apache/karaf/jaas/command/WhoamiCommand.java
+++ b/jaas/command/src/main/java/org/apache/karaf/jaas/command/WhoamiCommand.java
@@ -55,8 +55,7 @@ public Object execute() throws Exception {
ShellTable table = new ShellTable();
// Get the currently-active JAAS Subject.
- AccessControlContext acc = AccessController.getContext();
- Subject subj = Subject.getSubject(acc);
+ Subject subj = Subject.current();
String classString = USER_CLASS;
if (groups) {
diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModule.java
index 2c911765529..dd365e0fa05 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModule.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModule.java
@@ -34,6 +34,8 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionException;
/**
* Specific LDAPLoginModule to be used with GSSAPI. Uses the specified realm as login context.
@@ -62,9 +64,9 @@ public boolean login() throws LoginException {
context.login();
try {
- succeeded = Subject.doAs(context.getSubject(), (PrivilegedExceptionAction) this::doLogin);
+ succeeded = Subject.callAs(context.getSubject(), (Callable) this::doLogin);
return succeeded;
- } catch (PrivilegedActionException pExcp) {
+ } catch (CompletionException pExcp) {
logger.error("error with delegated authentication", pExcp);
throw new LoginException(pExcp.getMessage());
}
diff --git a/main/src/test/java/org/apache/karaf/main/MainLockingTest.java b/main/src/test/java/org/apache/karaf/main/MainLockingTest.java
index ac01543343c..d1beb601343 100644
--- a/main/src/test/java/org/apache/karaf/main/MainLockingTest.java
+++ b/main/src/test/java/org/apache/karaf/main/MainLockingTest.java
@@ -38,6 +38,16 @@ public class MainLockingTest {
private File data;
private File log;
+ private Bundle installTimeoutShutdownBundle(Framework framework) throws Exception {
+ return framework.getBundleContext().installBundle("foo",
+ TinyBundles.bundle()
+ .addClass(TimeoutShutdownActivator.class)
+ .setHeader(Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName())
+ .setHeader(Constants.IMPORT_PACKAGE, "org.osgi.framework")
+ .build(TinyBundles.bndBuilder())
+ );
+ }
+
@Before
public void setUp() throws IOException {
File basedir = new File(getClass().getClassLoader().getResource("foo").getPath()).getParentFile();
@@ -82,12 +92,7 @@ public void testLostMasterLock() throws Exception {
Main main = new Main(args);
main.launch();
Framework framework = main.getFramework();
- Bundle bundle = framework.getBundleContext().installBundle("foo",
- TinyBundles.bundle()
- .addClass(TimeoutShutdownActivator.class)
- .setHeader(Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName())
- .build(TinyBundles.bndBuilder())
- );
+ Bundle bundle = installTimeoutShutdownBundle(framework);
bundle.start();
@@ -127,12 +132,7 @@ public void testRetainsMasterLockOverFluctuation() throws Exception {
Main main = new Main(args);
main.launch();
Framework framework = main.getFramework();
- Bundle bundle = framework.getBundleContext().installBundle("foo",
- TinyBundles.bundle()
- .setHeader(Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName())
- .addClass(TimeoutShutdownActivator.class)
- .build(TinyBundles.bndBuilder())
- );
+ Bundle bundle = installTimeoutShutdownBundle(framework);
bundle.start();
@@ -172,11 +172,7 @@ public void testLostMasterLockAfterThreshold() throws Exception {
Main main = new Main(args);
main.launch();
Framework framework = main.getFramework();
- Bundle bundle = framework.getBundleContext().installBundle("foo",
- TinyBundles.bundle()
- .setHeader(Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName())
- .addClass(TimeoutShutdownActivator.class)
- .build(TinyBundles.bndBuilder()));
+ Bundle bundle = installTimeoutShutdownBundle(framework);
bundle.start();
diff --git a/management/server/src/main/java/org/apache/karaf/management/internal/BulkRequestContext.java b/management/server/src/main/java/org/apache/karaf/management/internal/BulkRequestContext.java
index 7d1e0641e80..ce6f8f796cb 100644
--- a/management/server/src/main/java/org/apache/karaf/management/internal/BulkRequestContext.java
+++ b/management/server/src/main/java/org/apache/karaf/management/internal/BulkRequestContext.java
@@ -63,16 +63,11 @@ public static BulkRequestContext newContext(ConfigurationAdmin configAdmin) thro
context.configAdmin = configAdmin;
try {
// check JAAS subject here
- AccessControlContext acc = AccessController.getContext();
- if (acc == null) {
+ Subject subject = Subject.current();
+ if (subject == null) {
context.anonymous = true;
} else {
- Subject subject = Subject.getSubject(acc);
- if (subject == null) {
- context.anonymous = true;
- } else {
- context.principals.addAll(subject.getPrincipals());
- }
+ context.principals.addAll(subject.getPrincipals());
}
// list available ACL configs - valid for this instance only
for (Configuration config : configAdmin.listConfigurations("(service.pid=jmx.acl*)")) {
diff --git a/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java b/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
index 53d2e37f2a4..3c7a99916e7 100644
--- a/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
+++ b/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
@@ -33,8 +33,8 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.security.Principal;
-import java.security.PrivilegedAction;
import java.util.*;
+import java.util.concurrent.Callable;
public class KarafMBeanServerGuardTest extends TestCase {
@@ -462,7 +462,7 @@ private ConfigurationAdmin getMockConfigAdmin2(Dictionary... con
public void testCurrentUserHasRole() throws Exception {
Subject subject = loginWithTestRoles("test");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
assertTrue(JaasHelper.currentUserHasRole("test"));
assertFalse(JaasHelper.currentUserHasRole("toast"));
return null;
@@ -476,7 +476,7 @@ public void testCurrentUserHasCustomRole() throws Exception {
lm.login();
lm.commit();
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
assertTrue(JaasHelper.currentUserHasRole(TestRolePrincipal.class.getCanonicalName() + ":foo"));
assertFalse(JaasHelper.currentUserHasRole("foo"));
return null;
@@ -493,7 +493,7 @@ public void testInvoke() throws Throwable {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("editor", "admin");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
Method im = MBeanServer.class.getMethod("invoke", ObjectName.class, String.class, Object[].class, String[].class);
@@ -547,7 +547,7 @@ public void testGetAttributeIs() throws Throwable {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("editor", "admin");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
Method im = MBeanServer.class.getMethod("getAttribute", ObjectName.class, String.class);
@@ -593,7 +593,7 @@ public void testGetAttributes() throws Throwable {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("editor", "admin");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
Method im = MBeanServer.class.getMethod("getAttributes", ObjectName.class, String[].class);
@@ -641,7 +641,7 @@ public void testGetAttributes2() throws Throwable {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("editor", "admin");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
Method im = MBeanServer.class.getMethod("getAttributes", ObjectName.class, String[].class);
@@ -688,7 +688,7 @@ public void testSetAttribute() throws Throwable {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("editor", "admin");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
Method im = MBeanServer.class.getMethod("setAttribute", ObjectName.class, Attribute.class);
@@ -742,7 +742,7 @@ public void testSetAttributes() throws Throwable {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("editor", "admin");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
Method im = MBeanServer.class.getMethod("setAttributes", ObjectName.class, AttributeList.class);
@@ -810,7 +810,7 @@ public void testCanInvokeMBean() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on));
assertFalse(guard.canInvoke(mbs, on2));
@@ -851,7 +851,7 @@ public void testCanInvokeMBean2() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on));
@@ -889,7 +889,7 @@ public void testCanInvokeAnyOverload() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on, "doit"));
@@ -928,7 +928,7 @@ public void testCanInvokeAnyOverload2() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on, "doit"));
@@ -960,7 +960,7 @@ public void testCanInvokeAnyOverload3() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on, "doit"));
@@ -994,7 +994,7 @@ public void testCanGetAttributeAnyOverload() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on, "getFoo"));
@@ -1028,7 +1028,7 @@ public void testCanGetAttributeAnyOverload2() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on, "getFoo"));
@@ -1063,7 +1063,7 @@ public void testCanGetAttributeAnyOverload3() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on, "isFoo"));
@@ -1098,7 +1098,7 @@ public void testCanGetAttributeAnyOverload4() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on, "isFoo"));
@@ -1132,7 +1132,7 @@ public void testCanSetAttributeAnyOverload() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on, "setFoo"));
@@ -1166,7 +1166,7 @@ public void testCanSetAttributeAnyOverload2() throws Exception {
guard.setConfigAdmin(ca);
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on, "setFoo"));
@@ -1202,7 +1202,7 @@ public void testCanInvokeMBeanGetter() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on));
@@ -1238,7 +1238,7 @@ public void testCanInvokeMBeanGetter2() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on));
@@ -1274,7 +1274,7 @@ public void testCanInvokeMBeanGetter3() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on));
@@ -1310,7 +1310,7 @@ public void testCanInvokeMBeanSetter() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(mbs, on));
@@ -1346,7 +1346,7 @@ public void testCanInvokeMBeanSetter2() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertFalse(guard.canInvoke(mbs, on));
@@ -1374,7 +1374,7 @@ public void testCanInvokeMethod() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(null, on, "dodo", new String[]{"java.lang.String"}));
assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String", "java.lang.String"}));
@@ -1407,7 +1407,7 @@ public void testCanInvokeMethod2() throws Exception {
Subject subject = loginWithTestRoles("viewer");
- Subject.doAs(subject, (PrivilegedAction) () -> {
+ Subject.callAs(subject, (Callable) () -> {
try {
assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String"}));
assertTrue(guard.canInvoke(null, on, "doit", new String[]{}));
diff --git a/pom.xml b/pom.xml
index ec4c28d7b20..1ad92d748ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -150,7 +150,8 @@
1695310533
- 11
+ 21
+ 21
scm:git:https://gitbox.apache.org/repos/asf/karaf.git
scm:git:https://gitbox.apache.org/repos/asf/karaf.git
@@ -449,6 +450,15 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ -Xlint:deprecation
+
+
+
org.apache.maven.plugins
maven-eclipse-plugin
@@ -632,7 +642,8 @@
[3.8.8,4)
- [17,)
+
+ [21,)
@@ -898,7 +909,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 1.8
+ 21
diff --git a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
index 21bb8f993f1..54bb4b737d3 100644
--- a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
+++ b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
@@ -28,9 +28,9 @@
import java.io.IOException;
import java.security.Principal;
-import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.concurrent.Callable;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
@@ -338,7 +338,7 @@ public void testInvocationBlocking1() throws Exception {
// Run with the right credentials so we can test the expected roles
Subject subject = new Subject();
subject.getPrincipals().add(new RolePrincipal("b"));
- Subject.doAs(subject, (PrivilegedAction