Search in sources :

Example 11 with TCredentials

use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.

the class TCredentialsUpdatingInvocationHandlerTest method testDisallowedImpersonationForMultipleUsersNewConfig.

@Test(expected = ThriftSecurityException.class)
public void testDisallowedImpersonationForMultipleUsersNewConfig() throws Exception {
    final String proxyServer = "proxy";
    // let "otherproxy" impersonate, but not "proxy"
    cc.set(Property.INSTANCE_RPC_SASL_ALLOWED_USER_IMPERSONATION, "otherproxy1:*;otherproxy2:client1,client2");
    cc.set(Property.INSTANCE_RPC_SASL_ALLOWED_HOST_IMPERSONATION, "*;*");
    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 });
}
Also used : TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) Test(org.junit.Test)

Example 12 with TCredentials

use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.

the class CredentialsTest method roundtripThrift.

@Test
public void roundtripThrift() throws DestroyFailedException {
    Credentials creds = new Credentials("test", new PasswordToken("testing"));
    TCredentials tCreds = creds.toThrift(inst);
    Credentials roundtrip = Credentials.fromThrift(tCreds);
    assertEquals("Roundtrip through thirft changed credentials equality", creds, roundtrip);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) Credentials(org.apache.accumulo.core.client.impl.Credentials) Test(org.junit.Test)

Example 13 with TCredentials

use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.

the class CredentialsTest method testToThrift.

@Test
public void testToThrift() throws DestroyFailedException {
    // verify thrift serialization
    Credentials creds = new Credentials("test", new PasswordToken("testing"));
    TCredentials tCreds = creds.toThrift(inst);
    assertEquals("test", tCreds.getPrincipal());
    assertEquals(PasswordToken.class.getName(), tCreds.getTokenClassName());
    assertArrayEquals(AuthenticationTokenSerializer.serialize(new PasswordToken("testing")), tCreds.getToken());
    // verify that we can't serialize if it's destroyed
    creds.getToken().destroy();
    try {
        creds.toThrift(inst);
        fail();
    } catch (Exception e) {
        assertTrue(e instanceof RuntimeException);
        assertTrue(e.getCause() instanceof AccumuloSecurityException);
        assertTrue(AccumuloSecurityException.class.cast(e.getCause()).getSecurityErrorCode().equals(SecurityErrorCode.TOKEN_EXPIRED));
    }
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) Credentials(org.apache.accumulo.core.client.impl.Credentials) DestroyFailedException(javax.security.auth.DestroyFailedException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Test(org.junit.Test)

Example 14 with TCredentials

use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.

the class AccumuloReplicaSystemTest method dontSendEmptyDataToPeer.

@Test
public void dontSendEmptyDataToPeer() throws Exception {
    Client replClient = createMock(Client.class);
    AccumuloReplicaSystem ars = createMock(AccumuloReplicaSystem.class);
    WalEdits edits = new WalEdits(Collections.emptyList());
    WalReplication walReplication = new WalReplication(edits, 0, 0, 0);
    ReplicationTarget target = new ReplicationTarget("peer", "2", Table.ID.of("1"));
    DataInputStream input = null;
    Path p = new Path("/accumulo/wals/tserver+port/" + UUID.randomUUID().toString());
    Status status = null;
    long sizeLimit = Long.MAX_VALUE;
    String remoteTableId = target.getRemoteIdentifier();
    TCredentials tcreds = null;
    Set<Integer> tids = new HashSet<>();
    WalClientExecReturn walClientExec = ars.new WalClientExecReturn(target, input, p, status, sizeLimit, remoteTableId, tcreds, tids);
    expect(ars.getWalEdits(target, input, p, status, sizeLimit, tids)).andReturn(walReplication);
    replay(replClient, ars);
    ReplicationStats stats = walClientExec.execute(replClient);
    verify(replClient, ars);
    Assert.assertEquals(new ReplicationStats(0l, 0l, 0l), stats);
}
Also used : Path(org.apache.hadoop.fs.Path) Status(org.apache.accumulo.server.replication.proto.Replication.Status) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) WalReplication(org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.WalReplication) WalClientExecReturn(org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.WalClientExecReturn) DataInputStream(java.io.DataInputStream) WalEdits(org.apache.accumulo.core.replication.thrift.WalEdits) ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) ReplicationStats(org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.ReplicationStats) Client(org.apache.accumulo.core.replication.thrift.ReplicationServicer.Client) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with TCredentials

use of org.apache.accumulo.core.security.thrift.TCredentials in project accumulo by apache.

the class AccumuloReplicaSystemTest method consumedButNotSentDataShouldBeRecorded.

@Test
public void consumedButNotSentDataShouldBeRecorded() throws Exception {
    Client replClient = createMock(Client.class);
    AccumuloReplicaSystem ars = createMock(AccumuloReplicaSystem.class);
    WalEdits edits = new WalEdits(Collections.emptyList());
    WalReplication walReplication = new WalReplication(edits, 0, 5, 0);
    ReplicationTarget target = new ReplicationTarget("peer", "2", Table.ID.of("1"));
    DataInputStream input = null;
    Path p = new Path("/accumulo/wals/tserver+port/" + UUID.randomUUID().toString());
    Status status = null;
    long sizeLimit = Long.MAX_VALUE;
    String remoteTableId = target.getRemoteIdentifier();
    TCredentials tcreds = null;
    Set<Integer> tids = new HashSet<>();
    WalClientExecReturn walClientExec = ars.new WalClientExecReturn(target, input, p, status, sizeLimit, remoteTableId, tcreds, tids);
    expect(ars.getWalEdits(target, input, p, status, sizeLimit, tids)).andReturn(walReplication);
    replay(replClient, ars);
    ReplicationStats stats = walClientExec.execute(replClient);
    verify(replClient, ars);
    Assert.assertEquals(new ReplicationStats(0l, 0l, 5l), stats);
}
Also used : Path(org.apache.hadoop.fs.Path) Status(org.apache.accumulo.server.replication.proto.Replication.Status) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) WalReplication(org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.WalReplication) WalClientExecReturn(org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.WalClientExecReturn) DataInputStream(java.io.DataInputStream) WalEdits(org.apache.accumulo.core.replication.thrift.WalEdits) ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) ReplicationStats(org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.ReplicationStats) Client(org.apache.accumulo.core.replication.thrift.ReplicationServicer.Client) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

TCredentials (org.apache.accumulo.core.security.thrift.TCredentials)26 Test (org.junit.Test)21 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)13 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)6 Credentials (org.apache.accumulo.core.client.impl.Credentials)5 DataInputStream (java.io.DataInputStream)2 HashSet (java.util.HashSet)2 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)2 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)2 ReplicationTarget (org.apache.accumulo.core.replication.ReplicationTarget)2 Client (org.apache.accumulo.core.replication.thrift.ReplicationServicer.Client)2 WalEdits (org.apache.accumulo.core.replication.thrift.WalEdits)2 TInfo (org.apache.accumulo.core.trace.thrift.TInfo)2 Status (org.apache.accumulo.server.replication.proto.Replication.Status)2 ReplicationStats (org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.ReplicationStats)2 WalClientExecReturn (org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.WalClientExecReturn)2 WalReplication (org.apache.accumulo.tserver.replication.AccumuloReplicaSystem.WalReplication)2 Path (org.apache.hadoop.fs.Path)2