Пример #1
0
        public virtual void TestEncryptedReadWithRC4()
        {
            MiniDFSCluster cluster = null;

            try
            {
                Configuration conf = new Configuration();
                cluster = new MiniDFSCluster.Builder(conf).Build();
                FileSystem fs = GetFileSystem(conf);
                WriteTestDataToFile(fs);
                NUnit.Framework.Assert.AreEqual(PlainText, DFSTestUtil.ReadFile(fs, TestPath));
                FileChecksum checksum = fs.GetFileChecksum(TestPath);
                fs.Close();
                cluster.Shutdown();
                SetEncryptionConfigKeys(conf);
                // It'll use 3DES by default, but we set it to rc4 here.
                conf.Set(DFSConfigKeys.DfsDataEncryptionAlgorithmKey, "rc4");
                cluster = new MiniDFSCluster.Builder(conf).ManageDataDfsDirs(false).ManageNameDfsDirs
                              (false).Format(false).StartupOption(HdfsServerConstants.StartupOption.Regular).Build
                              ();
                fs = GetFileSystem(conf);
                GenericTestUtils.LogCapturer logs = GenericTestUtils.LogCapturer.CaptureLogs(LogFactory
                                                                                             .GetLog(typeof(SaslDataTransferServer)));
                GenericTestUtils.LogCapturer logs1 = GenericTestUtils.LogCapturer.CaptureLogs(LogFactory
                                                                                              .GetLog(typeof(DataTransferSaslUtil)));
                try
                {
                    NUnit.Framework.Assert.AreEqual(PlainText, DFSTestUtil.ReadFile(fs, TestPath));
                    NUnit.Framework.Assert.AreEqual(checksum, fs.GetFileChecksum(TestPath));
                }
                finally
                {
                    logs.StopCapturing();
                    logs1.StopCapturing();
                }
                fs.Close();
                if (resolverClazz == null)
                {
                    // Test client and server negotiate cipher option
                    GenericTestUtils.AssertDoesNotMatch(logs.GetOutput(), "Server using cipher suite"
                                                        );
                    // Check the IOStreamPair
                    GenericTestUtils.AssertDoesNotMatch(logs1.GetOutput(), "Creating IOStreamPair of CryptoInputStream and CryptoOutputStream."
                                                        );
                }
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        private void TestEncryptedWrite(int numDns)
        {
            MiniDFSCluster cluster = null;

            try
            {
                Configuration conf = new Configuration();
                SetEncryptionConfigKeys(conf);
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(numDns).Build();
                FileSystem fs = GetFileSystem(conf);
                GenericTestUtils.LogCapturer logs = GenericTestUtils.LogCapturer.CaptureLogs(LogFactory
                                                                                             .GetLog(typeof(SaslDataTransferServer)));
                GenericTestUtils.LogCapturer logs1 = GenericTestUtils.LogCapturer.CaptureLogs(LogFactory
                                                                                              .GetLog(typeof(DataTransferSaslUtil)));
                try
                {
                    WriteTestDataToFile(fs);
                }
                finally
                {
                    logs.StopCapturing();
                    logs1.StopCapturing();
                }
                NUnit.Framework.Assert.AreEqual(PlainText, DFSTestUtil.ReadFile(fs, TestPath));
                fs.Close();
                if (resolverClazz == null)
                {
                    // Test client and server negotiate cipher option
                    GenericTestUtils.AssertDoesNotMatch(logs.GetOutput(), "Server using cipher suite"
                                                        );
                    // Check the IOStreamPair
                    GenericTestUtils.AssertDoesNotMatch(logs1.GetOutput(), "Creating IOStreamPair of CryptoInputStream and CryptoOutputStream."
                                                        );
                }
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }