in server/src/jetbrains/buildServer/staticUIExtensions/web/StaticPageContentController.java [29:66]
public StaticPageContentController(@NotNull final AuthorizationInterceptor auth,
@NotNull final WebControllerManager web,
@NotNull final Configuration config,
@NotNull final HttpDownloadProcessor httpDownloadProcessor) {
super(httpDownloadProcessor);
final File container = FileUtil.getCanonicalFile(new File(config.getIncludeFilesBase(), FOLDER_NAME));
if (!container.exists()) {
try {
if (!container.mkdirs() && !container.exists()) {
LOG.error("Cannot create pages directory: " + container.getAbsolutePath());
} else {
LOG.debug("Created empty pages directory: " + container.getAbsolutePath());
}
} catch (Exception e) {
LOG.error("Cannot create pages directory: " + container.getAbsolutePath(), e);
}
} else if (!container.isDirectory()) {
LOG.warn("Pages directory is not a directory: " + container.getAbsolutePath());
}
setProvider(new StaticResourcesController.ResourceProvider() {
@Nullable
public Resource getResourceForPath(@NotNull String path) {
path = path.replace(PUBLIC_STATIC_CONTENT_PAGES_PATH, "");
if (!container.isDirectory() || !container.exists()) {
return null;
}
final File file = FileUtil.getCanonicalFile(new File(container, path));
if (!FileUtil.isAncestor(container, file, true)) {
// Trying to access something not under container
return null;
}
return new FileSystemResource(file);
}
});
final String path = PUBLIC_STATIC_CONTENT_PAGES_PATH + "**";
web.registerController(path, this);
auth.addPathNotRequiringAuth(path);
}