use of org.apache.jena.web.AuthSetup in project jena by apache.
the class TestPasswdOnly method passwd_user_bad.
@Test
public void passwd_user_bad() {
AuthSetup auth1 = new AuthSetup("localhost", port, "user99", "pw1", null);
expectQuery401(() -> {
LibSec.withAuth("http://localhost:" + port + "/db", auth1, conn -> {
conn.queryAsk("ASK{}");
});
});
}
use of org.apache.jena.web.AuthSetup in project jena by apache.
the class TestSecurityBuilderSetup method beforeClass.
@BeforeClass
public static void beforeClass() {
int port = WebLib.choosePort();
authSetup1 = new AuthSetup("localhost", port, "user1", "pw1", "TripleStore");
authSetup2 = new AuthSetup("localhost", port, "user2", "pw2", "TripleStore");
authSetupX = new AuthSetup("localhost", port, "userX", "pwX", "TripleStore");
// Two authorized users.
UserStore userStore = new UserStore();
JettyLib.addUser(userStore, authSetup1.user, authSetup1.password);
JettyLib.addUser(userStore, authSetup2.user, authSetup2.password);
try {
userStore.start();
} catch (Exception ex) {
throw new RuntimeException("UserStore", ex);
}
ConstraintSecurityHandler sh = JettyLib.makeSecurityHandler(authSetup1.realm, userStore);
// Secure these areas.
// User needs to be logged in.
JettyLib.addPathConstraint(sh, "/ds");
// Allow auth control even through there isn't anything there
JettyLib.addPathConstraint(sh, "/nowhere");
// user1 only.
JettyLib.addPathConstraint(sh, "/ctl");
// Not controlled: "/open"
AuthPolicy reqAuth = Auth.policyAllowSpecific("user1");
DataService dSrv = DataService.newBuilder(DatasetGraphFactory.createTxnMem()).withStdServices(false).setAuthPolicy(reqAuth).build();
fusekiServer = FusekiServer.create().port(port).add("/ds", DatasetFactory.createTxnMem()).add("/open", DatasetFactory.createTxnMem()).add("/ctl", dSrv).securityHandler(sh).build();
fusekiServer.start();
serverURL = fusekiServer.serverURL();
}
use of org.apache.jena.web.AuthSetup in project jena by apache.
the class TestPasswdOnly method passwd_user1.
@Test
public void passwd_user1() {
// Works!
AuthSetup auth1 = new AuthSetup("localhost", port, "user1", "pw1", null);
expectOK(() -> {
LibSec.withAuth("http://localhost:" + port + "/db", auth1, conn -> {
conn.queryAsk("ASK{}");
});
});
}
Aggregations