Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateCreateContext() [1/2]

void System.Net.Security.NegotiateStream.ValidateCreateContext ( string package,
bool isServer,
NetworkCredential credential,
string servicePrincipalName,
ChannelBinding channelBinding,
ProtectionLevel protectionLevel,
TokenImpersonationLevel impersonationLevel )
inlineprivate

Definition at line 699 of file NegotiateStream.cs.

700 {
702 {
704 }
705 if (_context != null && _context.IsValidContext)
706 {
708 }
709 if (credential == null)
710 {
711 throw new ArgumentNullException("credential");
712 }
713 if (servicePrincipalName == null)
714 {
715 throw new ArgumentNullException("servicePrincipalName");
716 }
717 NegotiateStreamPal.ValidateImpersonationLevel(impersonationLevel);
718 if (_context != null && IsServer != isServer)
719 {
721 }
722 _exception = null;
723 _remoteOk = false;
724 _framer = new StreamFramer();
725 _framer.WriteHeader.MessageId = 22;
726 _expectedProtectionLevel = protectionLevel;
727 _expectedImpersonationLevel = (isServer ? impersonationLevel : TokenImpersonationLevel.None);
730 ContextFlagsPal contextFlagsPal = ContextFlagsPal.Connection;
731 if (protectionLevel == ProtectionLevel.None && !isServer)
732 {
733 package = "NTLM";
734 }
735 else
736 {
737 switch (protectionLevel)
738 {
739 case ProtectionLevel.EncryptAndSign:
740 contextFlagsPal |= ContextFlagsPal.Confidentiality;
741 break;
742 case ProtectionLevel.Sign:
743 contextFlagsPal |= ContextFlagsPal.ReplayDetect | ContextFlagsPal.SequenceDetect | ContextFlagsPal.AcceptStream;
744 break;
745 }
746 }
747 if (isServer)
748 {
750 {
751 contextFlagsPal |= ContextFlagsPal.AllowMissingBindings;
752 }
754 {
755 contextFlagsPal |= ContextFlagsPal.ProxyBindings;
756 }
757 }
758 else
759 {
760 if (protectionLevel != 0)
761 {
762 contextFlagsPal |= ContextFlagsPal.MutualAuth;
763 }
764 if (impersonationLevel == TokenImpersonationLevel.Identification)
765 {
766 contextFlagsPal |= ContextFlagsPal.AcceptIntegrity;
767 }
768 if (impersonationLevel == TokenImpersonationLevel.Delegation)
769 {
770 contextFlagsPal |= ContextFlagsPal.Delegate;
771 }
772 }
774 try
775 {
776 _context = new NTAuthentication(isServer, package, credential, servicePrincipalName, contextFlagsPal, channelBinding);
777 }
778 catch (Win32Exception innerException)
779 {
780 throw new AuthenticationException(System.SR.net_auth_SSPI, innerException);
781 }
782 }
ExtendedProtectionPolicy _extendedProtectionPolicy
TokenImpersonationLevel _expectedImpersonationLevel
static string net_auth_client_server
Definition SR.cs:70
static string net_auth_reauth
Definition SR.cs:66
static string net_auth_SSPI
Definition SR.cs:72
Definition SR.cs:7

References System.Net.Security.NegotiateStream._canRetryAuthentication, System.Net.Security.NegotiateStream._context, System.Net.Security.NegotiateStream._exception, System.Net.Security.NegotiateStream._expectedImpersonationLevel, System.Net.Security.NegotiateStream._expectedProtectionLevel, System.Net.Security.NegotiateStream._extendedProtectionPolicy, System.Net.Security.NegotiateStream._framer, System.Net.Security.NegotiateStream._readSequenceNumber, System.Net.Security.NegotiateStream._remoteOk, System.Net.Security.NegotiateStream._writeSequenceNumber, System.Net.Security.NegotiateStream.IsServer, System.Net.NTAuthentication.IsValidContext, System.SR.net_auth_client_server, System.SR.net_auth_reauth, System.SR.net_auth_SSPI, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy.PolicyEnforcement, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy.ProtectionScenario, System.Net.Security.NegotiateStream.ThrowIfExceptional(), and System.Net.Security.NegotiateStreamPal.ValidateImpersonationLevel().