Skip to content

Commit

Permalink
Added security manager check.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <tomas.kraus@oracle.com>
  • Loading branch information
Tomas-Kraus committed Apr 19, 2023
1 parent b8a7881 commit 5b50d93
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions impl/src/main/java/org/eclipse/parsson/JsonContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class JsonContext {

static final String PROPERTY_BUFFER_POOL = BufferPool.class.getName();

@SuppressWarnings("removal")
private static final boolean IS_SECURITY_MANAGER = System.getSecurityManager() != null;
private final Map<String, ?> config;

// Maximum value of BigInteger scale value
Expand Down Expand Up @@ -115,12 +117,12 @@ private static Integer getIntSystemProperty(String propertyName) throws JsonExce

@SuppressWarnings("removal")
private static String getSystemProperty(String propertyName) throws JsonException {
return AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty(propertyName));
}

private static String propertyAction(String propertyName) {
return System.getProperty(propertyName);
if (IS_SECURITY_MANAGER) {
return AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty(propertyName));
} else {
return System.getProperty(propertyName);
}
}

private static int propertyStringToInt(String propertyName, String propertyValue) throws JsonException {
Expand Down

0 comments on commit 5b50d93

Please sign in to comment.