in src/main/java/com/amazonaws/neptune/client/jena/NeptuneJenaSigV4Example.java [39:91]
public static void main(String... args) throws NeptuneSigV4SignerException {
if (args.length == 0 || StringUtils.isEmpty(args[0])) {
System.err.println("Please specify your endpoint as program argument "
+ "(e.g.: http://<your_neptune_endpoint>:<your_neptune_endpoint>)");
System.exit(1);
}
final String endpoint = args[0];
final String regionName = "us-east-1";
final AwsCredentialsProvider awsCredentialsProvider = DefaultCredentialsProvider.create();
final NeptuneApacheHttpSigV4Signer v4Signer = new NeptuneApacheHttpSigV4Signer(regionName, awsCredentialsProvider);
final HttpClient v4SigningClient = HttpClientBuilder.create().addInterceptorLast(new HttpRequestInterceptor() {
@Override
public void process(final HttpRequest req, final HttpContext ctx) throws HttpException {
if (req instanceof HttpUriRequest) {
final HttpUriRequest httpUriReq = (HttpUriRequest) req;
try {
v4Signer.signRequest(httpUriReq);
} catch (NeptuneSigV4SignerException e) {
throw new HttpException("Problem signing the request: ", e);
}
} else {
throw new HttpException("Not an HttpUriRequest"); // this should never happen
}
}
}).build();
RDFConnectionRemoteBuilder builder = RDFConnectionRemote.create()
.httpClient(v4SigningClient)
.destination(endpoint)
// Query only.
.queryEndpoint("sparql")
.updateEndpoint("sparql");
String query = "SELECT * { ?s ?p ?o } LIMIT 100";
// Whether the connection can be reused depends on the details of the implementation.
// See example 5.
try (RDFConnection conn = builder.build()) {
System.out.println("> Printing query result: ");
conn.querySelect(query, System.out::println);
}
}