Beispiel #1
0
        public virtual void TestDTManager()
        {
            Configuration conf = new Configuration(false);

            conf.SetLong(DelegationTokenManager.UpdateInterval, DayInSecs);
            conf.SetLong(DelegationTokenManager.MaxLifetime, DayInSecs);
            conf.SetLong(DelegationTokenManager.RenewInterval, DayInSecs);
            conf.SetLong(DelegationTokenManager.RemovalScanInterval, DayInSecs);
            conf.GetBoolean(DelegationTokenManager.EnableZkKey, enableZKKey);
            DelegationTokenManager tm = new DelegationTokenManager(conf, new Text("foo"));

            tm.Init();
            Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = (Org.Apache.Hadoop.Security.Token.Token
                                                                                        <DelegationTokenIdentifier>)tm.CreateToken(UserGroupInformation.GetCurrentUser()
                                                                                                                                   , "foo");
            NUnit.Framework.Assert.IsNotNull(token);
            tm.VerifyToken(token);
            Assert.True(tm.RenewToken(token, "foo") > Runtime.CurrentTimeMillis
                            ());
            tm.CancelToken(token, "foo");
            try
            {
                tm.VerifyToken(token);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException)
            {
            }
            catch (Exception)
            {
                //NOP
                NUnit.Framework.Assert.Fail();
            }
            tm.Destroy();
        }
Beispiel #2
0
        public virtual void InitTokenManager(Properties config)
        {
            Configuration conf = new Configuration(false);

            foreach (DictionaryEntry entry in config)
            {
                conf.Set((string)entry.Key, (string)entry.Value);
            }
            string tokenKind = conf.Get(TokenKind);

            if (tokenKind == null)
            {
                throw new ArgumentException("The configuration does not define the token kind");
            }
            tokenKind    = tokenKind.Trim();
            tokenManager = new DelegationTokenManager(conf, new Text(tokenKind));
            tokenManager.Init();
        }
Beispiel #3
0
 /// <exception cref="System.IO.IOException"/>
 public override DelegationTokenIdentifier DecodeTokenIdentifier(Org.Apache.Hadoop.Security.Token.Token
                                                                 <DelegationTokenIdentifier> token)
 {
     return(DelegationTokenManager.DecodeToken(token, tokenKind));
 }