예제 #1
0
        public void TryGettingSspiTicketTest()
        {
            using (var contextSender = new SspiContext($"host/{Environment.MachineName}", "negotiate"))
                using (var contextReceiver = new SspiContext($"host/{Environment.MachineName}", "negotiate"))
                {
                    byte[] token          = null;
                    byte[] serverResponse = null;

                    do
                    {
                        token = contextSender.RequestToken(serverResponse);

                        Assert.IsNotNull(token);

                        if (token != null && token.Length > 0)
                        {
                            contextReceiver.AcceptToken(token, out serverResponse);
                            Assert.IsNotNull(serverResponse);
                        }
                    }while (token != null && token.Length > 0);

                    var serverContext = NegotiationToken.Decode(serverResponse);

                    Assert.IsNotNull(serverContext);
                    Assert.IsNotNull(serverContext.ResponseToken);
                    Assert.IsNull(serverContext.InitialToken);

                    Assert.IsNotNull(contextSender.SessionKey);

                    Assert.IsTrue(KerberosCryptoTransformer.AreEqualSlow(contextSender.SessionKey, contextReceiver.SessionKey));
                }
        }
예제 #2
0
        public void TryGettingSspiTicketTest()
        {
            using (var contextSender = new SspiContext($"host/{Environment.MachineName}", "Negotiate"))
                using (var contextReceiver = new SspiContext($"host/{Environment.MachineName}", "Negotiate"))
                {
                    var token = contextSender.RequestToken();

                    Assert.IsNotNull(token);

                    var contextToken = MessageParser.Parse <NegotiateContextToken>(token);

                    Assert.IsNotNull(contextToken);

                    contextReceiver.AcceptToken(token, out byte[] serverResponse);

                    Assert.IsNotNull(serverResponse);

                    var serverContext = NegotiationToken.Decode(serverResponse);

                    Assert.IsNotNull(serverContext);
                    Assert.IsNotNull(serverContext.ResponseToken);
                    Assert.IsNull(serverContext.InitialToken);
                }
        }