use of org.apache.jena.sparql.modify.UpdateProcessRemoteBase in project jena by apache.
the class TestAuth method update_with_auth_11.
@Test
public void update_with_auth_11() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
// Auth credentials for valid user with correct password scoped to correct URI
// Also using pre-emptive auth
BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
URI scope = URI.create(authServiceUpdate);
credsProv.setCredentials(new AuthScope(scope.getHost(), scope.getPort()), new UsernamePasswordCredentials("allowed", "password"));
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
// Generate BASIC scheme object and add it to the local auth cache
BasicScheme basicAuth = new BasicScheme();
authCache.put(new HttpHost(scope.getHost()), basicAuth);
// Add AuthCache to the execution context
HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credsProv);
context.setAuthCache(authCache);
HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
ue.setClient(client);
ue.setHttpContext(context);
ue.execute();
}
use of org.apache.jena.sparql.modify.UpdateProcessRemoteBase in project jena by apache.
the class TestService method update_service_context_application_01.
@Test
public void update_service_context_application_01() {
// This test requires no service context to be set
@SuppressWarnings("unchecked") Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
if (serviceContextMap != null) {
serviceContextMap.remove(SERVICE);
}
UpdateRequest updates = UpdateFactory.create("CREATE GRAPH <http://example>");
UpdateProcessRemoteBase engine = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, SERVICE);
Assert.assertNotNull(engine);
// Check that no settings were changed
Assert.assertNull(engine.getClient());
}
use of org.apache.jena.sparql.modify.UpdateProcessRemoteBase in project jena by apache.
the class TestAuth method update_with_auth_10.
@Test
public void update_with_auth_10() throws URISyntaxException {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
// Auth credentials for valid user with correct password scoped to
// correct URI
ue.setClient(withBasicAuth(new AuthScope("localhost", authPort), "allowed", "password"));
ue.execute();
}
use of org.apache.jena.sparql.modify.UpdateProcessRemoteBase in project jena by apache.
the class TestAuth method update_with_auth_02.
@Test(expected = HttpException.class)
public void update_with_auth_02() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
// Auth credentials for valid user with bad password
ue.setClient(withBasicAuth(ANY, "allowed", "incorrect"));
ue.execute();
}
use of org.apache.jena.sparql.modify.UpdateProcessRemoteBase in project jena by apache.
the class TestAuth method update_with_auth_06.
@Test(expected = HttpException.class)
public void update_with_auth_06() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemoteForm(updates, authServiceUpdate);
// Auth credentials for valid user with bad password
ue.setClient(withBasicAuth(ANY, "allowed", "incorrect"));
ue.execute();
}
Aggregations