Search in sources :

Example 1 with URLAccessRule

use of org.neo4j.graphdb.security.URLAccessRule in project neo4j by neo4j.

the class URLAccessRules method combined.

public static URLAccessRule combined(final Map<String, URLAccessRule> urlAccessRules) {
    return new URLAccessRule() {

        @Override
        public URL validate(Configuration config, URL url) throws URLAccessValidationError {
            String protocol = url.getProtocol();
            URLAccessRule protocolRule = urlAccessRules.get(protocol);
            if (protocolRule == null) {
                throw new URLAccessValidationError("loading resources via protocol '" + protocol + "' is not permitted");
            }
            return protocolRule.validate(config, url);
        }
    };
}
Also used : URLAccessRule(org.neo4j.graphdb.security.URLAccessRule) Configuration(org.neo4j.graphdb.config.Configuration) URL(java.net.URL) URLAccessValidationError(org.neo4j.graphdb.security.URLAccessValidationError)

Example 2 with URLAccessRule

use of org.neo4j.graphdb.security.URLAccessRule in project neo4j by neo4j.

the class GraphDatabaseDependencies method newDependencies.

public static GraphDatabaseDependencies newDependencies() {
    List<KernelExtensionFactory<?>> kernelExtensions = new ArrayList<>();
    for (KernelExtensionFactory factory : Service.load(KernelExtensionFactory.class)) {
        kernelExtensions.add(factory);
    }
    Map<String, URLAccessRule> urlAccessRules = new HashMap<>();
    urlAccessRules.put("http", URLAccessRules.alwaysPermitted());
    urlAccessRules.put("https", URLAccessRules.alwaysPermitted());
    urlAccessRules.put("ftp", URLAccessRules.alwaysPermitted());
    urlAccessRules.put("file", URLAccessRules.fileAccess());
    List<QueryEngineProvider> queryEngineProviders = asList(Service.load(QueryEngineProvider.class));
    return new GraphDatabaseDependencies(null, null, new ArrayList<>(), kernelExtensions, urlAccessRules, queryEngineProviders);
}
Also used : QueryEngineProvider(org.neo4j.kernel.impl.query.QueryEngineProvider) URLAccessRule(org.neo4j.graphdb.security.URLAccessRule) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory)

Aggregations

URLAccessRule (org.neo4j.graphdb.security.URLAccessRule)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Configuration (org.neo4j.graphdb.config.Configuration)1 URLAccessValidationError (org.neo4j.graphdb.security.URLAccessValidationError)1 KernelExtensionFactory (org.neo4j.kernel.extension.KernelExtensionFactory)1 QueryEngineProvider (org.neo4j.kernel.impl.query.QueryEngineProvider)1