Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-405

srv:serviceContext in QueryEngineHTTP

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • ARQ 2.9.2
    • Jena 2.10.1
    • ARQ

    Description

      I'm running SPARQL queries on endpoints with HTTP Basic
      authentication, and am looking for a convenient way to manage and
      configure the credentials.

      Currently I've implemented a simple registry that checks endpoint URIs
      against a map and sets the credentials using
      QueryEngineHTTP.setBasicAuthentication().

      Recently however I came across query Context configuration:
      http://jena.apache.org/documentation/query/service.html

      That seemed exactly what I needed, but there is a problem: it doesn't
      seem to work with basic QueryEngineHTTP? Am I right to assume that
      srv:serviceContext only works with explicit SERVICE endpoints?

      Any reason why the approaches cannot be unified and
      QueryEngineHTTP.setBasicAuthentication() would use the Context? It is
      executing the query against some service after all (even if it's not
      explicit SERVICE). What class(es) would I need to extend to achieve
      this?

      The code I tried on ARQ 2.9.2 (endpoint and credentials are bogus):

      Context sparqlContext = new Context();
      sparqlContext.put(ARQConstants.allocSymbol("http://jena.hpl.hp.com/Service#",
      "queryAuthUser"), "xxxxx");
      sparqlContext.put(ARQConstants.allocSymbol("http://jena.hpl.hp.com/Service#",
      "queryAuthPwd"), "yyyy");
      Map<String,Context> serviceContext = new HashMap<String,Context>();
      serviceContext.put("http://dydra.com/graphity/repository/sparql",
      sparqlContext);
      ARQ.getContext().put(ARQConstants.allocSymbol("http://jena.hpl.hp.com/Service#",
      "serviceContext"), serviceContext);
      ...
      QueryEngineHTTP request =
      QueryExecutionFactory.createServiceRequest(endpointURI, query);
      if (log.isDebugEnabled()) log.debug("SPARQL Context: {} ",
      request.getContext());
      request.execConstruct();

      I see the credentials in the debug output:

      symbol:http://jena.hpl.hp.com/Service#serviceContext =

      {http://dydra.com/graphity/repository/sparql=symbol:http://jena.hpl.hp.com/Service#queryAuthPwd = yyyy symbol:http://jena.hpl.hp.com/Service#queryAuthUser = xxxxx}

      but the serviceContext doesn't seem to have effect since I'm getting

      13:21:54,149 TRACE HttpQuery:242 - Exception in exec
      HttpException: 401 Unauthorized
      You need to sign in or sign up before continuing.
      at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:431)

      Attachments

        1. QueryEngineHTTP.java
          2 kB
          Martynas Jusevičius

        Issue Links

          Activity

            People

              rvesse Rob Vesse
              graphity Martynas Jusevičius
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 20m
                  20m
                  Remaining:
                  Remaining Estimate - 20m
                  20m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified