I'm trying to use federated queries with Jena via a Fuseki endpoint. With the SERVICE keyword in my SPARQL query, I'm connecting to a Stardog endpoint. As it's a secured URL, the endpoint is specified as follows: http://admin:admin@url. As this is not secure, Jena shows the following message:
Code: 36/HAS_PASSWORD in USER: Including passwords in URIs is deprecated.
According to the docs, you can specify srv:queryAuthUser and srv:queryAuthPwd for the credentials. Is there any way to do this directly in the SPARQL query? Or, can it be configured in Fuseki (ttl file)?
EDIT
When I use @RobV's solution, the service context doesn't seem to be picked up. This is what the context looks like:
symbol:http://jena.hpl.hp.com/ARQ#regexImpl = symbol:http://jena.hpl.hp.com/ARQ#javaRegex
symbol:http://jena.hpl.hp.com/ARQ#constantBNodeLabels = true
symbol:http://jena.hpl.hp.com/ARQ#strictGraph = false
symbol:http://jena.hpl.hp.com/ARQ#strictSPARQL = false
symbol:http://jena.hpl.hp.com/ARQ#stageGenerator = com.hp.hpl.jena.tdb.solver.StageGeneratorDirectTDB@6f2dd58d
symbol:http://jena.hpl.hp.com/ARQ#enablePropertyFunctions = true
symbol:http://jena.hpl.hp.com/ARQ#romanNumerals = false
symbol:http://jena.hpl.hp.com/ARQ#optFilterPlacement = false
symbol:http://jena.hpl.hp.com/ARQ#registryPropertyFunctions = com.hp.hpl.jena.sparql.pfunction.PropertyFunctionRegistry@6f05ca41
symbol:http://jena.hpl.hp.com/ARQ/system#opExecutorFactory = com.hp.hpl.jena.tdb.solver.OpExecutorTDB$1@2a1f5501
When I leave the Fuseki config as is, and add the service context in my business layer, the service context does seem to be added:
symbol:http://jena.hpl.hp.com/Service#serviceContext = {http://host:5820/db/query=symbol:http://jena.hpl.hp.com/Service#queryAuthPwd = usr
symbol:http://jena.hpl.hp.com/Service#queryAuthUser = pwd}
Eitherway, I'm still getting an unauthorized message when I execute a federated query.
No there is no way to do this directly in the SPARQL query
In theory you could use the
ja:context
property in the Fuseki configuration file to specify context properties. However in practise this does not work because a service context is a nested context and the assembler does not support nested contexts currently.However what you can do instead is to to use the
ja:loadClass
mechanism to load a custom class that you add to the class path which does the necessary static initialisation e.g.Note that you MUST associate your initialiser with the subject that represents the
fuseki:Server
instance otherwise theja:loadClass
triple may not get processed.And then:
Note that the method needs to be static and needs to be called
init()
in order for Fuseki to invoke it.With this revised setup I was able to successfully query my local Stardog server.