use of org.apache.accumulo.core.security.TablePermission in project incubator-rya by apache.
the class AccumuloInstanceDriver method setUpTables.
/**
* Sets up all the tables and indices.
* @throws Exception
*/
public void setUpTables() throws Exception {
// Setup tables and permissions
log.info("Setting up " + driverName + " tables and permissions");
for (final String tableSuffix : TABLE_NAME_SUFFIXES) {
final String tableName = tablePrefix + tableSuffix;
tableList.add(tableName);
if (!connector.tableOperations().exists(tableName)) {
connector.tableOperations().create(tableName);
}
}
if (shouldCreateIndices) {
indices = Arrays.asList();
tableList.addAll(indices);
log.info("Setting up " + driverName + " indices");
for (final String index : indices) {
if (!connector.tableOperations().exists(index)) {
connector.tableOperations().create(index);
}
}
}
// Setup user with authorizations
log.info("Creating " + driverName + " user and authorizations");
secOps = connector.securityOperations();
if (!user.equals(ROOT_USER_NAME)) {
secOps.createLocalUser(user, new PasswordToken(userpwd));
}
addAuths(auth);
final TablePermission tablePermission = isReadOnly ? TablePermission.READ : TablePermission.WRITE;
for (final String tableSuffix : TABLE_NAME_SUFFIXES) {
log.info("Giving user: " + user + " " + tablePermission.toString() + " permissions on table " + tablePrefix + tableSuffix);
secOps.grantTablePermission(user, tablePrefix + tableSuffix, tablePermission);
}
if (shouldCreateIndices) {
for (final String index : indices) {
log.info("Giving user: " + user + " " + tablePermission.toString() + " permissions on table " + index);
secOps.grantTablePermission(user, index, tablePermission);
}
}
}
use of org.apache.accumulo.core.security.TablePermission in project incubator-rya by apache.
the class AccumuloInstanceDriver method setUpTables.
/**
* Sets up all the tables and indices.
* @throws Exception
*/
public void setUpTables() throws Exception {
// Setup tables and permissions
log.info("Setting up " + driverName + " tables and permissions");
for (final String tableSuffix : TABLE_NAME_SUFFIXES) {
final String tableName = tablePrefix + tableSuffix;
tableList.add(tableName);
if (!connector.tableOperations().exists(tableName)) {
connector.tableOperations().create(tableName);
}
}
if (shouldCreateIndices) {
indices = Arrays.asList();
tableList.addAll(indices);
log.info("Setting up " + driverName + " indices");
for (final String index : indices) {
if (!connector.tableOperations().exists(index)) {
connector.tableOperations().create(index);
}
}
}
// Setup user with authorizations
log.info("Creating " + driverName + " user and authorizations");
secOps = connector.securityOperations();
if (!user.equals(ROOT_USER_NAME)) {
secOps.createLocalUser(user, new PasswordToken(userpwd));
}
addAuths(auth);
final TablePermission tablePermission = isReadOnly ? TablePermission.READ : TablePermission.WRITE;
for (final String tableSuffix : TABLE_NAME_SUFFIXES) {
secOps.grantTablePermission(user, tablePrefix + tableSuffix, tablePermission);
}
if (shouldCreateIndices) {
for (final String index : indices) {
secOps.grantTablePermission(user, index, tablePermission);
}
}
}
use of org.apache.accumulo.core.security.TablePermission in project accumulo by apache.
the class ZKAuthenticatorTest method testTableConversion.
public void testTableConversion() {
Set<TablePermission> perms = new TreeSet<>();
for (TablePermission s : TablePermission.values()) perms.add(s);
Set<TablePermission> converted = ZKSecurityTool.convertTablePermissions(ZKSecurityTool.convertTablePermissions(perms));
assertTrue(perms.size() == converted.size());
for (TablePermission s : perms) assertTrue(converted.contains(s));
}
use of org.apache.accumulo.core.security.TablePermission in project accumulo by apache.
the class MockSecurityOperations method revokeTablePermission.
@Override
public void revokeTablePermission(String principal, String tableName, TablePermission permission) throws AccumuloException, AccumuloSecurityException {
if (acu.users.get(principal) == null)
throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
MockTable table = acu.tables.get(tableName);
if (table == null)
throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
EnumSet<TablePermission> perms = table.userPermissions.get(principal);
if (perms != null)
perms.remove(permission);
}
use of org.apache.accumulo.core.security.TablePermission in project accumulo by apache.
the class Admin method printUserConfiguration.
private static void printUserConfiguration(Connector connector, String user, File outputDirectory) throws IOException, AccumuloException, AccumuloSecurityException {
File userScript = new File(outputDirectory, user + USER_FILE_SUFFIX);
FileWriter userWriter = new FileWriter(userScript);
userWriter.write(createUserFormat.format(new String[] { user }));
Authorizations auths = connector.securityOperations().getUserAuthorizations(user);
userWriter.write(userAuthsFormat.format(new String[] { user, auths.toString() }));
for (SystemPermission sp : SystemPermission.values()) {
if (connector.securityOperations().hasSystemPermission(user, sp)) {
userWriter.write(sysPermFormat.format(new String[] { sp.name(), user }));
}
}
for (String namespace : connector.namespaceOperations().list()) {
for (NamespacePermission np : NamespacePermission.values()) {
if (connector.securityOperations().hasNamespacePermission(user, namespace, np)) {
userWriter.write(nsPermFormat.format(new String[] { np.name(), namespace, user }));
}
}
}
for (String tableName : connector.tableOperations().list()) {
for (TablePermission perm : TablePermission.values()) {
if (connector.securityOperations().hasTablePermission(user, tableName, perm)) {
userWriter.write(tablePermFormat.format(new String[] { perm.name(), tableName, user }));
}
}
}
userWriter.close();
}
Aggregations