RFR: 8267108: Alternate Subject.getSubject and doAs APIs that do not depend on Security Manager APIs
Weijun Wang
weijun at openjdk.java.net
Tue Oct 19 16:28:14 UTC 2021
New `Subject` APIs `current()` and `callAs()` are created to be replacements of `getSubject()` and `doAs()` since the latter two methods are now deprecated for removal.
In this implementation, by default, `current()` returns the same value as `getSubject(AccessController.getCurrent())` and `callAs()` is implemented based on `doAs()`. This behavior is subject to change in the future once `SecurityManager` is removed.
User can experiment a possible future mechanism by setting the system property `jdk.security.auth.subject.useTL` to `true`, where the `callAs()` method stores the subject into a `ThreadLocal` object and the `current()` method returns it (Note: this mechanism does not work with principal-based permissions).
Inside JDK, we’ve switched from `getSubject()` to `current()` in JGSS and user can start switching to `callAs()` in their applications. Users can also switch to `current()` but please note that if you used to call `getSubject(acc)` in a `doPrivileged` call you might need to try calling `current()` in a `doPrivilegedWithCombiner` call to see if the `AccessControlContext` inside the call inherits the subject from the outer one.
-------------
Commit messages:
- deprecate doAs, use new APIs in src and test
- Merge branch 'master' into 8267108
- old untouched. new same as old by default, or use TL when a sys prop is set
- multiple implementations
- 8267108: Alternate Subject.getSubject API that does not depend on Security Manager APIs
Changes: https://git.openjdk.java.net/jdk/pull/5024/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5024&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8267108
Stats: 653 lines in 20 files changed: 452 ins; 92 del; 109 mod
Patch: https://git.openjdk.java.net/jdk/pull/5024.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/5024/head:pull/5024
PR: https://git.openjdk.java.net/jdk/pull/5024
More information about the security-dev
mailing list