Skip to content

Lift minimum JDK version to 21 and remove SecurityManager - #2214

Merged
jbonofre merged 23 commits into
apache:mainfrom
holgerfriedrich:pr-secmgr-removal
Nov 18, 2026
Merged

jbonofre merged 23 commits into
apache:mainfrom
holgerfriedrich:pr-secmgr-removal

Conversation

@holgerfriedrich

@holgerfriedrich holgerfriedrich commented Dec 30, 2025 •

Copy link
Copy Markdown
Contributor

This is a first step to prepare the 4.5 branch for running with Java 25.
Starting Karaf in Java 25 does not yet work, as a few functions related to the SecurityManager have been deprecated long time ago and cannot be activated any longer via command line switches.
As a new API has been added in Java 18, I for new lift the minimum required version to Java 21 (LTS).

Maybe this is not the way to go - as there has been some discussions if we could introduce an abstraction layer to allow Java 17 as well.

  • Lift minimum JDK version to 21
  • Remove occurrences of SecurityManager, as getSecurityManager returns
    null since JDK 18
  • Disable JavaSecurityTest, Rework JavaSecurityTest #2082
  • Enable verbose deprecation warnings
  • Replace getSubject and doAs calls
    ** getSubject can no longer be activated via JRE command line as
    SecurityManager has been removed in JDK 25.
    A replacement is available since Java 21.
    ** doAs was deprecated and is replaced by callAll.

For Java 25, another set of modifications is still needed and will be submitted as another PR.
Locally, I got Karaf compiling, passing the tests, and starting with Java 25. 🥳

@jbonofre
jbonofre self-requested a review December 31, 2025 05:20
<libraries>
</libraries>
<javase>17</javase>
<javase>21</javase>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's require change on the karaf-maven-plugin and dependencies. I will create another PR (as planned) to tackle that.

import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;

@Ignore("Disabled due to removal of SecurityManager. ref Apache Karaf GitHub issue #2082")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather remove the test (to avoid confusion) or refactor it instead of ignoring it.

@holgerfriedrich holgerfriedrich Jan 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, if I just remove the SecurityManager assertion, the test completes.
I am not sure if I get completely what this test was intended for (it checks that all bundles come up after applying a specific config - but how this was related to SecurityManager, I still don't get).

I pushed the change to ignore that no SecurityManager is there.

@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

@jbonofre is there anying else open I should address?

@jbonofre

jbonofre commented Jan 9, 2026

Copy link
Copy Markdown
Member

@holgerfriedrich I think this PR is pretty good, it just needs dependent PRs. I will tackle that.

@jbonofre

Copy link
Copy Markdown
Member

@holgerfriedrich do you mind to share your email address with me ? I just realize that you didn't subscribe on the dev mailing list, and you are not on The ASF slack Karaf channel. Thanks !

@arusevm

arusevm commented Mar 12, 2026

Copy link
Copy Markdown

Hi @holgerfriedrich @jbonofre,

I've got here some ugly patches that seem to make the Subject-related stuff work on java 25.

Basically, there's an issue with that in 25, Subject.callAs() and current() use a ScopedValue and its binding "gets lost" across "thread-boundaries", of which there are a bunch :) It gets ugly, because every time you do something like ExecutorService.submit() you have to also "pass" the current Subject. Gets even worse, because Gogo needs a similar treatment...

Anyway, wondering if it might help if I share what we've got here with you... or if you already have something like it? Or if I might help in some other way? :)

@jbonofre

Copy link
Copy Markdown
Member

@arusevm I'm finalizing camel-karaf release. I will be back on Karaf just after, tackling this.

Sorry for the delay.

@jbonofre

Copy link
Copy Markdown
Member

Thanks @holgerfriedrich for the update ! I will do a new pass because I have a bunch of changes on the way.

@holgerfriedrich
holgerfriedrich force-pushed the pr-secmgr-removal branch 6 times, most recently from 7e6e4fd to 05bbfa0 Compare April 14, 2026 22:30
@holgerfriedrich

holgerfriedrich commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@jbonofre may I ask you to have a look at this again?

I rebased it in the last days and got the CI green.

It is a major step towards Java 25 compatibility.
Compilation with JDK 25 already works; one test needs a class downgrade and a few itests fail.
I'd like to keep that in a separate PR on top of this one.

❯ ./bin/karaf
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldOffset has been called by org.apache.felix.framework.util.SecureAction (file:/C:/Users/holgerf/src/karaf/assemblies/apache-karaf/target/assembly/system/org/apache/felix/org.apache.felix.framework/7.0.5/org.apache.felix.framework-7.0.5.jar)
WARNING: Please consider reporting this to the maintainers of class org.apache.felix.framework.util.SecureAction
WARNING: sun.misc.Unsafe::staticFieldOffset will be removed in a future release
        __ __                  ____
       / //_/____ __________ _/ __/
      / ,<  / __ `/ ___/ __ `/ /_
     / /| |/ /_/ / /  / /_/ / __/
    /_/ |_|\__,_/_/   \__,_/_/

  Apache Karaf (4.5.0-SNAPSHOT)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

@root()> shell:info
shell:info
Karaf
  Karaf version               4.5.0-SNAPSHOT
  Karaf home                  C:\Users\holgerf\src\karaf\assemblies\apache-karaf\target\assembly
  Karaf base                  C:\Users\holgerf\src\karaf\assemblies\apache-karaf\target\assembly
  OSGi Framework              org.apache.felix.framework-7.0.5

JVM
  Java Virtual Machine        OpenJDK 64-Bit Server VM version 25+36-3489
  Version                     25

@jbonofre

jbonofre commented May 6, 2026

Copy link
Copy Markdown
Member

@holgerfriedrich I removed the specs bundles. Can you please rebase?

What's your take about JDK 17 / JDK 21?
Personaly, I think it's completely ok to bump directly to JDK 21 for Karaf 4.5.x (JDK 17 is supported at runtime by Karaf 4.4.x).

@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

@jbonofre if we do not consider writing a compat layer on our own, we need then new API available from JDK18. So 21 LTS is the natural choice.
I have rebased now (mainly due to the deleted files in the spec folder), but did not have time to give it a try in JDK25.

@jbonofre

jbonofre commented May 6, 2026

Copy link
Copy Markdown
Member

@holgerfriedrich I agree. I'm advocating for JDK 21 for Karaf 4.5.x. I propose to go that way (including updating our CI).

@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

@jbonofre how shall we proceed with this one?
Is something missing, or do you have another approach in mind?

@kamilkrzywanski

Copy link
Copy Markdown

@holgerfriedrich there is needed wersion of aries proxy compatible with jdk 25, it seems that their repo is already compatible with jdk 25 but no new release yet.

org.apache.aries.proxy
org.apache.aries.proxy
1.1.14

@jbonofre

jbonofre commented Jun 2, 2026

Copy link
Copy Markdown
Member

@holgerfriedrich @kamilkrzywanski I think we can move forward with this PR and tackle more required updates in follow up PRs (I'm working on Aries releases).

- Propagate session subject on JDK 25, fix jaas:sudo
- Fix GogoPlugin user lookup, KarafTestSupport unwrap
- java_home 21+, ${javaVersion} in archetype pom
Java 21 is the minimum now, so drop the jre-1.8..20 and eecap-1.8..20
definitions. Add eecap-22..27 and jre-27, and align the instance and
test templates (they stopped at eecap-18).

java.applet (JEP 504) and netscape.javascript (jdk.jsobject) are gone
from Java 26, so jre-26 and later no longer export them.
No replacement intended: the SecurityManager is permanently disabled
since JDK 24 (JEP 486), so there is nothing left to test. Felix dropped
its Security Manager support as well, see FELIX-6833.

Also remove the felix.framework.security test dependency and the
test-only framework-security feature.
@holgerfriedrich

holgerfriedrich commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Last version + cherry-picked #3098 tested with native J25 classes: Full openHAB on top, still seems to work fine.

// them (JDK 21: AccessControlContext inheritance, possibly from an earlier
// jaas:sudo). So the session's subject is authoritative; jaas:sudo switches it while
// its command runs. Subject.current() is only a fallback for sessions without one.
Subject subject = (Subject) session.get(Subject.class.getName());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking closer at this, reading the authoritative RBAC Subject from session.get(Subject.class.getName()) is a security issue: Session.get/put is backed by Gogo's user-writable variable map (CommandSessionImpl.variables), so any shell user can overwrite or clear it directly with plain variable assignment (no command or .invoke needed):

  • In Karaf's default org.apache.karaf.command.acl.shell (where .invoke is not restricted), a restricted user (e.g. viewer) can construct/populate a Subject with RolePrincipal("admin") and assign javax.security.auth.Subject = $forged, bypassing shell RBAC.
  • Even when .invoke = admin is configured, javax.security.auth.Subject = foo causes an unchecked ClassCastException on every subsequent command, and javax.security.auth.Subject = null forces fallback to Subject.current() (which on JDK 21 can pick up a stale inherited ACC on a pool thread).

Instead of reading the security authority from Gogo variables, could we keep the authoritative Subject in an internal field on ConsoleSessionImpl and HeadlessSessionImpl (and map CommandSessionImpl -> Session internally in SessionFactoryImpl instead of trusting .session)?

  • Capture Subject.current() in both ConsoleSessionImpl and HeadlessSessionImpl constructors (and create shell inside JaasHelper.doAs(Subject, ...) in ShellFactoryImpl, matching LocalConsoleManager and SuCommand).
  • In Session.execute(CharSequence), if Subject.current() is non-null, temporarily switch the internal session subject in a try/finally block. That way SudoCommand, ShellCommand, and KarafTestSupport automatically propagate their doAs/callAs subject without writing it to user-mutable shell variables.

@Override
protected Object invoke(CommandSessionImpl session, Object target, String name, List<Object> args) throws Exception {
checkSecurity(SHELL_SCOPE, SHELL_INVOKE, Arrays.asList(target, name, args));
checkShellSecurityAsSessionSubject(session, SHELL_INVOKE, Arrays.asList(target, name, args));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two points here (in addition to the session.get(Subject.class.getName()) comment on SecuredCommand):

  1. super.invoke(session, target, name, args) currently runs outside JaasHelper.runAs(subject, ...). On JDK 25, if reflective invocation calls a ServiceGuard-protected OSGi service or anything inspecting Subject.current(), it will see null. Wrapping both checkSecurity(...) and super.invoke(...) inside JaasHelper.doAs(subject, ...) avoids that.
  2. If .session is still read from commandSession, a user running .session = foo will cause a ClassCastException here, resolving the Session / Subject via an internal map in SessionFactoryImpl (or at least guarding with instanceof) will prevent that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbonofre both changes done as requested.... please have a careful look at the implementation - I don't feel very confident in this area....

// pull the java:21-jre-alpine image
// TODO it should be changed to the official karaf image as soon as it's available on Docker HUB
pull("java", "8-jre-alpine", true, url);
pull("java", "21-jre-alpine", true, url);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java:21-jre-alpine doesn't exist on Docker Hub (the official java repo was deprecated after Java 8). Let's use eclipse-temurin:21-jre-alpine here (and in provision() below), and eclipse-temurin:21-jre in DockerClientTest.java, docker/src/test/resources/Dockerfile, docker/src/test/resources/docker-build.sh (openjdk:21-jre also doesn't exist), and manual/src/main/asciidoc/user-guide/docker.adoc, to stay consistent with DockerfileMojo and assemblies/docker/Dockerfile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done as requested

<configuration>
<source>1.8</source>
<target>1.8</target>
<release>${javaVersion}</release>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this to ${javaVersion}! Two spots right above in this same POM still reference Java 17:

  • Line 373: <requiredJavaVersion>[17,)</requiredJavaVersion> should be [${javaVersion},) now that the plugin ships Java 21 bytecode (same in tooling/karaf-services-maven-plugin/pom.xml:151).
  • Line 301: <maven.compiler.release>17</maven.compiler.release> could also use ${javaVersion} for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to avoid conflicts with #3115. Changing both now.

setPrivateField(mojo, "assembly", assembly);
setPrivateField(mojo, "command", "[\"karaf\", \"server\"]");
setPrivateField(mojo, "image", "eclipse-temurin:17-jre");
setPrivateField(mojo, "image", "eclipse-temurin:21-jre");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since DEFAULT_IMAGE is now eclipse-temurin:21-jre, testCustomImageAndCommand() no longer distinguishes a custom image from the default. Maybe use eclipse-temurin:25-jre here instead?

Comment thread .github/workflows/ci.yml Resolved
holgerfriedrich and others added 3 commits November 18, 2026 18:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks for addressing all the feedback and for the patience through all rebases @holgerfriedrich!

I reviewed the updated SessionFactoryImpl / ConsoleSessionImpl / HeadlessSessionImpl / SecuredCommand / SecuredSessionFactoryImpl changes-keeping the authoritative Subject in a package-private field and resolving CommandSession -> Session internally in SessionFactoryImpl looks solid and cleanly handles both the security boundary and JDK 25 ScopedValue propagation across Gogo/SSH/console threads.

@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

Great. Let's see how it works out. CI is green now as well (the other 6 jobs will never run, since the CI setup has changed in the meantime).

@jbonofre

Copy link
Copy Markdown
Member

@holgerfriedrich I will merge as soon as CI is green on the PR (still running).

@jbonofre

Copy link
Copy Markdown
Member

@holgerfriedrich it seems that the CI is "weird" here. Let me check 😄

@holgerfriedrich

holgerfriedrich commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@jbonofre I don't think it's weird. It's just the jobs from the past (when the PR was created) plus the jobs we use now.

@jbonofre

Copy link
Copy Markdown
Member

@holgerfriedrich the problem is that they are blocking the merge. Let me fix that.

…er from MBeanInvocationHandler

Signed-off-by: JB Onofré <jbonofre@apache.org>
Signed-off-by: JB Onofré <jbonofre@apache.org>
@jbonofre

Copy link
Copy Markdown
Member

@holgerfriedrich

I updated the ci.yml to match the name as defined in .asf.yaml. It should unblock the merge button.

I will cleanup once on main.

@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

It seems the J25 job is only triggered on merge - as long it is a PR, it will not built due to the condition github.ref == 'refs/heads/main'. Maybe (github.ref == 'refs/heads/main' || github.base_ref == 'main')` works out better. But we can do this after merge.

@jbonofre

Copy link
Copy Markdown
Member

@holgerfriedrich yes, that's the plan: unblock/merge this one and improve on main.

@jbonofre
jbonofre merged commit 4829b97 into apache:main Nov 18, 2026
7 checks passed
@holgerfriedrich
holgerfriedrich deleted the pr-secmgr-removal branch November 19, 2026 04:16
MrEasy pushed a commit to seeburger-ag/karaf that referenced this pull request Nov 19, 2026
* Lift minimum JDK version to 21 and remove SecurityManager

* Lift minimum JDK version to 21
* Remove occurrences of SecurityManager, as getSecurityManager returns
  null since JDK 18
* Enable verbose deprecation warnings
* Replace getSubject and doAs calls,
  getSubject can no longer be activated via JRE command line as
  SecurityManager has been removed in JDK 25.
  A replacement is available since Java 21.
  doAs was deprecated and is replaced by callAll.
* Remove SecurityManager form JavaSecurityTest

* disable org.osgi.framework.security in JavaSecurityTest

* Updated how Java 21 is set in various places

* Fix Subject propagation for shell RBAC on JDK 25

Subject.current()/callAs() use a plain ScopedValue on JDK 25 (no
SecurityManager fallback like on JDK 21), which doesn't survive a
new Thread or an ExecutorService hop. Since Felix Gogo runs each
command on its own executor thread, this broke current-user lookup
and RBAC checks (bundle:list/bundle:info losing bundle visibility).

- JaasHelper.doAs/runAs now use Subject.callAs() instead of the old
  AccessControlContext/SubjectDomainCombiner plumbing; drop the now
  dead OsgiSubjectDomainCombiner/DelegatingProtectionDomain classes.
- SecuredCommand.execute() re-binds the subject from the session on
  whatever thread runs the command, since Session is always passed
  explicitly there regardless of the executing thread.
- LocalConsoleManager, ShellFactoryImpl and SuCommand store the
  subject on the session so SecuredCommand can read it back.

* Change thread creation for itests

* Fix typo in ci workflow desc

* Replace doAs in newly added KarafMBeanServerGuardTest

* Replace java 17 in karaf-light pom

* Add Java25 on Ubuntu to build matrix

* ubuntu 26.04 public preview for j25

* mvn-4.0.0-rc-7 for j25

* Cleanup

* Prefer the bound subject in SecuredCommand, fall back to the session variable
* Rethrow unchecked exceptions in GSSAPILdapLoginModule
* Require JDK 21 in startup scripts, remove Java 8 leftovers
* Remove unused java.security import

* Cleanup, addresses AI review

- Propagate session subject on JDK 25, fix jaas:sudo
- Fix GogoPlugin user lookup, KarafTestSupport unwrap
- java_home 21+, ${javaVersion} in archetype pom

* Define JRE/EE capabilities for Java 21 to 27 only

Java 21 is the minimum now, so drop the jre-1.8..20 and eecap-1.8..20
definitions. Add eecap-22..27 and jre-27, and align the instance and
test templates (they stopped at eecap-18).

java.applet (JEP 504) and netscape.javascript (jdk.jsobject) are gone
from Java 26, so jre-26 and later no longer export them.

* Replace {8,11,17}-jre by 21-jre

* Remove JavaSecurityTest, apache#2082

No replacement intended: the SecurityManager is permanently disabled
since JDK 24 (JEP 486), so there is nothing left to test. Felix dropped
its Security Manager support as well, see FELIX-6833.

Also remove the felix.framework.security test dependency and the
test-only framework-security feature.

* Replace stale Java versions, also in docs

* Use session subject for shell invoke/redirect ACL checks

* Implement review suggestions

* Keep the shell session subject out of user-writable variables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Adapt Docker test to J25

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

* Remove unused karaf-maven-plugin config.properties and AccessController from MBeanInvocationHandler

Signed-off-by: JB Onofré <jbonofre@apache.org>

* Keep default JDK 21 CI job names matching .asf.yaml required checks

Signed-off-by: JB Onofré <jbonofre@apache.org>

---------

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: JB Onofré <jbonofre@apache.org>
Co-authored-by: Fryderyk Wysocki <fryderyk.wysocki@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: JB Onofré <jbonofre@apache.org>

(cherry picked from commit 4829b97)
MrEasy pushed a commit to seeburger-ag/karaf that referenced this pull request Nov 19, 2026
* Lift minimum JDK version to 21 and remove SecurityManager

* Lift minimum JDK version to 21
* Remove occurrences of SecurityManager, as getSecurityManager returns
  null since JDK 18
* Enable verbose deprecation warnings
* Replace getSubject and doAs calls,
  getSubject can no longer be activated via JRE command line as
  SecurityManager has been removed in JDK 25.
  A replacement is available since Java 21.
  doAs was deprecated and is replaced by callAll.
* Remove SecurityManager form JavaSecurityTest

* disable org.osgi.framework.security in JavaSecurityTest

* Updated how Java 21 is set in various places

* Fix Subject propagation for shell RBAC on JDK 25

Subject.current()/callAs() use a plain ScopedValue on JDK 25 (no
SecurityManager fallback like on JDK 21), which doesn't survive a
new Thread or an ExecutorService hop. Since Felix Gogo runs each
command on its own executor thread, this broke current-user lookup
and RBAC checks (bundle:list/bundle:info losing bundle visibility).

- JaasHelper.doAs/runAs now use Subject.callAs() instead of the old
  AccessControlContext/SubjectDomainCombiner plumbing; drop the now
  dead OsgiSubjectDomainCombiner/DelegatingProtectionDomain classes.
- SecuredCommand.execute() re-binds the subject from the session on
  whatever thread runs the command, since Session is always passed
  explicitly there regardless of the executing thread.
- LocalConsoleManager, ShellFactoryImpl and SuCommand store the
  subject on the session so SecuredCommand can read it back.

* Change thread creation for itests

* Fix typo in ci workflow desc

* Replace doAs in newly added KarafMBeanServerGuardTest

* Replace java 17 in karaf-light pom

* Add Java25 on Ubuntu to build matrix

* ubuntu 26.04 public preview for j25

* mvn-4.0.0-rc-7 for j25

* Cleanup

* Prefer the bound subject in SecuredCommand, fall back to the session variable
* Rethrow unchecked exceptions in GSSAPILdapLoginModule
* Require JDK 21 in startup scripts, remove Java 8 leftovers
* Remove unused java.security import

* Cleanup, addresses AI review

- Propagate session subject on JDK 25, fix jaas:sudo
- Fix GogoPlugin user lookup, KarafTestSupport unwrap
- java_home 21+, ${javaVersion} in archetype pom

* Define JRE/EE capabilities for Java 21 to 27 only

Java 21 is the minimum now, so drop the jre-1.8..20 and eecap-1.8..20
definitions. Add eecap-22..27 and jre-27, and align the instance and
test templates (they stopped at eecap-18).

java.applet (JEP 504) and netscape.javascript (jdk.jsobject) are gone
from Java 26, so jre-26 and later no longer export them.

* Replace {8,11,17}-jre by 21-jre

* Remove JavaSecurityTest, apache#2082

No replacement intended: the SecurityManager is permanently disabled
since JDK 24 (JEP 486), so there is nothing left to test. Felix dropped
its Security Manager support as well, see FELIX-6833.

Also remove the felix.framework.security test dependency and the
test-only framework-security feature.

* Replace stale Java versions, also in docs

* Use session subject for shell invoke/redirect ACL checks

* Implement review suggestions

* Keep the shell session subject out of user-writable variables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Adapt Docker test to J25

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

* Remove unused karaf-maven-plugin config.properties and AccessController from MBeanInvocationHandler

Signed-off-by: JB Onofré <jbonofre@apache.org>

* Keep default JDK 21 CI job names matching .asf.yaml required checks

Signed-off-by: JB Onofré <jbonofre@apache.org>

---------

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: JB Onofré <jbonofre@apache.org>
Co-authored-by: Fryderyk Wysocki <fryderyk.wysocki@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: JB Onofré <jbonofre@apache.org>

(cherry picked from commit 4829b97)
MrEasy pushed a commit to seeburger-ag/karaf that referenced this pull request Nov 19, 2026
* Lift minimum JDK version to 21 and remove SecurityManager

* Lift minimum JDK version to 21
* Remove occurrences of SecurityManager, as getSecurityManager returns
  null since JDK 18
* Enable verbose deprecation warnings
* Replace getSubject and doAs calls,
  getSubject can no longer be activated via JRE command line as
  SecurityManager has been removed in JDK 25.
  A replacement is available since Java 21.
  doAs was deprecated and is replaced by callAll.
* Remove SecurityManager form JavaSecurityTest

* disable org.osgi.framework.security in JavaSecurityTest

* Updated how Java 21 is set in various places

* Fix Subject propagation for shell RBAC on JDK 25

Subject.current()/callAs() use a plain ScopedValue on JDK 25 (no
SecurityManager fallback like on JDK 21), which doesn't survive a
new Thread or an ExecutorService hop. Since Felix Gogo runs each
command on its own executor thread, this broke current-user lookup
and RBAC checks (bundle:list/bundle:info losing bundle visibility).

- JaasHelper.doAs/runAs now use Subject.callAs() instead of the old
  AccessControlContext/SubjectDomainCombiner plumbing; drop the now
  dead OsgiSubjectDomainCombiner/DelegatingProtectionDomain classes.
- SecuredCommand.execute() re-binds the subject from the session on
  whatever thread runs the command, since Session is always passed
  explicitly there regardless of the executing thread.
- LocalConsoleManager, ShellFactoryImpl and SuCommand store the
  subject on the session so SecuredCommand can read it back.

* Change thread creation for itests

* Fix typo in ci workflow desc

* Replace doAs in newly added KarafMBeanServerGuardTest

* Replace java 17 in karaf-light pom

* Add Java25 on Ubuntu to build matrix

* ubuntu 26.04 public preview for j25

* mvn-4.0.0-rc-7 for j25

* Cleanup

* Prefer the bound subject in SecuredCommand, fall back to the session variable
* Rethrow unchecked exceptions in GSSAPILdapLoginModule
* Require JDK 21 in startup scripts, remove Java 8 leftovers
* Remove unused java.security import

* Cleanup, addresses AI review

- Propagate session subject on JDK 25, fix jaas:sudo
- Fix GogoPlugin user lookup, KarafTestSupport unwrap
- java_home 21+, ${javaVersion} in archetype pom

* Define JRE/EE capabilities for Java 21 to 27 only

Java 21 is the minimum now, so drop the jre-1.8..20 and eecap-1.8..20
definitions. Add eecap-22..27 and jre-27, and align the instance and
test templates (they stopped at eecap-18).

java.applet (JEP 504) and netscape.javascript (jdk.jsobject) are gone
from Java 26, so jre-26 and later no longer export them.

* Replace {8,11,17}-jre by 21-jre

* Remove JavaSecurityTest, apache#2082

No replacement intended: the SecurityManager is permanently disabled
since JDK 24 (JEP 486), so there is nothing left to test. Felix dropped
its Security Manager support as well, see FELIX-6833.

Also remove the felix.framework.security test dependency and the
test-only framework-security feature.

* Replace stale Java versions, also in docs

* Use session subject for shell invoke/redirect ACL checks

* Implement review suggestions

* Keep the shell session subject out of user-writable variables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Adapt Docker test to J25

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

* Remove unused karaf-maven-plugin config.properties and AccessController from MBeanInvocationHandler

Signed-off-by: JB Onofré <jbonofre@apache.org>

* Keep default JDK 21 CI job names matching .asf.yaml required checks

Signed-off-by: JB Onofré <jbonofre@apache.org>

---------

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: JB Onofré <jbonofre@apache.org>
Co-authored-by: Fryderyk Wysocki <fryderyk.wysocki@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: JB Onofré <jbonofre@apache.org>

(cherry picked from commit 4829b97)
MrEasy pushed a commit to seeburger-ag/karaf that referenced this pull request Nov 19, 2026
* Lift minimum JDK version to 21 and remove SecurityManager

* Lift minimum JDK version to 21
* Remove occurrences of SecurityManager, as getSecurityManager returns
  null since JDK 18
* Enable verbose deprecation warnings
* Replace getSubject and doAs calls,
  getSubject can no longer be activated via JRE command line as
  SecurityManager has been removed in JDK 25.
  A replacement is available since Java 21.
  doAs was deprecated and is replaced by callAll.
* Remove SecurityManager form JavaSecurityTest

* disable org.osgi.framework.security in JavaSecurityTest

* Updated how Java 21 is set in various places

* Fix Subject propagation for shell RBAC on JDK 25

Subject.current()/callAs() use a plain ScopedValue on JDK 25 (no
SecurityManager fallback like on JDK 21), which doesn't survive a
new Thread or an ExecutorService hop. Since Felix Gogo runs each
command on its own executor thread, this broke current-user lookup
and RBAC checks (bundle:list/bundle:info losing bundle visibility).

- JaasHelper.doAs/runAs now use Subject.callAs() instead of the old
  AccessControlContext/SubjectDomainCombiner plumbing; drop the now
  dead OsgiSubjectDomainCombiner/DelegatingProtectionDomain classes.
- SecuredCommand.execute() re-binds the subject from the session on
  whatever thread runs the command, since Session is always passed
  explicitly there regardless of the executing thread.
- LocalConsoleManager, ShellFactoryImpl and SuCommand store the
  subject on the session so SecuredCommand can read it back.

* Change thread creation for itests

* Fix typo in ci workflow desc

* Replace doAs in newly added KarafMBeanServerGuardTest

* Replace java 17 in karaf-light pom

* Add Java25 on Ubuntu to build matrix

* ubuntu 26.04 public preview for j25

* mvn-4.0.0-rc-7 for j25

* Cleanup

* Prefer the bound subject in SecuredCommand, fall back to the session variable
* Rethrow unchecked exceptions in GSSAPILdapLoginModule
* Require JDK 21 in startup scripts, remove Java 8 leftovers
* Remove unused java.security import

* Cleanup, addresses AI review

- Propagate session subject on JDK 25, fix jaas:sudo
- Fix GogoPlugin user lookup, KarafTestSupport unwrap
- java_home 21+, ${javaVersion} in archetype pom

* Define JRE/EE capabilities for Java 21 to 27 only

Java 21 is the minimum now, so drop the jre-1.8..20 and eecap-1.8..20
definitions. Add eecap-22..27 and jre-27, and align the instance and
test templates (they stopped at eecap-18).

java.applet (JEP 504) and netscape.javascript (jdk.jsobject) are gone
from Java 26, so jre-26 and later no longer export them.

* Replace {8,11,17}-jre by 21-jre

* Remove JavaSecurityTest, apache#2082

No replacement intended: the SecurityManager is permanently disabled
since JDK 24 (JEP 486), so there is nothing left to test. Felix dropped
its Security Manager support as well, see FELIX-6833.

Also remove the felix.framework.security test dependency and the
test-only framework-security feature.

* Replace stale Java versions, also in docs

* Use session subject for shell invoke/redirect ACL checks

* Implement review suggestions

* Keep the shell session subject out of user-writable variables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Adapt Docker test to J25

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

* Remove unused karaf-maven-plugin config.properties and AccessController from MBeanInvocationHandler

Signed-off-by: JB Onofré <jbonofre@apache.org>

* Keep default JDK 21 CI job names matching .asf.yaml required checks

Signed-off-by: JB Onofré <jbonofre@apache.org>

---------

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: JB Onofré <jbonofre@apache.org>
Co-authored-by: Fryderyk Wysocki <fryderyk.wysocki@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: JB Onofré <jbonofre@apache.org>

(cherry picked from commit 4829b97)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants