// Obtain the needed AMRMTokenIdentifier from the remote-UGI. RPC layer // currently sets only the required id, but iterate through anyways just to be // sure. /// <exception cref="System.IO.IOException"/> private AMRMTokenIdentifier SelectAMRMTokenIdentifier(UserGroupInformation remoteUgi ) { AMRMTokenIdentifier result = null; ICollection <TokenIdentifier> tokenIds = remoteUgi.GetTokenIdentifiers(); foreach (TokenIdentifier tokenId in tokenIds) { if (tokenId is AMRMTokenIdentifier) { result = (AMRMTokenIdentifier)tokenId; break; } } return(result); }
/// <exception cref="System.Exception"/> public virtual void TestTokenIdentifiers() { UserGroupInformation ugi = UserGroupInformation.CreateUserForTesting("TheDoctor", new string[] { "TheTARDIS" }); TokenIdentifier t1 = Org.Mockito.Mockito.Mock <TokenIdentifier>(); TokenIdentifier t2 = Org.Mockito.Mockito.Mock <TokenIdentifier>(); ugi.AddTokenIdentifier(t1); ugi.AddTokenIdentifier(t2); ICollection <TokenIdentifier> z = ugi.GetTokenIdentifiers(); Assert.True(z.Contains(t1)); Assert.True(z.Contains(t2)); Assert.Equal(2, z.Count); // ensure that the token identifiers are passed through doAs ICollection <TokenIdentifier> otherSet = ugi.DoAs(new _PrivilegedExceptionAction_639 ()); Assert.True(otherSet.Contains(t1)); Assert.True(otherSet.Contains(t2)); Assert.Equal(2, otherSet.Count); }