use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_injection_07.
@Test(expected = ARQException.class)
public void test_param_string_injection_07() {
// This injection attempt is prevented by forbidding injection of
// variable parameters immediately surrounded by quotes
String str = "PREFIX : <http://example/>\nINSERT DATA { <s> <p> \"?var\" }";
ParameterizedSparqlString pss = new ParameterizedSparqlString(str);
pss.setLiteral("var", " . } ; DROP ALL ; INSERT DATA { <s> <p> ");
UpdateRequest updates = pss.asUpdate();
Assert.fail("Attempt to do SPARQL injection should result in an exception");
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestAuth method update_with_auth_01.
@Test(expected = HttpException.class)
public void update_with_auth_01() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
// No auth credentials should result in an error
ue.execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestAuth method update_with_auth_07.
@Test
public void update_with_auth_07() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemoteForm(updates, authServiceUpdate);
// Auth credentials for valid user with correct password
ue.setClient(withBasicAuth(ANY, "allowed", "password"));
ue.execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestAuth method update_with_auth_03.
@Test
public void update_with_auth_03() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
// Auth credentials for valid user with correct password
ue.setClient(withBasicAuth(ANY, "allowed", "password"));
ue.execute();
}
use of org.apache.jena.update.UpdateRequest in project webofneeds by researchstudio-sat.
the class SparqlUpdateCrawlerCallback method onDatasetCrawled.
@Override
public void onDatasetCrawled(final URI uri, final Dataset dataset) {
if (null == sparqlEndpoint) {
logger.warn("no SPARQL endpoint defined");
return;
}
Iterator<String> graphNames = dataset.listNames();
while (graphNames.hasNext()) {
StringBuilder quadpatterns = new StringBuilder();
String graphName = graphNames.next();
Model model = dataset.getNamedModel(graphName);
StringWriter sw = new StringWriter();
RDFDataMgr.write(sw, model, Lang.NTRIPLES);
quadpatterns.append("\nINSERT DATA { GRAPH <").append(graphName).append("> { ").append(sw).append("}};\n");
logger.info(quadpatterns.toString());
UpdateRequest update = UpdateFactory.create(quadpatterns.toString());
UpdateProcessRemote riStore = (UpdateProcessRemote) UpdateExecutionFactory.createRemote(update, sparqlEndpoint);
riStore.execute();
}
}
Aggregations