Class NeptuneRdf4JSigV4Example


  • public final class NeptuneRdf4JSigV4Example
    extends Object
    Small example demonstrating how to use NeptuneSparqlRepository with SignatureV4 in combination with the RDF4J library (see http://rdf4j.org/). The example uses the NeptuneSparqlRepository class contained in this package, which extends RDF4J's SparqlRepository class by IAM authentication.

    Before running this code, make sure you've got everything setup properly, in particular:

    1. Make sure that your AWS credentials are available in the provider chain, see DefaultAWSCredentialsProviderChain for more information.
    2. Start the main method by passing in your endpoint, e.g. "http://<my_neptune_host>:<my_neptune_port>". The server will send a "SELECT * WHERE { ?s ?p ?o } LIMIT 10" query against your endpoint.
    Author:
    schmdtm
    • Method Detail

      • main

        public static void main​(String[] args)
                         throws Exception
        Main method. Expecting the endpoint as the first argument.
        Parameters:
        args - arguments
        Throws:
        Exception - in case there are problems
      • executeSignedQueryRequest

        protected static void executeSignedQueryRequest​(String endpointUrl,
                                                        String query)
                                                 throws com.amazonaws.neptune.auth.NeptuneSigV4SignerException
        Example for signed request.
        Parameters:
        endpointUrl - of the endpoint to which to send the request
        Throws:
        com.amazonaws.neptune.auth.NeptuneSigV4SignerException - in case there's a problem signing the request
      • executeSignedInsertRequest

        protected static void executeSignedInsertRequest​(String endpointUrl)
                                                  throws com.amazonaws.neptune.auth.NeptuneSigV4SignerException
        Example for signed request.
        Parameters:
        endpointUrl - of the endpoint to which to send the request
        Throws:
        com.amazonaws.neptune.auth.NeptuneSigV4SignerException - in case there's a problem signing the request
      • executeUnsignedQueryRequest

        protected static void executeUnsignedQueryRequest​(String endpointUrl)
        Example for unsigned request.
        Parameters:
        endpointUrl - of the endpoint to which to send the request
      • evaluateAndPrintQueryResult

        protected static void evaluateAndPrintQueryResult​(String queryString,
                                                          org.eclipse.rdf4j.repository.Repository repo)
        Evaluate the query and print the query result.
        Parameters:
        queryString - the query string to evaluate
        repo - the repository over which to evaluate the query