Skip to content

Introduce SystemAccessUtils to all Security Manager permission checks - #1668

Open
taoliult wants to merge 1 commit into
IBM:java21from
taoliult:java21_SecurityManager
Open

Introduce SystemAccessUtils to all Security Manager permission checks#1668
taoliult wants to merge 1 commit into
IBM:java21from
taoliult:java21_SecurityManager

Conversation

@taoliult

@taoliult taoliult commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Centralize all security manager permission checks in SystemAccessUtils wrapper methods instead of AccessController.doPrivileged() calls throughout the codebase.

SystemAccessUtils now wraps all permission-requiring operations:

  • System property access (getSystemProperty)
  • File system access (fileExists, newFileReader, getFileCanonicalPath)
  • Library loading (loadLibrary)
  • Class loading (forName)

This centralizes permission checks in one utility class, making the codebase cleaner and easier to maintain across JDK versions (SecurityManager in JDK 21 and earlier, removed AccessController.doPrivileged() in JDK 25+).

This is a back port PR from PR: #1700

Comment thread src/main/java/com/ibm/crypto/plus/provider/OpenJCEPlusFIPS.java Outdated
Comment thread src/main/java/com/ibm/crypto/plus/provider/base/Digest.java Outdated
@taoliult
taoliult force-pushed the java21_SecurityManager branch from a435aee to 81b622d Compare July 27, 2026 18:57
@@ -143,7 +143,7 @@ public List<ServiceDefinition> readServices() throws IOException {
throw new IOException("File not found: " + filePath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add a privileged check on this Files.exists() function?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, updated.

Comment thread src/main/java/com/ibm/crypto/plus/provider/SystemAccessUtils.java Outdated
Comment thread src/main/java/com/ibm/crypto/plus/provider/ock/NativeOCKImplementation.java Outdated
@taoliult
taoliult force-pushed the java21_SecurityManager branch from 10601e3 to a7e07b9 Compare July 28, 2026 21:22
@taoliult
taoliult requested a review from jasonkatonica July 28, 2026 21:27
@taoliult
taoliult force-pushed the java21_SecurityManager branch from b0a56a3 to 9323557 Compare July 29, 2026 14:06

@jasonkatonica jasonkatonica 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

@taoliult
taoliult force-pushed the java21_SecurityManager branch 6 times, most recently from 1e50e81 to d725f65 Compare August 10, 2026 17:03
Centralize all security manager permission checks in SystemAccessUtils
wrapper methods instead of AccessController.doPrivileged() calls
throughout the codebase.

SystemAccessUtils now wraps all permission-requiring operations:
- System property access (getSystemProperty)
- File system access (fileExists, newFileReader, getFileCanonicalPath)
- Library loading (loadLibrary)
- Class loading (forName)

This centralizes permission checks in one utility class, making the
codebase cleaner and easier to maintain across JDK versions
(SecurityManager in JDK 21 and earlier, removed
AccessController.doPrivileged() in JDK 25+).

Signed-off-by: Tao Liu <tao.liu@ibm.com>
@taoliult
taoliult force-pushed the java21_SecurityManager branch from ed67237 to 5dbb1da Compare August 11, 2026 13:42

@KostasTsiounis KostasTsiounis 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

@JinhangZhang JinhangZhang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@jasonkatonica
jasonkatonica self-requested a review August 11, 2026 18:20

@jasonkatonica jasonkatonica 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

@taoliult taoliult changed the title Introduce SystemAccessUtils to wrap AccessController.doPrivileged() Introduce SystemAccessUtils to all Security Manager permission checks Aug 13, 2026
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.

5 participants