1 package hudson; 2 3 import hudson.model.Hudson; 4 import hudson.scm.SCM; 5 import hudson.tasks.Builder; 6 import hudson.tasks.Publisher; 7 import hudson.triggers.Trigger; 8 import org.kohsuke.stapler.StaplerRequest; 9 import org.kohsuke.stapler.StaplerResponse; 10 11 import javax.servlet.ServletContext ; 12 import javax.servlet.ServletException ; 13 import javax.servlet.http.HttpServletResponse ; 14 import java.io.IOException ; 15 import java.net.URL ; 16 17 36 public abstract class Plugin { 37 38 41 PluginWrapper wrapper; 42 43 55 public void setServletContext(ServletContext context) { 56 } 57 58 79 public void start() throws Exception { 80 } 81 82 97 public void stop() throws Exception { 98 } 99 100 103 public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException , ServletException { 104 String path = req.getRestOfPath(); 105 106 if(path.length()==0) 107 path = "/"; 108 109 if(path.indexOf("..")!=-1 || path.length()<1) { 110 rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); 112 return; 113 } 114 115 rsp.serveFile(req, new URL (wrapper.baseResourceURL,'.'+path)); 116 } 117 } 118 | Popular Tags |