use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.
the class RdfFileInputToolTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
connector = new MockInstance(instance).getConnector(user, new PasswordToken(pwd));
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.createLocalUser(user, new PasswordToken(pwd));
secOps.changeUserAuthorizations(user, 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);
}
use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.
the class PcjVisibilityIT method setupTestUsers.
private void setupTestUsers(final Connector accumuloConn, final String ryaInstanceName, final String pcjId) throws AccumuloException, AccumuloSecurityException {
final PasswordToken pass = new PasswordToken("password");
final SecurityOperations secOps = accumuloConn.securityOperations();
// We need the table name so that we can update security for the users.
final String pcjTableName = new PcjTableNameFactory().makeTableName(ryaInstanceName, pcjId);
// Give the 'roor' user authorizations to see everything.
secOps.changeUserAuthorizations("root", new Authorizations("A", "B", "C", "D", "E"));
// Create a user that can see things with A and B.
secOps.createLocalUser("abUser", pass);
secOps.changeUserAuthorizations("abUser", new Authorizations("A", "B"));
secOps.grantTablePermission("abUser", pcjTableName, TablePermission.READ);
// Create a user that can see things with A, B, and C.
secOps.createLocalUser("abcUser", pass);
secOps.changeUserAuthorizations("abcUser", new Authorizations("A", "B", "C"));
secOps.grantTablePermission("abcUser", pcjTableName, TablePermission.READ);
// Create a user that can see things with A, D, and E.
secOps.createLocalUser("adeUser", pass);
secOps.changeUserAuthorizations("adeUser", new Authorizations("A", "D", "E"));
secOps.grantTablePermission("adeUser", pcjTableName, TablePermission.READ);
// Create a user that can't see anything.
secOps.createLocalUser("noAuth", pass);
secOps.changeUserAuthorizations("noAuth", new Authorizations());
secOps.grantTablePermission("noAuth", pcjTableName, TablePermission.READ);
}
use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.
the class PcjAdminClient method createAccumuloConnector.
private static Connector createAccumuloConnector(final PcjAdminClientProperties clientProps) throws AccumuloException, AccumuloSecurityException {
checkNotNull(clientProps);
// Connect to the Zookeepers.
final String instanceName = clientProps.getAccumuloInstance();
final String zooServers = clientProps.getAccumuloZookeepers();
final Instance inst = new ZooKeeperInstance(instanceName, zooServers);
// Create a connector to the Accumulo that hosts the PCJ export tables.
return inst.getConnector(clientProps.getAccumuloUsername(), new PasswordToken(clientProps.getAccumuloPassword()));
}
use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.
the class PeriodicBindingSetExporterFactory method build.
@Override
public Optional<IncrementalResultExporter> build(Context context) throws IncrementalExporterFactoryException, ConfigurationException {
checkNotNull(context);
// Wrap the context's parameters for parsing.
final RyaExportParameters params = new RyaExportParameters(context.getObserverConfiguration().toMap());
if (params.getUsePeriodicBindingSetExporter()) {
// Setup Zookeeper connection info.
final String accumuloInstance = params.getAccumuloInstanceName().get();
final String zookeeperServers = params.getZookeeperServers().get().replaceAll(";", ",");
final Instance inst = new ZooKeeperInstance(accumuloInstance, zookeeperServers);
try {
// Setup Accumulo connection info.
final String exporterUsername = params.getExporterUsername().get();
final String exporterPassword = params.getExporterPassword().get();
final Connector accumuloConn = inst.getConnector(exporterUsername, new PasswordToken(exporterPassword));
// Setup Rya PCJ Storage.
final String ryaInstanceName = params.getRyaInstanceName().get();
final PeriodicQueryResultStorage periodicStorage = new AccumuloPeriodicQueryResultStorage(accumuloConn, ryaInstanceName);
// Make the exporter.
final IncrementalBindingSetExporter exporter = new PeriodicBindingSetExporter(periodicStorage);
return Optional.of(exporter);
} catch (final AccumuloException | AccumuloSecurityException e) {
throw new IncrementalExporterFactoryException("Could not initialize the Accumulo connector using the provided configuration.", e);
}
} else {
return Optional.absent();
}
}
use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.
the class ConnectorFactory method connect.
/**
* Create a {@link Connector} that connects to an Accumulo instance. The {@link AccumuloRdfConfiguration#USE_MOCK_INSTANCE}
* flag must be set if the configuration information needs to connect to a mock instance of Accumulo. If this is
* the case, then the Zookeepers information should not be set.
*
* @param config - The configuration that will be used to initialize the connector. (not null)
* @return The {@link Connector} that was created by {@code config}.
* @throws AccumuloException The connector couldn't be created because of an Accumulo problem.
* @throws AccumuloSecurityException The connector couldn't be created because of an Accumulo security violation.
*/
public static Connector connect(AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException {
requireNonNull(config);
// Wrap the configuration as the Accumulo configuration so that we may have access
// to Accumulo specific configuration values.
final AccumuloRdfConfiguration accConf = new AccumuloRdfConfiguration(config);
// Create the Mock or Zookeeper backed Instance depending on the configuration.
final Instance instance;
if (accConf.useMockInstance()) {
instance = new MockInstance(accConf.getInstanceName());
} else {
instance = new ZooKeeperInstance(accConf.getInstanceName(), accConf.getZookeepers());
}
// Return a connector using the configured username and password.
return instance.getConnector(accConf.getUsername(), new PasswordToken(accConf.getPassword()));
}
Aggregations