Skip to content

Commit

Permalink
#37 Make the JRE path resolved by the java.home property.
Browse files Browse the repository at this point in the history
  • Loading branch information
junoyoon committed Mar 8, 2014
1 parent 3946c88 commit 855fe03
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class NGrinderSecurityManager extends SecurityManager {

private String agentExecDirectory = System.getProperty("ngrinder.exec.path", workDirectory);
private String javaHomeDirectory = System.getenv("JAVA_HOME");
private String jreHomeDirectory = System.getProperty("java.home");
private final String javaExtDirectory = System.getProperty("java.ext.dirs");
private final String pythonPath = System.getProperty("python.path");
private final String pythonHome = System.getProperty("python.home");
Expand All @@ -45,10 +46,13 @@ public class NGrinderSecurityManager extends SecurityManager {
private final List<String> deleteAllowedDirectory = new ArrayList<String>();

{
this.init();
}

void init() {
this.initAccessOfDirectories();
this.initAccessOfHosts();
}

/**
* Set default accessed of directories. <br>
*/
Expand All @@ -65,20 +69,14 @@ private void initAccessOfDirectories() {
agentExecDirectory = normalize(new File(agentExecDirectory).getAbsolutePath(), null);
if (javaHomeDirectory == null) {
System.out.println("env var JAVA_HOME should be provided.");
}
javaHomeDirectory = normalize(new File(javaHomeDirectory).getAbsolutePath(), null);
String jreHomeDirectory;
if (javaHomeDirectory != null && !javaHomeDirectory.isEmpty()) {
jreHomeDirectory = javaHomeDirectory.substring(0, javaHomeDirectory.lastIndexOf(File.separator))
+ File.separator + "jre";
} else {
jreHomeDirectory = "JAVA";
javaHomeDirectory = normalize(new File(javaHomeDirectory).getAbsolutePath(), null);
readAllowedDirectory.add(javaHomeDirectory);
}

readAllowedDirectory.add(workDirectory);
readAllowedDirectory.add(logDirectory);
readAllowedDirectory.add(agentExecDirectory);
readAllowedDirectory.add(javaHomeDirectory);

readAllowedDirectory.add(jreHomeDirectory);
if (isNotEmpty(pythonHome)) {
readAllowedDirectory.add(pythonHome);
Expand Down

0 comments on commit 855fe03

Please sign in to comment.