use of org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier in project accumulo by apache.
the class SaslConnectionParamsTest method testDelegationTokenImpl.
@Test
public void testDelegationTokenImpl() throws Exception {
final DelegationTokenImpl token = new DelegationTokenImpl(new byte[0], new AuthenticationTokenIdentifier(createTAuthIdentifier("user", 1, 10L, 20L, "instanceid")));
testUser.doAs((PrivilegedExceptionAction<Void>) () -> {
final SaslConnectionParams saslParams = createSaslParams(token);
assertEquals(primary, saslParams.getKerberosServerPrimary());
final QualityOfProtection defaultQop = QualityOfProtection.get(Property.RPC_SASL_QOP.getDefaultValue());
assertEquals(defaultQop, saslParams.getQualityOfProtection());
assertEquals(SaslMechanism.DIGEST_MD5, saslParams.getMechanism());
assertNotNull(saslParams.getCallbackHandler());
assertEquals(SaslClientDigestCallbackHandler.class, saslParams.getCallbackHandler().getClass());
Map<String, String> properties = saslParams.getSaslProperties();
assertEquals(1, properties.size());
assertEquals(defaultQop.getQuality(), properties.get(Sasl.QOP));
assertEquals(username, saslParams.getPrincipal());
return null;
});
}
use of org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier in project accumulo by apache.
the class SaslConnectionParamsTest method testEquality.
@Test
public void testEquality() throws Exception {
final KerberosToken token = EasyMock.createMock(KerberosToken.class);
SaslConnectionParams params1 = testUser.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(token));
SaslConnectionParams params2 = testUser.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(token));
assertEquals(params1, params2);
assertEquals(params1.hashCode(), params2.hashCode());
final DelegationTokenImpl delToken1 = new DelegationTokenImpl(new byte[0], new AuthenticationTokenIdentifier(createTAuthIdentifier("user", 1, 10L, 20L, "instanceid")));
SaslConnectionParams params3 = testUser.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(delToken1));
assertNotEquals(params1, params3);
assertNotEquals(params1.hashCode(), params3.hashCode());
assertNotEquals(params2, params3);
assertNotEquals(params2.hashCode(), params3.hashCode());
final DelegationTokenImpl delToken2 = new DelegationTokenImpl(new byte[0], new AuthenticationTokenIdentifier(createTAuthIdentifier("user", 1, 10L, 20L, "instanceid")));
SaslConnectionParams params4 = testUser.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(delToken2));
assertNotEquals(params1, params4);
assertNotEquals(params1.hashCode(), params4.hashCode());
assertNotEquals(params2, params4);
assertNotEquals(params2.hashCode(), params4.hashCode());
assertEquals(params3, params4);
assertEquals(params3.hashCode(), params4.hashCode());
}
use of org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier 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"));
}
use of org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier 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));
}
use of org.apache.accumulo.core.clientImpl.AuthenticationTokenIdentifier 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());
}
Aggregations