ConnectionConfiguration config = ConnectionConfiguration
.to("stardog")
.credentials("admin", "admin")
.server("snarl://localhost:5820");
AdminConnection adminConnection = config.connect().admin();
UserManager userManager = Preconditions.checkNotNull(adminConnection.getUserManager());
PermissionManager permissionManager = Preconditions.checkNotNull(adminConnection.getPermissionManager());
String username = "username";
String pwd = "userpass";
// - create
userManager.addUser(username, false, pwd.toCharArray());
permissionManager.addUserPerm(Permissions.create(username, ActionType.READ, CoreResourceType.DATABASE, "stardog"));
permissionManager.addUserPerm(Permissions.create(username, ActionType.WRITE, CoreResourceType.DATABASE, "stardog"));
List<String> graphs = Lists.newArrayList("http://example.org/graphOne", "http://example.org/graphTwo");
// - set READ access
permissionManager.addUserPerm(Permissions.create(username, ActionType.READ, CoreResourceType.NAMED_GRAPH, graphs));
// for (String graph : graphs) {
// permissionManager.addUserPerm(Permissions.create(username, ActionType.READ, CoreResourceType.NAMED_GRAPH, graph));
// }
// - set WRITE access
permissionManager.addUserPerm(Permissions.create(username, ActionType.WRITE, CoreResourceType.NAMED_GRAPH, graphs));
// for (String graph : graphs) {
// permissionManager.addUserPerm(Permissions.create(username, ActionType.WRITE, CoreResourceType.NAMED_GRAPH, graph));
// }
// execute update
try (Connection connection = config.credentials(username, pwd).connect()) {
String update = "INSERT DATA { " +
"GRAPH <http://example.org/graphOne> {<urn:a> <urn:b> <urn:c>} " +
"GRAPH <http://example.org/graphTwo> {<urn:x> <urn:y> <urn:z>}" +
"}";
connection.update(update).execute(); // the exception takes places at this point
}
// execute select
try (Connection connection = config.credentials(username, pwd).connect()) {
String query = "SELECT * FROM <http://example.org/graphOne> FROM <http://example.org/graphTwo> {?s ?p ?o}";
TupleQueryResult result = connection.select(query).execute();
while (result.hasNext()) {
System.out.println(result.next());
}
}
com.complexible.stardog.StardogException: User does not have access to one or more named graphs at com.complexible.stardog.protocols.client.SPECClientUtil.toStardogException(SPECClientUtil.java:86) at com.complexible.stardog.protocols.client.SPECClientUtil.toStardogException(SPECClientUtil.java:34) at com.complexible.stardog.api.impl.SPECUpdateQuery.execute(SPECUpdateQuery.java:43) at com.complexible.stardog.api.impl.SPECUpdateQuery.execute(SPECUpdateQuery.java:26) at ***** (StardogAccessControlTest.java:67)
Caused by: com.complexible.common.protocols.client.ClientException: User does not have access to one or more named graphs at com.complexible.common.protocols.client.rpc.DefaultRPCClient.get(DefaultRPCClient.java:285) at com.complexible.common.protocols.client.rpc.DefaultRPCClient.execute(DefaultRPCClient.java:261) at com.complexible.stardog.protocols.snarl.client.AbstractSNARLClient.update(AbstractSNARLClient.java:171) at com.complexible.stardog.protocols.snarl.client.AbstractSNARLClient.update(AbstractSNARLClient.java:62) at com.complexible.stardog.api.impl.SPECUpdateQuery.execute(SPECUpdateQuery.java:40) ... 2 more
Caused by: java.lang.Exception: User does not have access to one or more named graphs
--Ruben
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/FO9Iw8Egy7k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+u...@clarkparsia.com.
AdminConnection adminConnection = this.getConnectionConfiguration().connect().admin();
Boolean namedGraphSecurityEnabled = adminConnection.get(databaseName, SecurityOptions.NAMED_GRAPH_SECURITY_ENABLED);
Hi Mike!I added a precondition check to ensure that the 'security.named.graphs' flag is active for the current database, but no value is returned.
AdminConnection adminConnection = this.getConnectionConfiguration().connect().admin();
Boolean namedGraphSecurityEnabled = adminConnection.get(databaseName, SecurityOptions.NAMED_GRAPH_SECURITY_ENABLED);The value of namedGraphSecurityEnabled was null (instead of true or false).Any ideas?
adminConnection.currentStatus().get(SecurityOptions.NAMED_GRAPH_SECURITY_ENABLED)
Fair enough. But how do I retrieve this global value? The following code returns 'false', although the flag is set in the properties file:
adminConnection.currentStatus().get(SecurityOptions.NAMED_GRAPH_SECURITY_ENABLED)
Hi Michael!I tested this with the latest Stardog version (4.1) and it does not work. The release notes state that the task was done (#2862).Any ideas?
Also, is there any PasswordOptions class (to check also the 'password.length.max' & 'password.regex' values)?
AdminConnection adminConnection = connectionConfiguration.connect().admin();
boolean namedGraphSecurityEnabled = adminConnection.currentStatus().get(SecurityOptions.NAMED_GRAPH_SECURITY_ENABLED);
I'm trying to get the value of the property 'security.named.graphs' used to configure the store. The value is set to true in the stardog.properties file, however when executing this code:
AdminConnection adminConnection = connectionConfiguration.connect().admin();boolean namedGraphSecurityEnabled = adminConnection.currentStatus().get(SecurityOptions.NAMED_GRAPH_SECURITY_ENABLED);the result is false (not true as expected).