类org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker源码实例Demo

下面列出了怎么用org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: selenium   文件: JettyAppServer.java
protected ServletContextHandler addResourceHandler(String contextPath, Path resourceBase) {
  ServletContextHandler context = new ServletContextHandler();

  ResourceHandler staticResource = new ResourceHandler();
  staticResource.setDirectoriesListed(true);
  staticResource.setWelcomeFiles(new String[] { "index.html" });
  staticResource.setResourceBase(resourceBase.toAbsolutePath().toString());
  MimeTypes mimeTypes = new MimeTypes();
  mimeTypes.addMimeMapping("appcache", "text/cache-manifest");
  staticResource.setMimeTypes(mimeTypes);

  context.setContextPath(contextPath);
  context.setAliasChecks(Arrays.asList(new ApproveAliases(), new AllowSymLinkAliasChecker()));

  HandlerList allHandlers = new HandlerList();
  allHandlers.addHandler(staticResource);
  allHandlers.addHandler(context.getHandler());
  context.setHandler(allHandlers);

  handlers.addHandler(context);

  return context;
}
 
源代码2 项目: quarks   文件: HttpServer.java
/**
 * Initialization of the context path for the web application "/console" occurs in this method
 * and the handler for the web application is set.  This only occurs once.
 * @return HttpServer: the singleton instance of this class
 * @throws IOException
 */
public static HttpServer getInstance() throws Exception {
    if (!HttpServerHolder.INITIALIZED) {
        HttpServerHolder.WEBAPP.setContextPath("/console");
        ServletContextHandler contextJobs = new ServletContextHandler(ServletContextHandler.SESSIONS);
        contextJobs.setContextPath("/jobs");
        ServletContextHandler contextMetrics = new ServletContextHandler(ServletContextHandler.SESSIONS);
        contextMetrics.setContextPath("/metrics");
        ServerUtil sUtil = new ServerUtil();
        String commandWarFilePath = sUtil.getAbsoluteWarFilePath("console.war");
        if (commandWarFilePath.equals("")){
        	// check if we are on Eclipse, if Eclipse can't find it, it probably does not exist
        	// running on Eclipse, look for the eclipse war file path
        	ProtectionDomain protectionDomain = HttpServer.class.getProtectionDomain();
        	String eclipseWarFilePath = sUtil.getEclipseWarFilePath(protectionDomain, "console.war");
        	if (!eclipseWarFilePath.equals("")) {            	
        		HttpServerHolder.WEBAPP.setWar(eclipseWarFilePath);
        	} else {
        		throw new Exception(HttpServerHolder.consoleWarNotFoundMessage);
        	}
        } else {
        	HttpServerHolder.WEBAPP.setWar(commandWarFilePath);
        }


        
        HttpServerHolder.WEBAPP.addAliasCheck(new AllowSymLinkAliasChecker()); 
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[] { contextJobs, contextMetrics, HttpServerHolder.WEBAPP });
        HttpServerHolder.JETTYSERVER.setHandler(contexts);
        HttpServerHolder.INITIALIZED = true;
    }
    return HttpServerHolder.INSTANCE;
}
 
 类所在包
 类方法
 同包方法