Пример #1
0
        /// <summary>Sets up the KDC and a set of principals in the JAAS file</summary>
        /// <exception cref="System.Exception"/>
        public static void SetupKDCAndPrincipals()
        {
            // set up the KDC
            FilePath target = new FilePath(Runtime.GetProperty("test.dir", "target"));

            kdcWorkDir = new FilePath(target, "kdc");
            kdcWorkDir.Mkdirs();
            if (!kdcWorkDir.Mkdirs())
            {
                NUnit.Framework.Assert.IsTrue(kdcWorkDir.IsDirectory());
            }
            kdcConf = MiniKdc.CreateConf();
            kdcConf.SetProperty(MiniKdc.Debug, "true");
            kdc = new MiniKdc(kdcConf, kdcWorkDir);
            kdc.Start();
            keytab_zk         = CreateKeytab(Zookeeper, "zookeeper.keytab");
            keytab_alice      = CreateKeytab(Alice, "alice.keytab");
            keytab_bob        = CreateKeytab(Bob, "bob.keytab");
            zkServerPrincipal = Shell.Windows ? Zookeeper1270001 : ZookeeperLocalhost;
            StringBuilder jaas = new StringBuilder(1024);

            jaas.Append(registrySecurity.CreateJAASEntry(ZookeeperClientContext, Zookeeper, keytab_zk
                                                         ));
            jaas.Append(registrySecurity.CreateJAASEntry(ZookeeperServerContext, zkServerPrincipal
                                                         , keytab_zk));
            jaas.Append(registrySecurity.CreateJAASEntry(AliceClientContext, AliceLocalhost,
                                                         keytab_alice));
            jaas.Append(registrySecurity.CreateJAASEntry(BobClientContext, BobLocalhost, keytab_bob
                                                         ));
            jaasFile = new FilePath(kdcWorkDir, "jaas.txt");
            FileUtils.Write(jaasFile, jaas.ToString());
            Log.Info("\n" + jaas);
            RegistrySecurity.BindJVMtoJAASFile(jaasFile);
        }
Пример #2
0
 public static void BeforeSecureRegistryTestClass()
 {
     registrySecurity = new RegistrySecurity("registrySecurity");
     registrySecurity.Init(Conf);
     SetupKDCAndPrincipals();
     RegistrySecurity.ClearJaasSystemProperties();
     RegistrySecurity.BindJVMtoJAASFile(jaasFile);
     InitHadoopSecurity();
 }
Пример #3
0
        public virtual void TestJaasFileBinding()
        {
            // the JVM has seemed inconsistent on setting up here
            NUnit.Framework.Assert.IsNotNull("jaasFile", jaasFile);
            RegistrySecurity.BindJVMtoJAASFile(jaasFile);
            string confFilename = Runtime.GetProperty(Environment.JaasConfKey);

            NUnit.Framework.Assert.AreEqual(jaasFile.GetAbsolutePath(), confFilename);
        }