Esempio n. 1
0
        public void TestDigest()
        {
            WindowsAuthIdentity identity = new WindowsAuthIdentity();

            identity.Username = _testUser.usri1_name;
            identity.Domain   = _computerName;
            identity.Password = _testUser.usri1_password;

            string package = "WDigest";
            WindowsAuthProviderImpl provider    = new WindowsAuthProviderImpl();
            WindowsSecurityContext  initContext = WindowsSecurityContext.Get(package,
                                                                             "http://localhost", identity, 0, 0);
            IWindowsSecurityContext continueContext = initContext;
            IWindowsSecurityContext responseContext = null;
            string connectionId = Guid.NewGuid().ToString();

            do
            {
                responseContext = provider.AcceptSecurityToken(connectionId, continueContext.Token, package, 0, 0);
                if (responseContext.Token != null)
                {
                    Console.WriteLine("  Token: {0}", Convert.ToBase64String(responseContext.Token));
                    Console.WriteLine("  Continue: {0}", responseContext.Continue);
                }
                continueContext = new WindowsSecurityContext(initContext, responseContext.Token, 0, 0);
            } while (responseContext.Continue);

            Assert.IsFalse(responseContext.Continue);
            Console.WriteLine(responseContext.Identity.Fqn);
        }
        public void TestDigest()
        {
            WindowsAuthIdentity identity = new WindowsAuthIdentity();
            identity.Username = _testUser.usri1_name;
            identity.Domain = _computerName;
            identity.Password = _testUser.usri1_password;

            string package = "WDigest";
            WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
            WindowsSecurityContext initContext = WindowsSecurityContext.Get(package,
                "http://localhost", identity, 0, 0);
            IWindowsSecurityContext continueContext = initContext;
            IWindowsSecurityContext responseContext = null;
            string connectionId = Guid.NewGuid().ToString();
            do
            {
                responseContext = provider.AcceptSecurityToken(connectionId, continueContext.Token, package, 0, 0);
                if (responseContext.Token != null)
                {
                    Console.WriteLine("  Token: {0}", Convert.ToBase64String(responseContext.Token));
                    Console.WriteLine("  Continue: {0}", responseContext.Continue);
                }
                continueContext = new WindowsSecurityContext(initContext, responseContext.Token, 0, 0);
            } while (responseContext.Continue);

            Assert.IsFalse(responseContext.Continue);
            Console.WriteLine(responseContext.Identity.Fqn);
        }