public void TestAcceptBadSecurityToken()
 {
     WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
     byte[] clientToken = new byte[] { 1, 2, 3 };
     IWindowsSecurityContext ctx = provider.AcceptSecurityToken(Guid.NewGuid().ToString(), clientToken, "Negotiate",
         Secur32.ISC_REQ_CONNECTION, Secur32.SECURITY_NATIVE_DREP);
 }
 public void TestAcceptExistingSecurityToken()
 {
     WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
     byte[] clientToken = System.Convert.FromBase64String("YIIFWgYGKwYBBQUCoIIFTjCCBUqgJDAiBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICCqKCBSAEggUcYIIFGAYJKoZIhvcSAQICAQBuggUHMIIFA6ADAgEFoQMCAQ6iBwMFACAAAACjggQuYYIEKjCCBCagAwIBBaEPGw1OWUNBUFQzNUsuQ09NoikwJ6ADAgECoSAwHhsESFRUUBsWamhpdGUyazMubnljYXB0MzVrLmNvbaOCA+EwggPdoAMCARehAwIBBaKCA88EggPL9ISsFstUd6KU8hUwiXh5axPlaoLgDfHF0jxsRiLVbKdB8WFSDbbICl3reAR2fPF8QVTL8KU2dZYuX770PFXZEBR/ZhyOfIUMtX2mmBwWZDDPU5MvMCbQcEhRSlweO/UQoAVzsRjq/wBrIKFEHpWm1LVE9Mqg/4rLmTTkdCIklB/HSHGz2Q64F37k3Q+NfM7T7wIMOsRJa1IIJt/2tpGwbYM6MJOPBVNw7UggFrJmdcm94TDgRZhBoC3E2UmJnt8GmlryPbE7i5WWoO24mx5VC43p6+WZYPhgyEwHzfrycar0BLNvJC1Tc8j2CDmAybUUczPCUhBIjYWGNuY/ILoZZTr1aTM4Y4tNJu/rpoe7SDtqWNWtGcdl8dDLTJBkbooymMYZuTCU6H5MWh7zvHbF7v3XjZtNPyhEiS0hVQ8y4hyeeAP5T1LdW5NVClHYx3HjZt8upcCYqczRGHYix9y/Fkq3xF70O3F0SoJl+DNsNI5D/otE4rOl472Jz8ywQ0hx+z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(), clientToken, "Negotiate",
         Secur32.ISC_REQ_CONNECTION, Secur32.SECURITY_NATIVE_DREP);
     Assert.IsTrue(ctx.Continue);
 }
        public void TestNegotiate()
        {
            string package = "Negotiate";
            WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
            WindowsSecurityContext initContext = WindowsSecurityContext.GetCurrent(package,
                WindowsIdentity.GetCurrent().Name, Secur32.ISC_REQ_CONNECTION, Secur32.SECURITY_NATIVE_DREP);
            IWindowsSecurityContext continueContext = initContext;
            IWindowsSecurityContext responseContext = null;
            string connectionId = Guid.NewGuid().ToString();
            do
            {
                responseContext = provider.AcceptSecurityToken(connectionId, continueContext.Token, package,
                    Secur32.ISC_REQ_CONNECTION, Secur32.SECURITY_NATIVE_DREP);
                if (responseContext.Token != null)
                {
                    Console.WriteLine("  Token: {0}", Convert.ToBase64String(responseContext.Token));
                    Console.WriteLine("  Continue: {0}", responseContext.Continue);
                }
                continueContext = new WindowsSecurityContext(initContext, responseContext.Token,
                    Secur32.ISC_REQ_CONNECTION, Secur32.SECURITY_NATIVE_DREP);
            } while (responseContext.Continue);

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