public ResourceManager build() { return new PathResourceManager(this); } }
public ServletResourceManager(final VirtualFile resourcesRoot, final Collection<VirtualFile> overlays, boolean explodedDeployment, boolean followSymlink, boolean disableFileWatchService, List<String> externalOverlays) throws IOException { this.explodedDeployment = explodedDeployment; Path physicalFile = resourcesRoot.getPhysicalFile().toPath().toRealPath(); deploymentResourceManager = new PathResourceManager(physicalFile, TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.overlays = overlays; if(externalOverlays == null) { this.externalOverlays = new ResourceManager[0]; } else { this.externalOverlays = new ResourceManager[externalOverlays.size()]; for (int i = 0; i < externalOverlays.size(); ++i) { String path = externalOverlays.get(i); PathResourceManager pr = new PathResourceManager(Paths.get(path).toRealPath(), TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.externalOverlays[i] = pr; } } }
@Override public HttpHandler wrap(HttpHandler handler) { ResourceManager rm = new PathResourceManager(Paths.get(location), 1024); ResourceHandler resourceHandler = new ResourceHandler(rm); resourceHandler.setDirectoryListingEnabled(allowDirectoryListing); return resourceHandler; } }
private HttpHandler configureRootHandler() { AccessLogService logService = accessLogService; HttpHandler rootHandler = pathHandler; ArrayList<UndertowFilter> filters = new ArrayList<>(this.filters); //handle options * requests rootHandler = new OptionsHandler(rootHandler); //handle requests that use the Expect: 100-continue header rootHandler = Handlers.httpContinueRead(rootHandler); rootHandler = LocationService.configureHandlerChain(rootHandler, filters); if (logService != null) { rootHandler = logService.configureAccessLogHandler(rootHandler); } // handle .well-known requests from ACME certificate authorities String path = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", "."); Path base; try { base = Paths.get(path).normalize().toRealPath(); } catch (IOException e) { throw new RuntimeException(e); } final int cacheBufferSize = 1024; final int cacheBuffers = 1024; PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, true, false); rootHandler = new AcmeResourceHandler(resourceManager, rootHandler); GateHandlerWrapper gateHandlerWrapper = this.gateHandlerWrapper; if(gateHandlerWrapper != null) { rootHandler = gateHandlerWrapper.wrap(rootHandler); } return rootHandler; }
public PathResourceHandler() { PathResourceConfig config = (PathResourceConfig)Config.getInstance().getJsonObjectConfig(PathResourceConfig.CONFIG_NAME, PathResourceConfig.class); if(config.isPrefix()) { pathHandler = new PathHandler() .addPrefixPath(config.getPath(), new ResourceHandler(new PathResourceManager(Paths.get(config.getBase()), config.getTransferMinSize())) .setDirectoryListingEnabled(config.isDirectoryListingEnabled())); } else { pathHandler = new PathHandler() .addExactPath(config.getPath(), new ResourceHandler(new PathResourceManager(Paths.get(config.getBase()), config.getTransferMinSize())) .setDirectoryListingEnabled(config.isDirectoryListingEnabled())); } }
public VirtualHostHandler() { VirtualHostConfig config = (VirtualHostConfig)Config.getInstance().getJsonObjectConfig(VirtualHostConfig.CONFIG_NAME, VirtualHostConfig.class); virtualHostHandler = new NameVirtualHostHandler(); for(VirtualHost host: config.hosts) { virtualHostHandler.addHost(host.domain, new PathHandler().addPrefixPath(host.getPath(), new ResourceHandler((new PathResourceManager(Paths.get(host.getBase()), host.getTransferMinSize()))).setDirectoryListingEnabled(host.isDirectoryListingEnabled()))); } }
@Override public HttpHandler createHandler(final OperationContext context, ModelNode model) throws OperationFailedException { final String path = PATH.resolveModelAttribute(context, model).asString(); final boolean directoryListing = DIRECTORY_LISTING.resolveModelAttribute(context, model).asBoolean(); final boolean followSymlink = FOLLOW_SYMLINK.resolveModelAttribute(context, model).asBoolean(); final boolean caseSensitive = CASE_SENSITIVE.resolveModelAttribute(context, model).asBoolean(); final int cacheBufferSize = CACHE_BUFFER_SIZE.resolveModelAttribute(context, model).asInt(); final int cacheBuffers = CACHE_BUFFERS.resolveModelAttribute(context, model).asInt(); final List<String> safePaths = SAFE_SYMLINK_PATHS.unwrap(context, model); final String[] paths = safePaths.toArray(new String[safePaths.size()]); UndertowLogger.ROOT_LOGGER.creatingFileHandler(path, directoryListing, followSymlink, caseSensitive, safePaths); Path base; try { base = Paths.get(path).normalize().toRealPath(); //workaround for JBEAP-10231 } catch (IOException e) { throw new OperationFailedException(UndertowLogger.ROOT_LOGGER.unableAddHandlerForPath(path)); } PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, caseSensitive, followSymlink, paths); ResourceHandler handler = new ResourceHandler(resourceManager); handler.setDirectoryListingEnabled(directoryListing); return handler; } }
@Override public WebDeploymentController addWebDeployment(final WebDeploymentBuilder webDeploymentBuilder) throws Exception { DeploymentInfo d = new DeploymentInfo(); d.setDeploymentName(webDeploymentBuilder.getContextRoot()); d.setContextPath(webDeploymentBuilder.getContextRoot()); d.setClassLoader(webDeploymentBuilder.getClassLoader()); d.setResourceManager(new PathResourceManager(webDeploymentBuilder.getDocumentRoot().toPath().toAbsolutePath(), 1024 * 1024)); d.setIgnoreFlush(false); for (ServletBuilder servlet : webDeploymentBuilder.getServlets()) { ServletInfo s; if (servlet.getServlet() == null) { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass()); } else { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass(), new ImmediateInstanceFactory<>(servlet.getServlet())); } if (servlet.isForceInit()) { s.setLoadOnStartup(1); } s.addMappings(servlet.getUrlMappings()); for (Map.Entry<String, String> param : servlet.getInitParams().entrySet()) { s.addInitParam(param.getKey(), param.getValue()); } d.addServlet(s); } if (controlPoint != null) { d.addOuterHandlerChainWrapper(GlobalRequestControllerHandler.wrapper(controlPoint, webDeploymentBuilder.getAllowRequestPredicates())); } return new WebDeploymentControllerImpl(d); }
public ResourceManager build() { return new PathResourceManager(this); } }
public ResourceManager build() { return new PathResourceManager(this); } }
public ServletResourceManager(final VirtualFile resourcesRoot, final Collection<VirtualFile> overlays, boolean explodedDeployment, boolean followSymlink, boolean disableFileWatchService, List<String> externalOverlays) throws IOException { this.explodedDeployment = explodedDeployment; Path physicalFile = resourcesRoot.getPhysicalFile().toPath().toRealPath(); deploymentResourceManager = new PathResourceManager(physicalFile, TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.overlays = overlays; if(externalOverlays == null) { this.externalOverlays = new ResourceManager[0]; } else { this.externalOverlays = new ResourceManager[externalOverlays.size()]; for (int i = 0; i < externalOverlays.size(); ++i) { String path = externalOverlays.get(i); PathResourceManager pr = new PathResourceManager(Paths.get(path).toRealPath(), TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.externalOverlays[i] = pr; } } }
public ServletResourceManager(final VirtualFile resourcesRoot, final Collection<VirtualFile> overlays, boolean explodedDeployment, boolean followSymlink, boolean disableFileWatchService, List<String> externalOverlays) throws IOException { this.explodedDeployment = explodedDeployment; Path physicalFile = resourcesRoot.getPhysicalFile().toPath().toRealPath(); deploymentResourceManager = new PathResourceManager(physicalFile, TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.overlays = overlays; if(externalOverlays == null) { this.externalOverlays = new ResourceManager[0]; } else { this.externalOverlays = new ResourceManager[externalOverlays.size()]; for (int i = 0; i < externalOverlays.size(); ++i) { String path = externalOverlays.get(i); PathResourceManager pr = new PathResourceManager(Paths.get(path).toRealPath(), TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.externalOverlays[i] = pr; } } }
@Override public HttpHandler wrap(HttpHandler handler) { ResourceManager rm = new PathResourceManager(Paths.get(location), 1024); ResourceHandler resourceHandler = new ResourceHandler(rm); resourceHandler.setDirectoryListingEnabled(allowDirectoryListing); return resourceHandler; } }
@Override public HttpHandler wrap(HttpHandler handler) { ResourceManager rm = new PathResourceManager(Paths.get(location), 1024); ResourceHandler resourceHandler = new ResourceHandler(rm); resourceHandler.setDirectoryListingEnabled(allowDirectoryListing); return resourceHandler; } }
private HttpHandler configureRootHandler() { AccessLogService logService = accessLogService; HttpHandler rootHandler = pathHandler; ArrayList<UndertowFilter> filters = new ArrayList<>(this.filters); //handle options * requests rootHandler = new OptionsHandler(rootHandler); //handle requests that use the Expect: 100-continue header rootHandler = Handlers.httpContinueRead(rootHandler); rootHandler = LocationService.configureHandlerChain(rootHandler, filters); if (logService != null) { rootHandler = logService.configureAccessLogHandler(rootHandler); } // handle .well-known requests from ACME certificate authorities String path = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", "."); Path base; try { base = Paths.get(path).normalize().toRealPath(); } catch (IOException e) { throw new RuntimeException(e); } final int cacheBufferSize = 1024; final int cacheBuffers = 1024; PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, true, false); rootHandler = new AcmeResourceHandler(resourceManager, rootHandler); GateHandlerWrapper gateHandlerWrapper = this.gateHandlerWrapper; if(gateHandlerWrapper != null) { rootHandler = gateHandlerWrapper.wrap(rootHandler); } return rootHandler; }
private HttpHandler configureRootHandler() { AccessLogService logService = accessLogService; HttpHandler rootHandler = pathHandler; ArrayList<UndertowFilter> filters = new ArrayList<>(this.filters); //handle options * requests rootHandler = new OptionsHandler(rootHandler); //handle requests that use the Expect: 100-continue header rootHandler = Handlers.httpContinueRead(rootHandler); rootHandler = LocationService.configureHandlerChain(rootHandler, filters); if (logService != null) { rootHandler = logService.configureAccessLogHandler(rootHandler); } // handle .well-known requests from ACME certificate authorities String path = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", "."); Path base; try { base = Paths.get(path).normalize().toRealPath(); } catch (IOException e) { throw new RuntimeException(e); } final int cacheBufferSize = 1024; final int cacheBuffers = 1024; PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, true, false); rootHandler = new AcmeResourceHandler(resourceManager, rootHandler); GateHandlerWrapper gateHandlerWrapper = this.gateHandlerWrapper; if(gateHandlerWrapper != null) { rootHandler = gateHandlerWrapper.wrap(rootHandler); } return rootHandler; }
@Override public HttpHandler createHandler(final OperationContext context, ModelNode model) throws OperationFailedException { final String path = PATH.resolveModelAttribute(context, model).asString(); final boolean directoryListing = DIRECTORY_LISTING.resolveModelAttribute(context, model).asBoolean(); final boolean followSymlink = FOLLOW_SYMLINK.resolveModelAttribute(context, model).asBoolean(); final boolean caseSensitive = CASE_SENSITIVE.resolveModelAttribute(context, model).asBoolean(); final int cacheBufferSize = CACHE_BUFFER_SIZE.resolveModelAttribute(context, model).asInt(); final int cacheBuffers = CACHE_BUFFERS.resolveModelAttribute(context, model).asInt(); final List<String> safePaths = SAFE_SYMLINK_PATHS.unwrap(context, model); final String[] paths = safePaths.toArray(new String[safePaths.size()]); UndertowLogger.ROOT_LOGGER.creatingFileHandler(path, directoryListing, followSymlink, caseSensitive, safePaths); Path base; try { base = Paths.get(path).normalize().toRealPath(); //workaround for JBEAP-10231 } catch (IOException e) { throw new OperationFailedException(UndertowLogger.ROOT_LOGGER.unableAddHandlerForPath(path)); } PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, caseSensitive, followSymlink, paths); ResourceHandler handler = new ResourceHandler(resourceManager); handler.setDirectoryListingEnabled(directoryListing); return handler; } }
@Override public HttpHandler createHandler(final OperationContext context, ModelNode model) throws OperationFailedException { final String path = PATH.resolveModelAttribute(context, model).asString(); final boolean directoryListing = DIRECTORY_LISTING.resolveModelAttribute(context, model).asBoolean(); final boolean followSymlink = FOLLOW_SYMLINK.resolveModelAttribute(context, model).asBoolean(); final boolean caseSensitive = CASE_SENSITIVE.resolveModelAttribute(context, model).asBoolean(); final int cacheBufferSize = CACHE_BUFFER_SIZE.resolveModelAttribute(context, model).asInt(); final int cacheBuffers = CACHE_BUFFERS.resolveModelAttribute(context, model).asInt(); final List<String> safePaths = SAFE_SYMLINK_PATHS.unwrap(context, model); final String[] paths = safePaths.toArray(new String[safePaths.size()]); UndertowLogger.ROOT_LOGGER.creatingFileHandler(path, directoryListing, followSymlink, caseSensitive, safePaths); Path base; try { base = Paths.get(path).normalize().toRealPath(); //workaround for JBEAP-10231 } catch (IOException e) { throw new OperationFailedException(UndertowLogger.ROOT_LOGGER.unableAddHandlerForPath(path)); } PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, caseSensitive, followSymlink, paths); ResourceHandler handler = new ResourceHandler(resourceManager); handler.setDirectoryListingEnabled(directoryListing); return handler; } }
@Override public WebDeploymentController addWebDeployment(final WebDeploymentBuilder webDeploymentBuilder) throws Exception { DeploymentInfo d = new DeploymentInfo(); d.setDeploymentName(webDeploymentBuilder.getContextRoot()); d.setContextPath(webDeploymentBuilder.getContextRoot()); d.setClassLoader(webDeploymentBuilder.getClassLoader()); d.setResourceManager(new PathResourceManager(webDeploymentBuilder.getDocumentRoot().toPath().toAbsolutePath(), 1024 * 1024)); d.setIgnoreFlush(false); for (ServletBuilder servlet : webDeploymentBuilder.getServlets()) { ServletInfo s; if (servlet.getServlet() == null) { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass()); } else { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass(), new ImmediateInstanceFactory<>(servlet.getServlet())); } if (servlet.isForceInit()) { s.setLoadOnStartup(1); } s.addMappings(servlet.getUrlMappings()); for (Map.Entry<String, String> param : servlet.getInitParams().entrySet()) { s.addInitParam(param.getKey(), param.getValue()); } d.addServlet(s); } if (controlPoint != null) { d.addOuterHandlerChainWrapper(GlobalRequestControllerHandler.wrapper(controlPoint, webDeploymentBuilder.getAllowRequestPredicates())); } return new WebDeploymentControllerImpl(d); }
@Override public WebDeploymentController addWebDeployment(final WebDeploymentBuilder webDeploymentBuilder) throws Exception { DeploymentInfo d = new DeploymentInfo(); d.setDeploymentName(webDeploymentBuilder.getContextRoot()); d.setContextPath(webDeploymentBuilder.getContextRoot()); d.setClassLoader(webDeploymentBuilder.getClassLoader()); d.setResourceManager(new PathResourceManager(webDeploymentBuilder.getDocumentRoot().toPath().toAbsolutePath(), 1024 * 1024)); d.setIgnoreFlush(false); for (ServletBuilder servlet : webDeploymentBuilder.getServlets()) { ServletInfo s; if (servlet.getServlet() == null) { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass()); } else { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass(), new ImmediateInstanceFactory<>(servlet.getServlet())); } if (servlet.isForceInit()) { s.setLoadOnStartup(1); } s.addMappings(servlet.getUrlMappings()); for (Map.Entry<String, String> param : servlet.getInitParams().entrySet()) { s.addInitParam(param.getKey(), param.getValue()); } d.addServlet(s); } if (controlPoint != null) { d.addOuterHandlerChainWrapper(GlobalRequestControllerHandler.wrapper(controlPoint, webDeploymentBuilder.getAllowRequestPredicates())); } return new WebDeploymentControllerImpl(d); }