Skip to content

Commit

Permalink
Remove JNDI support (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Dec 26, 2021
1 parent 19f3b90 commit c6a14ca
Showing 1 changed file with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.framework.errors.NoHomeDirError;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
Expand Down Expand Up @@ -218,23 +215,8 @@ public Locale get() {
*/
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "Home dir is configured by admin or app.")
protected File getHomeDir() {
// check JNDI for the home directory first
// check the system property for the home directory first
String varName = getApplicationName().toUpperCase() + "_HOME";
try {
InitialContext iniCtxt = new InitialContext();
Context env = (Context) iniCtxt.lookup("java:comp/env");
String value = (String) env.lookup(varName);
if(value!=null && value.trim().length()>0)
return new File(value.trim());
// look at one more place. See HUDSON-1314
value = (String) iniCtxt.lookup(varName);
if(value!=null && value.trim().length()>0)
return new File(value.trim());
} catch (NamingException e) {
// ignore
}

// finally check the system property
String sysProp = System.getProperty(varName);
if(sysProp!=null)
return new File(sysProp.trim());
Expand Down

0 comments on commit c6a14ca

Please sign in to comment.