use of org.apache.accumulo.core.client.admin.SecurityOperations in project incubator-rya by apache.
the class Upgrade322ToolTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
final String spoTable = tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
final String poTable = tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
final String ospTable = tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
connector.tableOperations().create(spoTable);
connector.tableOperations().create(poTable);
connector.tableOperations().create(ospTable);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
SecurityOperations secOps = connector.securityOperations();
secOps.createUser(user, pwd.getBytes(), auths);
secOps.grantTablePermission(user, spoTable, TablePermission.READ);
secOps.grantTablePermission(user, poTable, TablePermission.READ);
secOps.grantTablePermission(user, ospTable, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
// load data
final BatchWriter ospWriter = connector.createBatchWriter(ospTable, new BatchWriterConfig());
ospWriter.addMutation(getMutation("00000000000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010/tracked-data-provenance/ns#longLit\u0001\u0004"));
ospWriter.addMutation(getMutation("00000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#intLit\u0001\u0005"));
ospWriter.addMutation(getMutation("00000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#byteLit\u0001\t"));
ospWriter.addMutation(getMutation("00001 1.0\u0000http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#doubleLit\u0001\u0006"));
ospWriter.addMutation(getMutation("10\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0000http" + "://here/2010/tracked-data-provenance/ns#shortLit\u0001http://www.w3" + ".org/2001/XMLSchema#short\u0001\b"));
ospWriter.addMutation(getMutation("10.0\u0000http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#floatLit\u0001http" + "://www.w3.org/2001/XMLSchema#float\u0001\b"));
ospWriter.addMutation(getMutation("3.0.0\u0000urn:org.apache.rya/2012/05#rts\u0000urn:org.apache" + ".rya/2012/05#version\u0001\u0003"));
ospWriter.addMutation(getMutation("9223370726404375807\u0000http://here/2010/tracked-data-provenance/ns" + "#uuid10\u0000http://here/2010/tracked-data-provenance/ns#dateLit" + "\u0001\u0007"));
ospWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#Created\u0000http://here" + "/2010/tracked-data-provenance/ns#uuid10\u0000http://www.w3" + ".org/1999/02/22-rdf-syntax-ns#type\u0001\u0002"));
ospWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#objectuuid1\u0000http" + "://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010" + "/tracked-data-provenance/ns#uriLit\u0001\u0002"));
ospWriter.addMutation(getMutation("stringLit\u0000http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#stringLit\u0001" + "\u0003"));
ospWriter.addMutation(getMutation("true\u0000http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#booleanLit\u0001\n"));
ospWriter.flush();
ospWriter.close();
final BatchWriter spoWriter = connector.createBatchWriter(spoTable, new BatchWriterConfig());
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010/tracked-data-provenance/ns#longLit\u000000000000000000000010\u0001\u0004"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#intLit\u000000000000010\u0001\u0005"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#byteLit\u000000000010\u0001\t"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#doubleLit\u000000001 1.0\u0001\u0006"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10\u0000http" + "://here/2010/tracked-data-provenance/ns#shortLit\u000010\u0001http://www.w3" + ".org/2001/XMLSchema#short\u0001\b"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#floatLit\u0001http" + "://www.w3.org/2001/XMLSchema#float\u000010.0\u0001\b"));
spoWriter.addMutation(getMutation("urn:org.apache.rya/2012/05#rts\u0000urn:org.apache" + ".rya/2012/05#version\u00003.0.0\u0001\u0003"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns" + "#uuid10\u0000http://here/2010/tracked-data-provenance/ns#dateLit" + "\u00009223370726404375807\u0001\u0007"));
spoWriter.addMutation(getMutation("http://here" + "/2010/tracked-data-provenance/ns#uuid10\u0000http://www.w3" + ".org/1999/02/22-rdf-syntax-ns#type\u0000http://here/2010/tracked-data-provenance/ns#Created\u0001\u0002"));
spoWriter.addMutation(getMutation("http" + "://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010" + "/tracked-data-provenance/ns#uriLit\u0000http://here/2010/tracked-data-provenance/ns#objectuuid1\u0001\u0002"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#stringLit\u0000stringLit\u0001" + "\u0003"));
spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" + "\u0000http://here/2010/tracked-data-provenance/ns#booleanLit\u0000true\u0001\n"));
spoWriter.flush();
spoWriter.close();
final BatchWriter poWriter = connector.createBatchWriter(poTable, new BatchWriterConfig());
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#longLit\u000000000000000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0004"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#intLit\u000000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0005"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#byteLit\u000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\t"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#doubleLit\u000000001 1.0\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0006"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#shortLit\u000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001http://www.w3" + ".org/2001/XMLSchema#short\u0001\b"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#floatLit\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001http" + "://www.w3.org/2001/XMLSchema#float\u000010.0\u0001\b"));
poWriter.addMutation(getMutation("urn:org.apache" + ".rya/2012/05#version\u00003.0.0\u0000urn:org.apache.rya/2012/05#rts\u0001\u0003"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#dateLit" + "\u00009223370726404375807\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0007"));
poWriter.addMutation(getMutation("http://www.w3" + ".org/1999/02/22-rdf-syntax-ns#type\u0000http://here/2010/tracked-data-provenance/ns#Created\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0002"));
poWriter.addMutation(getMutation("http://here/2010" + "/tracked-data-provenance/ns#uriLit\u0000http://here/2010/tracked-data-provenance/ns#objectuuid1\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0002"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#stringLit\u0000stringLit\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001" + "\u0003"));
poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#booleanLit\u0000true\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\n"));
poWriter.flush();
poWriter.close();
}
use of org.apache.accumulo.core.client.admin.SecurityOperations in project incubator-rya by apache.
the class AccumuloRdfCountToolTest method setUp.
@Before
public void setUp() throws Exception {
connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
SecurityOperations secOps = connector.securityOperations();
secOps.createUser(user, pwd.getBytes(), auths);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
dao = new AccumuloRyaDAO();
dao.setConnector(connector);
conf.setTablePrefix(tablePrefix);
dao.setConf(conf);
dao.init();
}
use of org.apache.accumulo.core.client.admin.SecurityOperations in project incubator-rya by apache.
the class AccumuloListInstancesIT method setup.
@Before
public void setup() throws Exception {
// this is a bit of a hack to clear any existing instances before
// adding the instances we want to exist for testing the list command
final TableOperations tableOps = getConnector().tableOperations();
final SecurityOperations secOps = getConnector().securityOperations();
secOps.grantSystemPermission("root", SystemPermission.DROP_TABLE);
for (final String tableName : getConnector().tableOperations().list()) {
if (!tableName.startsWith("accumulo.")) {
tableOps.delete(tableName);
}
}
}
use of org.apache.accumulo.core.client.admin.SecurityOperations in project incubator-rya by apache.
the class AccumuloRemoveUserIT method removedUserCanNotInsert.
/**
* Ensure a user that has been removed from the Rya instance can not interact with it.
*/
@Test
public void removedUserCanNotInsert() throws Exception {
final String adminUser = testInstance.createUniqueUser();
final String user = testInstance.createUniqueUser();
final SecurityOperations secOps = super.getConnector().securityOperations();
// Create the user that will install the instance of Rya.
secOps.createLocalUser(adminUser, new PasswordToken(adminUser));
secOps.grantSystemPermission(adminUser, SystemPermission.CREATE_TABLE);
final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(adminUser, adminUser.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(adminUser, adminUser));
// Create the user that will be added to the instance of Rya.
secOps.createLocalUser(user, new PasswordToken(user));
final RyaClient userCClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(user, user.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(user, user));
// Install the instance of Rya.
userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
// Add userC.
userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
// Remove userA.
userCClient.getRemoveUser().get().removeUser(getRyaInstanceName(), adminUser);
// Show that userA can not insert anything.
boolean securityExceptionThrown = false;
Sail sail = null;
SailConnection sailConn = null;
try {
final AccumuloRdfConfiguration userAConf = makeRyaConfig(getRyaInstanceName(), adminUser, adminUser, getInstanceName(), getZookeepers());
sail = RyaSailFactory.getInstance(userAConf);
sailConn = sail.getConnection();
final ValueFactory vf = sail.getValueFactory();
sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"));
} catch (final RuntimeException e) {
final Throwable cause = e.getCause();
if (cause instanceof AccumuloSecurityException) {
securityExceptionThrown = true;
}
} finally {
if (sailConn != null) {
sailConn.close();
}
if (sail != null) {
sail.shutDown();
}
}
assertTrue(securityExceptionThrown);
}
use of org.apache.accumulo.core.client.admin.SecurityOperations in project incubator-rya by apache.
the class CopyToolTest method testImportDirectoryTool.
@Test
public void testImportDirectoryTool() throws Exception {
log.info("");
log.info("Setting up initial state of parent before importing directory to child...");
log.info("Adding data to parent...");
log.info("Starting import directory tool. Importing all data after the specified start time: " + YESTERDAY);
log.info("");
isImporting = true;
copyToolRun(YESTERDAY);
// Import Directory Tool made child instance so hook the tables and dao into the driver.
final String childUser = accumuloDualInstanceDriver.getChildUser();
final Connector childConnector = ConfigUtils.getConnector(childConfig);
accumuloDualInstanceDriver.getChildAccumuloInstanceDriver().setConnector(childConnector);
accumuloDualInstanceDriver.getChildAccumuloInstanceDriver().setUpTables();
accumuloDualInstanceDriver.getChildAccumuloInstanceDriver().setUpDao();
// Update child config to include changes made from import directory process
final SecurityOperations childSecOps = accumuloDualInstanceDriver.getChildSecOps();
final Authorizations newChildAuths = AccumuloRyaUtils.addUserAuths(childUser, childSecOps, PARENT_AUTH);
childSecOps.changeUserAuthorizations(childUser, newChildAuths);
final String childAuthString = newChildAuths.toString();
final List<String> duplicateKeys = MergeTool.DUPLICATE_KEY_MAP.get(MRUtils.AC_AUTH_PROP);
childConfig.set(MRUtils.AC_AUTH_PROP, childAuthString);
for (final String key : duplicateKeys) {
childConfig.set(key, childAuthString);
}
// AccumuloRyaUtils.printTablePretty(CHILD_TABLE_PREFIX + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, childConfig);
// AccumuloRyaUtils.printTablePretty(CHILD_TABLE_PREFIX + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, childConfig);
AccumuloRyaUtils.printTablePretty(CHILD_TABLE_PREFIX + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, childConfig);
final Scanner scanner = AccumuloRyaUtils.getScanner(CHILD_TABLE_PREFIX + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, childConfig);
final Iterator<Entry<Key, Value>> iterator = scanner.iterator();
int count = 0;
while (iterator.hasNext()) {
iterator.next();
count++;
}
log.info("");
log.info("Total rows imported: " + count);
log.info("");
assertEquals(20, count);
log.info("DONE");
}
Aggregations