상속: MessageBase
예제 #1
0
		public void TestNtlmAuthWithDomain ()
		{
			var initialFlags = Type1Message.DefaultFlags | NtlmFlags.NegotiateDomainSupplied;
			var credentials = new NetworkCredential ("domain\\username", "password");
			var uri = new Uri ("imap://imap.gmail.com");
			var sasl = new SaslMechanismNtlm (uri, credentials);
			string challenge;
			byte[] decoded;

			challenge = sasl.Challenge (string.Empty);
			decoded = Convert.FromBase64String (challenge);

			var type1 = new Type1Message (decoded, 0, decoded.Length);

			Assert.AreEqual (initialFlags, type1.Flags, "Expected initial NTLM client challenge flags do not match.");
			Assert.AreEqual ("DOMAIN", type1.Domain, "Expected initial NTLM client challenge domain does not match.");
			Assert.AreEqual (string.Empty, type1.Host, "Expected initial NTLM client challenge host does not match.");
			Assert.IsFalse (sasl.IsAuthenticated, "NTLM should not be authenticated.");
		}
예제 #2
0
		public void TestNtlmType1MessageDecode ()
		{
			var flags = NtlmFlags.NegotiateUnicode | NtlmFlags.NegotiateDomainSupplied | NtlmFlags.NegotiateWorkstationSupplied |
				NtlmFlags.NegotiateNtlm | NtlmFlags.NegotiateOem | NtlmFlags.RequestTarget;
			var type1 = new Type1Message (NtlmType1EncodedMessage, 0, NtlmType1EncodedMessage.Length);

			Assert.AreEqual (flags, type1.Flags, "The expected flags do not match.");
			Assert.AreEqual ("WORKSTATION", type1.Host, "The expected workstation name does not match.");
			Assert.AreEqual ("DOMAIN", type1.Domain, "The expected domain does not match.");
			Assert.AreEqual (new Version (5, 0, 2195), type1.OSVersion, "The expected OS Version does not match.");
		}
예제 #3
0
		static MessageBase GetInitialResponse (string domain)
		{
			var type1 = new Type1Message (string.Empty, domain);
			type1.Flags |= NtlmFlags.NegotiateNtlm2Key;

			return type1;
		}
예제 #4
0
		public void TestNtlmType1MessageEncode ()
		{
			var type1 = new Type1Message ("Workstation", "Domain") { OSVersion = new Version (5, 0, 2195) };
			var encoded = type1.Encode ();
			string actual, expected;

			expected = HexEncode (NtlmType1EncodedMessage);
			actual = HexEncode (encoded);

			Assert.AreEqual (expected, actual, "The encoded Type1Message did not match the expected result.");
		}
예제 #5
0
		public void TestNtlmAuthNoDomain ()
		{
			const NtlmFlags initialFlags = NtlmFlags.NegotiateUnicode | NtlmFlags.NegotiateOem | NtlmFlags.NegotiateNtlm |
				NtlmFlags.NegotiateNtlm2Key | NtlmFlags.RequestTarget;
			var credentials = new NetworkCredential ("username", "password");
			var uri = new Uri ("imap://imap.gmail.com");
			var sasl = new SaslMechanismNtlm (uri, credentials);
			string challenge;
			byte[] decoded;

			challenge = sasl.Challenge (string.Empty);
			decoded = Convert.FromBase64String (challenge);

			var type1 = new Type1Message (decoded, 0, decoded.Length);

			Assert.AreEqual (initialFlags, type1.Flags, "Expected initial NTLM client challenge flags do not match.");
			Assert.AreEqual (string.Empty, type1.Domain, "Expected initial NTLM client challenge domain does not match.");
			Assert.AreEqual (string.Empty, type1.Host, "Expected initial NTLM client challenge host does not match.");
			Assert.IsFalse (sasl.IsAuthenticated, "NTLM should not be authenticated.");
		}