use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.
the class ReplicationOperationsImplIT method getReplicationOperations.
/**
* Spoof out the Master so we can call the implementation without starting a full instance.
*/
private ReplicationOperationsImpl getReplicationOperations() throws Exception {
Master master = EasyMock.createMock(Master.class);
EasyMock.expect(master.getConnector()).andReturn(conn).anyTimes();
EasyMock.expect(master.getInstance()).andReturn(inst).anyTimes();
EasyMock.replay(master);
final MasterClientServiceHandler mcsh = new MasterClientServiceHandler(master) {
@Override
protected Table.ID getTableId(Instance inst, String tableName) throws ThriftTableOperationException {
try {
return Table.ID.of(conn.tableOperations().tableIdMap().get(tableName));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
ClientContext context = new ClientContext(inst, new Credentials("root", new PasswordToken(ROOT_PASSWORD)), getClientConfig());
return new ReplicationOperationsImpl(context) {
@Override
protected boolean getMasterDrain(final TInfo tinfo, final TCredentials rpcCreds, final String tableName, final Set<String> wals) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
try {
return mcsh.drainReplicationTable(tinfo, rpcCreds, tableName, wals);
} catch (TException e) {
throw new RuntimeException(e);
}
}
};
}
use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.
the class TCredentialsUpdatingInvocationHandlerTest method testDisallowedImpersonationForMultipleUsers.
@SuppressWarnings("deprecation")
@Test(expected = ThriftSecurityException.class)
public void testDisallowedImpersonationForMultipleUsers() throws Exception {
final String proxyServer = "proxy";
// let "otherproxy" impersonate, but not "proxy"
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + "otherproxy1" + ".users", "*");
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + "otherproxy1" + ".hosts", "*");
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + "otherproxy2" + ".users", "client1,client2");
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + "otherproxy2" + ".hosts", "*");
proxy = new TCredentialsUpdatingInvocationHandler<>(new Object(), conf);
TCredentials tcreds = new TCredentials("client1", KerberosToken.class.getName(), ByteBuffer.allocate(0), UUID.randomUUID().toString());
UGIAssumingProcessor.rpcPrincipal.set(proxyServer);
proxy.updateArgs(new Object[] { new Object(), tcreds });
}
use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.
the class TCredentialsUpdatingInvocationHandlerTest method testMissingPrincipal.
@Test(expected = ThriftSecurityException.class)
public void testMissingPrincipal() throws Exception {
final String principal = "root";
TCredentials tcreds = new TCredentials(principal, KerberosToken.CLASS_NAME, ByteBuffer.allocate(0), UUID.randomUUID().toString());
UGIAssumingProcessor.rpcPrincipal.set(null);
proxy.updateArgs(new Object[] { new Object(), tcreds });
}
use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.
the class TCredentialsUpdatingInvocationHandlerTest method testDisallowedImpersonationFromSpecificHost.
@SuppressWarnings("deprecation")
@Test(expected = ThriftSecurityException.class)
public void testDisallowedImpersonationFromSpecificHost() throws Exception {
final String proxyServer = "proxy", client = "client", host = "host.domain.com";
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + proxyServer + ".users", client);
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + proxyServer + ".hosts", host);
proxy = new TCredentialsUpdatingInvocationHandler<>(new Object(), conf);
TCredentials tcreds = new TCredentials("client", KerberosToken.class.getName(), ByteBuffer.allocate(0), UUID.randomUUID().toString());
UGIAssumingProcessor.rpcPrincipal.set(proxyServer);
// The RPC came from a different host than is allowed
TServerUtils.clientAddress.set("otherhost.domain.com");
proxy.updateArgs(new Object[] { new Object(), tcreds });
}
use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.
the class TCredentialsUpdatingInvocationHandlerTest method testMismatchedPrincipal.
@Test(expected = ThriftSecurityException.class)
public void testMismatchedPrincipal() throws Exception {
final String principal = "root";
TCredentials tcreds = new TCredentials(principal, KerberosToken.CLASS_NAME, ByteBuffer.allocate(0), UUID.randomUUID().toString());
UGIAssumingProcessor.rpcPrincipal.set(principal + "foobar");
proxy.updateArgs(new Object[] { new Object(), tcreds });
}
Aggregations