Example #1
0
 /// <exception cref="System.IO.IOException"/>
 private void InjectToken()
 {
     if (UserGroupInformation.IsSecurityEnabled())
     {
         Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = @params
                                                                                    .DelegationToken();
         token.SetKind(DelegationTokenIdentifier.HdfsDelegationKind);
         ugi.AddToken(token);
     }
 }
        /// <exception cref="System.IO.IOException"/>
        private UserGroupInformation TokenUGI()
        {
            Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = @params
                                                                                       .DelegationToken();
            ByteArrayInputStream      buf = new ByteArrayInputStream(token.GetIdentifier());
            DataInputStream           @in = new DataInputStream(buf);
            DelegationTokenIdentifier id  = new DelegationTokenIdentifier();

            id.ReadFields(@in);
            UserGroupInformation ugi = id.GetUser();

            ugi.AddToken(token);
            return(ugi);
        }
Example #3
0
        public virtual void TestDeserializeHAToken()
        {
            Configuration conf = DFSTestUtil.NewHAConfiguration(LogicalName);

            Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = new Org.Apache.Hadoop.Security.Token.Token
                                                                                       <DelegationTokenIdentifier>();
            QueryStringDecoder decoder = new QueryStringDecoder(WebHdfsHandler.WebhdfsPrefix
                                                                + "/?" + NamenodeAddressParam.Name + "=" + LogicalName + "&" + DelegationParam.Name
                                                                + "=" + token.EncodeToUrlString());
            ParameterParser testParser = new ParameterParser(decoder, conf);

            Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> tok2 = testParser
                                                                                      .DelegationToken();
            NUnit.Framework.Assert.IsTrue(HAUtil.IsTokenForLogicalUri(tok2));
        }