Search in sources :

Example 6 with TAuthenticationTokenIdentifier

use of org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier in project accumulo by apache.

the class AuthenticationTokenIdentifierTest method testExtendedEquality.

@Test
public void testExtendedEquality() {
    String principal = "user";
    var token = new AuthenticationTokenIdentifier(new TAuthenticationTokenIdentifier(principal));
    assertEquals(token, token);
    var newToken = new AuthenticationTokenIdentifier(createTAuthIdentifier(principal, 1, 5L, 10L, "uuid"));
    assertNotEquals(token, newToken);
    assertNotEquals(token.hashCode(), newToken.hashCode());
    var dblNewToken = new AuthenticationTokenIdentifier(new TAuthenticationTokenIdentifier(principal));
    dblNewToken.setKeyId(1);
    dblNewToken.setIssueDate(5L);
    dblNewToken.setExpirationDate(10L);
    dblNewToken.setInstanceId(InstanceId.of("uuid"));
}
Also used : TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) AuthenticationTokenIdentifier(org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier) Test(org.junit.jupiter.api.Test)

Example 7 with TAuthenticationTokenIdentifier

use of org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier in project accumulo by apache.

the class AuthenticationTokenIdentifierTest method testToString.

@Test
public void testToString() {
    String principal = "my_special_principal";
    var token = new AuthenticationTokenIdentifier(new TAuthenticationTokenIdentifier(principal));
    assertTrue(token.toString().contains(principal));
}
Also used : TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) AuthenticationTokenIdentifier(org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier) Test(org.junit.jupiter.api.Test)

Example 8 with TAuthenticationTokenIdentifier

use of org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier in project accumulo by apache.

the class AuthenticationTokenIdentifierTest method testUgi.

@Test
public void testUgi() {
    String principal = "user";
    var token = new AuthenticationTokenIdentifier(new TAuthenticationTokenIdentifier(principal));
    UserGroupInformation actual = token.getUser();
    UserGroupInformation expected = UserGroupInformation.createRemoteUser(principal);
    assertEquals(expected.getAuthenticationMethod(), actual.getAuthenticationMethod());
    assertEquals(expected.getUserName(), expected.getUserName());
}
Also used : TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) AuthenticationTokenIdentifier(org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.jupiter.api.Test)

Example 9 with TAuthenticationTokenIdentifier

use of org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier in project accumulo by apache.

the class AuthenticationTokenIdentifierTest method testEquality.

@Test
public void testEquality() {
    String principal = "user";
    var token = new AuthenticationTokenIdentifier(new TAuthenticationTokenIdentifier(principal));
    assertEquals(token, token);
    var newToken = new AuthenticationTokenIdentifier(new TAuthenticationTokenIdentifier(principal));
    assertEquals(token, newToken);
    assertEquals(token.hashCode(), newToken.hashCode());
}
Also used : TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) AuthenticationTokenIdentifier(org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier) Test(org.junit.jupiter.api.Test)

Example 10 with TAuthenticationTokenIdentifier

use of org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier in project accumulo by apache.

the class ThriftMessageUtilTest method testSerializationAsByteArray.

@Test
public void testSerializationAsByteArray() throws IOException {
    ByteBuffer buff = util.serialize(msg);
    TAuthenticationTokenIdentifier copy = new TAuthenticationTokenIdentifier();
    byte[] array = new byte[buff.limit()];
    System.arraycopy(buff.array(), 0, array, 0, buff.limit());
    util.deserialize(array, copy);
    assertEquals(msg, copy);
}
Also used : TAuthenticationTokenIdentifier(org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

TAuthenticationTokenIdentifier (org.apache.accumulo.core.securityImpl.thrift.TAuthenticationTokenIdentifier)12 Test (org.junit.jupiter.api.Test)8 AuthenticationTokenIdentifier (org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier)7 ByteBuffer (java.nio.ByteBuffer)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 ThriftMessageUtil (org.apache.accumulo.core.util.ThriftMessageUtil)1 Text (org.apache.hadoop.io.Text)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 Token (org.apache.hadoop.security.token.Token)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1