Exemple #1
0
        public virtual void TestLazyTokenFetchForWebhdfs()
        {
            // for any(Token.class)
            MiniDFSCluster    cluster = null;
            WebHdfsFileSystem fs      = null;

            try
            {
                Configuration clusterConf = new HdfsConfiguration(conf);
                SecurityUtil.SetAuthenticationMethod(UserGroupInformation.AuthenticationMethod.Simple
                                                     , clusterConf);
                clusterConf.SetBoolean(DFSConfigKeys.DfsNamenodeDelegationTokenAlwaysUseKey, true
                                       );
                // trick the NN into thinking security is enabled w/o it trying
                // to login from a keytab
                UserGroupInformation.SetConfiguration(clusterConf);
                cluster = new MiniDFSCluster.Builder(clusterConf).NumDataNodes(1).Build();
                cluster.WaitActive();
                SecurityUtil.SetAuthenticationMethod(UserGroupInformation.AuthenticationMethod.Kerberos
                                                     , clusterConf);
                UserGroupInformation.SetConfiguration(clusterConf);
                uri = DFSUtil.CreateUri("webhdfs", cluster.GetNameNode().GetHttpAddress());
                ValidateLazyTokenFetch(clusterConf);
            }
            finally
            {
                IOUtils.Cleanup(null, fs);
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
            /// <exception cref="System.Exception"/>
            public long Run()
            {
                IPEndPoint serviceAddr = SecurityUtil.GetTokenServiceAddr(token);

                return(DelegationTokenFetcher.RenewDelegationToken(this._enclosing.connectionFactory
                                                                   , DFSUtil.CreateUri(this._enclosing.GetUnderlyingProtocol(), serviceAddr), (Org.Apache.Hadoop.Security.Token.Token
                                                                                                                                               <DelegationTokenIdentifier>)token));
            }
Exemple #3
0
        public virtual void TestLazyTokenFetchForSWebhdfs()
        {
            // for any(Token.class)
            MiniDFSCluster     cluster = null;
            SWebHdfsFileSystem fs      = null;

            try
            {
                Configuration clusterConf = new HdfsConfiguration(conf);
                SecurityUtil.SetAuthenticationMethod(UserGroupInformation.AuthenticationMethod.Simple
                                                     , clusterConf);
                clusterConf.SetBoolean(DFSConfigKeys.DfsNamenodeDelegationTokenAlwaysUseKey, true
                                       );
                string Basedir = Runtime.GetProperty("test.build.dir", "target/test-dir") + "/" +
                                 typeof(TestWebHdfsTokens).Name;
                string keystoresDir;
                string sslConfDir;
                clusterConf.SetBoolean(DFSConfigKeys.DfsWebhdfsEnabledKey, true);
                clusterConf.Set(DFSConfigKeys.DfsHttpPolicyKey, HttpConfig.Policy.HttpsOnly.ToString
                                    ());
                clusterConf.Set(DFSConfigKeys.DfsNamenodeHttpsAddressKey, "localhost:0");
                clusterConf.Set(DFSConfigKeys.DfsDatanodeHttpsAddressKey, "localhost:0");
                FilePath @base = new FilePath(Basedir);
                FileUtil.FullyDelete(@base);
                @base.Mkdirs();
                keystoresDir = new FilePath(Basedir).GetAbsolutePath();
                sslConfDir   = KeyStoreTestUtil.GetClasspathDir(typeof(TestWebHdfsTokens));
                KeyStoreTestUtil.SetupSSLConfig(keystoresDir, sslConfDir, clusterConf, false);
                // trick the NN into thinking security is enabled w/o it trying
                // to login from a keytab
                UserGroupInformation.SetConfiguration(clusterConf);
                cluster = new MiniDFSCluster.Builder(clusterConf).NumDataNodes(1).Build();
                cluster.WaitActive();
                IPEndPoint addr   = cluster.GetNameNode().GetHttpsAddress();
                string     nnAddr = NetUtils.GetHostPortString(addr);
                clusterConf.Set(DFSConfigKeys.DfsNamenodeHttpsAddressKey, nnAddr);
                SecurityUtil.SetAuthenticationMethod(UserGroupInformation.AuthenticationMethod.Kerberos
                                                     , clusterConf);
                UserGroupInformation.SetConfiguration(clusterConf);
                uri = DFSUtil.CreateUri("swebhdfs", cluster.GetNameNode().GetHttpsAddress());
                ValidateLazyTokenFetch(clusterConf);
            }
            finally
            {
                IOUtils.Cleanup(null, fs);
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
 protected internal virtual URI GetNamenodeUri(URI uri)
 {
     return(DFSUtil.CreateUri(GetUnderlyingProtocol(), GetNamenodeAddr(uri)));
 }