public virtual void TestCancelTokenSingleManager()
 {
     for (int i = 0; i < TestRetries; i++)
     {
         DelegationTokenManager tm1  = null;
         string        connectString = zkServer.GetConnectString();
         Configuration conf          = GetSecretConf(connectString);
         tm1 = new DelegationTokenManager(conf, new Text("foo"));
         tm1.Init();
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = (Org.Apache.Hadoop.Security.Token.Token
                                                                                     <DelegationTokenIdentifier>)tm1.CreateToken(UserGroupInformation.GetCurrentUser(
                                                                                                                                     ), "foo");
         NUnit.Framework.Assert.IsNotNull(token);
         tm1.CancelToken(token, "foo");
         try
         {
             VerifyTokenFail(tm1, token);
             NUnit.Framework.Assert.Fail("Expected InvalidToken");
         }
         catch (SecretManager.InvalidToken it)
         {
             Runtime.PrintStackTrace(it);
         }
         VerifyDestroy(tm1, conf);
     }
 }
 public virtual void TestMultiNodeOperations()
 {
     for (int i = 0; i < TestRetries; i++)
     {
         DelegationTokenManager tm1;
         DelegationTokenManager tm2  = null;
         string        connectString = zkServer.GetConnectString();
         Configuration conf          = GetSecretConf(connectString);
         tm1 = new DelegationTokenManager(conf, new Text("bla"));
         tm1.Init();
         tm2 = new DelegationTokenManager(conf, new Text("bla"));
         tm2.Init();
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = (Org.Apache.Hadoop.Security.Token.Token
                                                                                     <DelegationTokenIdentifier>)tm1.CreateToken(UserGroupInformation.GetCurrentUser(
                                                                                                                                     ), "foo");
         NUnit.Framework.Assert.IsNotNull(token);
         tm2.VerifyToken(token);
         tm2.RenewToken(token, "foo");
         tm1.VerifyToken(token);
         tm1.CancelToken(token, "foo");
         try
         {
             VerifyTokenFail(tm2, token);
             NUnit.Framework.Assert.Fail("Expected InvalidToken");
         }
         catch (SecretManager.InvalidToken)
         {
         }
         // Ignore
         token = (Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier>)tm2.CreateToken
                     (UserGroupInformation.GetCurrentUser(), "bar");
         NUnit.Framework.Assert.IsNotNull(token);
         tm1.VerifyToken(token);
         tm1.RenewToken(token, "bar");
         tm2.VerifyToken(token);
         tm2.CancelToken(token, "bar");
         try
         {
             VerifyTokenFail(tm1, token);
             NUnit.Framework.Assert.Fail("Expected InvalidToken");
         }
         catch (SecretManager.InvalidToken)
         {
         }
         // Ignore
         VerifyDestroy(tm1, conf);
         VerifyDestroy(tm2, conf);
     }
 }
 public virtual void TestNodeUpAferAWhile()
 {
     for (int i = 0; i < TestRetries; i++)
     {
         string                 connectString = zkServer.GetConnectString();
         Configuration          conf          = GetSecretConf(connectString);
         DelegationTokenManager tm1           = new DelegationTokenManager(conf, new Text("bla"));
         tm1.Init();
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token1 = (Org.Apache.Hadoop.Security.Token.Token
                                                                                      <DelegationTokenIdentifier>)tm1.CreateToken(UserGroupInformation.GetCurrentUser(
                                                                                                                                      ), "foo");
         NUnit.Framework.Assert.IsNotNull(token1);
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token2 = (Org.Apache.Hadoop.Security.Token.Token
                                                                                      <DelegationTokenIdentifier>)tm1.CreateToken(UserGroupInformation.GetCurrentUser(
                                                                                                                                      ), "bar");
         NUnit.Framework.Assert.IsNotNull(token2);
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token3 = (Org.Apache.Hadoop.Security.Token.Token
                                                                                      <DelegationTokenIdentifier>)tm1.CreateToken(UserGroupInformation.GetCurrentUser(
                                                                                                                                      ), "boo");
         NUnit.Framework.Assert.IsNotNull(token3);
         tm1.VerifyToken(token1);
         tm1.VerifyToken(token2);
         tm1.VerifyToken(token3);
         // Cancel one token
         tm1.CancelToken(token1, "foo");
         // Start second node after some time..
         Thread.Sleep(1000);
         DelegationTokenManager tm2 = new DelegationTokenManager(conf, new Text("bla"));
         tm2.Init();
         tm2.VerifyToken(token2);
         tm2.VerifyToken(token3);
         try
         {
             VerifyTokenFail(tm2, token1);
             NUnit.Framework.Assert.Fail("Expected InvalidToken");
         }
         catch (SecretManager.InvalidToken)
         {
         }
         // Ignore
         // Create a new token thru the new ZKDTSM
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token4 = (Org.Apache.Hadoop.Security.Token.Token
                                                                                      <DelegationTokenIdentifier>)tm2.CreateToken(UserGroupInformation.GetCurrentUser(
                                                                                                                                      ), "xyz");
         NUnit.Framework.Assert.IsNotNull(token4);
         tm2.VerifyToken(token4);
         tm1.VerifyToken(token4);
         // Bring down tm2
         VerifyDestroy(tm2, conf);
         // Start third node after some time..
         Thread.Sleep(1000);
         DelegationTokenManager tm3 = new DelegationTokenManager(conf, new Text("bla"));
         tm3.Init();
         tm3.VerifyToken(token2);
         tm3.VerifyToken(token3);
         tm3.VerifyToken(token4);
         try
         {
             VerifyTokenFail(tm3, token1);
             NUnit.Framework.Assert.Fail("Expected InvalidToken");
         }
         catch (SecretManager.InvalidToken)
         {
         }
         // Ignore
         VerifyDestroy(tm3, conf);
         VerifyDestroy(tm1, conf);
     }
 }