use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.
the class ManagerApiIT method setup.
@BeforeClass
public static void setup() throws Exception {
// need to pretend to be a server, so we can bypass all of
// the singleton resource management in this test
SingletonManager.setMode(Mode.SERVER);
SharedMiniClusterBase.startMiniCluster();
rootUser = new Credentials(getPrincipal(), getToken());
regularUser = new Credentials("regularUser", new PasswordToken("regularUser"));
privilegedUser = new Credentials("privilegedUser", new PasswordToken("privilegedUser"));
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
SecurityOperations rootSecOps = client.securityOperations();
for (Credentials user : Arrays.asList(regularUser, privilegedUser)) rootSecOps.createLocalUser(user.getPrincipal(), (PasswordToken) user.getToken());
rootSecOps.grantSystemPermission(privilegedUser.getPrincipal(), SystemPermission.SYSTEM);
}
}
use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.
the class MetadataTableUtil method getRootTable.
public static synchronized Writer getRootTable(ServerContext context) {
Credentials credentials = context.getCredentials();
Writer rootTable = root_tables.get(credentials);
if (rootTable == null) {
rootTable = new Writer(context, RootTable.ID);
root_tables.put(credentials, rootTable);
}
return rootTable;
}
use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.
the class MetadataTableUtil method getMetadataTable.
public static synchronized Writer getMetadataTable(ServerContext context) {
Credentials credentials = context.getCredentials();
Writer metadataTable = metadata_tables.get(credentials);
if (metadataTable == null) {
metadataTable = new Writer(context, MetadataTable.ID);
metadata_tables.put(credentials, metadataTable);
}
return metadataTable;
}
use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.
the class ClientServiceHandler method changeLocalUserPassword.
@Override
public void changeLocalUserPassword(TInfo tinfo, TCredentials credentials, String principal, ByteBuffer password) throws ThriftSecurityException {
PasswordToken token = new PasswordToken(password);
Credentials toChange = new Credentials(principal, token);
security.changePassword(credentials, toChange);
}
use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.
the class ClientServiceHandler method createLocalUser.
@Override
public void createLocalUser(TInfo tinfo, TCredentials credentials, String principal, ByteBuffer password) throws ThriftSecurityException {
AuthenticationToken token;
if (context.getSaslParams() != null) {
try {
token = new KerberosToken();
} catch (IOException e) {
log.warn("Failed to create KerberosToken");
throw new ThriftSecurityException(e.getMessage(), SecurityErrorCode.DEFAULT_SECURITY_ERROR);
}
} else {
token = new PasswordToken(password);
}
Credentials newUser = new Credentials(principal, token);
security.createUser(credentials, newUser, new Authorizations());
}
Aggregations