use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class ExAuth03_UpdateExecutionPW method exampleUpdateAuth.
public static void exampleUpdateAuth() {
System.out.println();
UpdateExecution uExec1 = UpdateExecutionHTTP.service(dataURL).update("INSERT DATA{}").build();
try {
// Expect failed because there is no authentication credentials.
System.out.println("Update/no auth");
uExec1.execute();
} catch (HttpException ex) {
System.out.println("Failed: " + ex.getMessage());
}
System.out.println("Register user/password + UpdateExecution");
AuthEnv.get().registerUsernamePassword(URI.create(dataURL), "u", "p");
UpdateExecution uExec3 = UpdateExecutionHTTP.service(dataURL).update("INSERT DATA{}").build();
// Expect success because there will be a challenge and Jena will resend with the auth information.
uExec3.execute();
AuthEnv.get().clearActiveAuthentication();
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class TestAuthUpdate_JDK method update_jdk_auth_02.
@Test
public void update_jdk_auth_02() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateExecution ue = withAuthJDK(UpdateExecutionHTTP.create().endpoint(databaseURL()).update(updates), "allowed", "bad-password");
expect401(() -> ue.execute());
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class TestAuthUpdate_JDK method update_jdk_auth_01.
@Test
public void update_jdk_auth_01() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateExecution ue = UpdateExecutionHTTP.create().endpoint(databaseURL()).update(updates).build();
// No auth credentials should result in an error
expect401(() -> ue.execute());
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class TestAuthUpdate_JDK method update_jdk_auth_03.
@Test
public void update_jdk_auth_03() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateExecution ue = withAuthJDK(UpdateExecutionHTTP.create().endpoint(databaseURL()).update(updates), "allowed", "password");
ue.execute();
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class AbstractTestRDFConnection method update_05.
@Test
public void update_05() {
UpdateRequest update = new UpdateRequest();
update.add("INSERT DATA { <urn:ex:s> <urn:ex:p> <urn:ex:o>}");
try (RDFConnection conn = connection()) {
UpdateExecutionBuilder updateBuilder = conn.newUpdate();
UpdateExecution uExec = updateBuilder.update(update).build();
Txn.executeWrite(conn, () -> uExec.execute());
}
}
Aggregations