'How to configure a repository and SAIL Configuration with authentication?

I need to create an openrdf:SailRepository in which to authenticate with basic authentication with username and password to a service. I tried the following configuration of the repository, but I don't know how to set the username and password to connect to the service.


PREFIX repo: <http://www.openrdf.org/config/repository#>
PREFIX reposail: <http://www.openrdf.org/config/repository/sail#>
PREFIX ephedra: <http://www.metaphacts.com/ontologies/platform/ephedra#>
PREFIX sail: <http://www.openrdf.org/config/sail#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://www.metaphacts.com/ontologies/platform/service/custom#>

[] a repo:Repository ;
  repo:repositoryID "rest-api-wrapper" ; 
  rdfs:label "Repository to connect to a remote REST API." ; 
  repo:repositoryImpl [
    repo:repositoryType "openrdf:SailRepository" ;
    reposail:sailImpl [
      sail:sailType "metaphacts:RESTService" ;
      ephedra:serviceURL "http://example.org/rest/service/api" ; 
      ephedra:httpMethod "POST" ; 
      ephedra:httpHeader [
       ephedra:name "Authorization";
       ephedra:value "Basic Auth"
      ] ;
      ephedra:implementsService ephedra:service-name 
    ]  
  ] .

I looked over the documentation on hhttps://rdf4j.org/documentation/reference/configuration/#SailRepository but I don't find any example with the basic authorization concept. Also I need to be able to also configure the body of the POST request. How could I change the template above to add the username, password and the body parameters of the request?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source