Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
            /// <exception cref="System.IO.IOException"/>
            private TokenAspect.TokenManagementDelegator GetInstance <_T0>(Org.Apache.Hadoop.Security.Token.Token
                                                                           <_T0> token, Configuration conf)
                where _T0 : TokenIdentifier
            {
                URI    uri;
                string scheme = GetSchemeByKind(token.GetKind());

                if (HAUtil.IsTokenForLogicalUri(token))
                {
                    uri = HAUtil.GetServiceUriFromToken(scheme, token);
                }
                else
                {
                    IPEndPoint address = SecurityUtil.GetTokenServiceAddr(token);
                    uri = URI.Create(scheme + "://" + NetUtils.GetHostPortString(address));
                }
                return((TokenAspect.TokenManagementDelegator)FileSystem.Get(uri, conf));
            }