Esempio n. 1
0
 public virtual void TestDelegationTokenSecretManager()
 {
     TestDelegationToken.TestDelegationTokenSecretManager dtSecretManager = new TestDelegationToken.TestDelegationTokenSecretManager
                                                                                (24 * 60 * 60 * 1000, 3 * 1000, 1 * 1000, 3600000);
     try
     {
         dtSecretManager.StartThreads();
         Org.Apache.Hadoop.Security.Token.Token <TestDelegationToken.TestDelegationTokenIdentifier
                                                 > token = GenerateDelegationToken(dtSecretManager, "SomeUser", "JobTracker");
         Assert.True(dtSecretManager.isStoreNewTokenCalled);
         // Fake renewer should not be able to renew
         ShouldThrow(new _PrivilegedExceptionAction_272(dtSecretManager, token), typeof(AccessControlException
                                                                                        ));
         long time = dtSecretManager.RenewToken(token, "JobTracker");
         Assert.True(dtSecretManager.isUpdateStoredTokenCalled);
         Assert.True("renew time is in future", time > Time.Now());
         TestDelegationToken.TestDelegationTokenIdentifier identifier = new TestDelegationToken.TestDelegationTokenIdentifier
                                                                            ();
         byte[] tokenId = token.GetIdentifier();
         identifier.ReadFields(new DataInputStream(new ByteArrayInputStream(tokenId)));
         Assert.True(null != dtSecretManager.RetrievePassword(identifier
                                                              ));
         Log.Info("Sleep to expire the token");
         Thread.Sleep(2000);
         //Token should be expired
         try
         {
             dtSecretManager.RetrievePassword(identifier);
             //Should not come here
             NUnit.Framework.Assert.Fail("Token should have expired");
         }
         catch (SecretManager.InvalidToken)
         {
         }
         //Success
         dtSecretManager.RenewToken(token, "JobTracker");
         Log.Info("Sleep beyond the max lifetime");
         Thread.Sleep(2000);
         ShouldThrow(new _PrivilegedExceptionAction_302(dtSecretManager, token), typeof(SecretManager.InvalidToken
                                                                                        ));
     }
     finally
     {
         dtSecretManager.StopThreads();
     }
 }
Esempio n. 2
0
 public virtual void TestDelegationTokenNullRenewer()
 {
     TestDelegationToken.TestDelegationTokenSecretManager dtSecretManager = new TestDelegationToken.TestDelegationTokenSecretManager
                                                                                (24 * 60 * 60 * 1000, 10 * 1000, 1 * 1000, 3600000);
     dtSecretManager.StartThreads();
     TestDelegationToken.TestDelegationTokenIdentifier dtId = new TestDelegationToken.TestDelegationTokenIdentifier
                                                                  (new Text("theuser"), null, null);
     Org.Apache.Hadoop.Security.Token.Token <TestDelegationToken.TestDelegationTokenIdentifier
                                             > token = new Org.Apache.Hadoop.Security.Token.Token <TestDelegationToken.TestDelegationTokenIdentifier
                                                                                                   >(dtId, dtSecretManager);
     Assert.True(token != null);
     try
     {
         dtSecretManager.RenewToken(token, string.Empty);
         NUnit.Framework.Assert.Fail("Renewal must not succeed");
     }
     catch (IOException)
     {
     }
 }