Skip to content

Commit

Permalink
TRUNK-6203: Global properties access should be privileged (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
wikumChamith authored Jun 20, 2024
1 parent b12d2ee commit 490ad71
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.openmrs.api.GlobalPropertyListener;
import org.openmrs.api.context.Context;
import org.openmrs.util.OpenmrsUtil;
import org.openmrs.util.PrivilegeConstants;

import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -46,7 +47,13 @@ public static String getSpaDirectory() {
}

private String getDirectoryFromSettings() {
String localDirectory = Context.getAdministrationService().getGlobalProperty(GP_LOCAL_DIRECTORY);
String localDirectory;
try {
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
localDirectory = Context.getAdministrationService().getGlobalProperty(GP_LOCAL_DIRECTORY);
} finally {
Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
}
if (localDirectory == null) {
localDirectory = Context.getRuntimeProperties().getProperty(GP_LOCAL_DIRECTORY);

Expand Down

0 comments on commit 490ad71

Please sign in to comment.