String filePath = file.substring(0, pos); URL internalUrl = new URL(filePath); URL normalizedUrl = resolveRepoURL(internalUrl); if (normalizedUrl == null) { return null;
String filePath = file.substring(0, pos); URL internalUrl = new URL(filePath); URL normalizedUrl = resolveRepoURL(internalUrl); if (normalizedUrl == null) { return null;
String filePath = file.substring(0, pos); URL internalUrl = new URL(filePath); URL normalizedUrl = resolveRepoURL(internalUrl); if (normalizedUrl == null) { return null;
String filePath = file.substring(0, pos); URL internalUrl = new URL(filePath); URL normalizedUrl = resolveRepoURL(internalUrl); if (normalizedUrl == null) { return null;
String filePath = file.substring(0, pos); URL internalUrl = new URL(filePath); URL normalizedUrl = resolveRepoURL(internalUrl); if (normalizedUrl == null) { return null;
/** * Makes sure that the url is white listed or if it points to the local file system it matches one on of the root path in path.repo */ private URL checkURL(URL url) { String protocol = url.getProtocol(); if (protocol == null) { throw new RepositoryException(repositoryName, "unknown url protocol from URL [" + url + "]"); } for (String supportedProtocol : supportedProtocols) { if (supportedProtocol.equals(protocol)) { try { if (URIPattern.match(urlWhiteList, url.toURI())) { // URL matches white list - no additional processing is needed return url; } } catch (URISyntaxException ex) { logger.warn("cannot parse the specified url [{}]", url); throw new RepositoryException(repositoryName, "cannot parse the specified url [" + url + "]"); } // We didn't match white list - try to resolve against path.repo URL normalizedUrl = environment.resolveRepoURL(url); if (normalizedUrl == null) { logger.warn("The specified url [{}] doesn't start with any repository paths specified by the path.repo setting: [{}] or by repositories.url.allowed_urls setting: [{}] ", url, environment.repoFiles()); throw new RepositoryException(repositoryName, "file url [" + url + "] doesn't match any of the locations specified by path.repo or repositories.url.allowed_urls"); } return normalizedUrl; } } throw new RepositoryException(repositoryName, "unsupported url protocol [" + protocol + "] from URL [" + url + "]"); }
/** * Makes sure that the url is white listed or if it points to the local file system it matches one on of the root path in path.repo */ private URL checkURL(URL url) { String protocol = url.getProtocol(); if (protocol == null) { throw new RepositoryException(getMetadata().name(), "unknown url protocol from URL [" + url + "]"); } for (String supportedProtocol : supportedProtocols) { if (supportedProtocol.equals(protocol)) { try { if (URIPattern.match(urlWhiteList, url.toURI())) { // URL matches white list - no additional processing is needed return url; } } catch (URISyntaxException ex) { logger.warn("cannot parse the specified url [{}]", url); throw new RepositoryException(getMetadata().name(), "cannot parse the specified url [" + url + "]"); } // We didn't match white list - try to resolve against path.repo URL normalizedUrl = environment.resolveRepoURL(url); if (normalizedUrl == null) { logger.warn("The specified url [{}] doesn't start with any repository paths specified by the path.repo setting or by {} setting: [{}] ", url, ALLOWED_URLS_SETTING.getKey(), environment.repoFiles()); throw new RepositoryException(getMetadata().name(), "file url [" + url + "] doesn't match any of the locations specified by path.repo or " + ALLOWED_URLS_SETTING.getKey()); } return normalizedUrl; } } throw new RepositoryException(getMetadata().name(), "unsupported url protocol [" + protocol + "] from URL [" + url + "]"); }