当前位置: 首页>>代码示例>>C#>>正文


C# ExtendedProtection.ChannelBinding类代码示例

本文整理汇总了C#中System.Security.Authentication.ExtendedProtection.ChannelBinding的典型用法代码示例。如果您正苦于以下问题:C# ChannelBinding类的具体用法?C# ChannelBinding怎么用?C# ChannelBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChannelBinding类属于System.Security.Authentication.ExtendedProtection命名空间,在下文中一共展示了ChannelBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Authenticate

        public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
        {

            lock (this.sessions)
            {
                NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication;
                if (clientContext == null)
                {
                    if (credential == null){
                        return null;
                    }
                    // 


                   

                    this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "WDigest", credential, spn, ContextFlags.Connection, channelBindingToken);
                }

                string resp = clientContext.GetOutgoingBlob(challenge);

                if (!clientContext.IsCompleted)
                {
                    return new Authorization(resp, false);
                }
                else
                {
                    this.sessions.Remove(sessionCookie);
                    return new Authorization(resp, true);
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:32,代码来源:SmtpDigestAuthenticationModule.cs

示例2: Initialize

        private void Initialize(bool isServer, string package, NetworkCredential credential, string spn, ContextFlagsPal requestedContextFlags, ChannelBinding channelBinding)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(this, package, spn, requestedContextFlags);

            _tokenSize = NegotiateStreamPal.QueryMaxTokenSize(package);
            _isServer = isServer;
            _spn = spn;
            _securityContext = null;
            _requestedContextFlags = requestedContextFlags;
            _package = package;
            _channelBinding = channelBinding;

            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Peer SPN-> '{_spn}'");

            //
            // Check if we're using DefaultCredentials.
            //

            Debug.Assert(CredentialCache.DefaultCredentials == CredentialCache.DefaultNetworkCredentials);
            if (credential == CredentialCache.DefaultCredentials)
            {
                if (NetEventSource.IsEnabled) NetEventSource.Info(this, "using DefaultCredentials");
                _credentialsHandle = NegotiateStreamPal.AcquireDefaultCredential(package, _isServer);
            }
            else
            {
                _credentialsHandle = NegotiateStreamPal.AcquireCredentialsHandle(package, _isServer, credential);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:29,代码来源:NTAuthentication.cs

示例3: OnAcceptUpgrade

 protected override Stream OnAcceptUpgrade(Stream stream, out SecurityMessageProperty remoteSecurity)
 {
     SslStream stream2 = new SslStream(stream, false, new RemoteCertificateValidationCallback(this.ValidateRemoteCertificate));
     try
     {
         stream2.AuthenticateAsServer(this.parent.ServerCertificate, this.parent.RequireClientCertificate, SslProtocols.Default, false);
     }
     catch (AuthenticationException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(exception.Message, exception));
     }
     catch (IOException exception2)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(System.ServiceModel.SR.GetString("NegotiationFailedIO", new object[] { exception2.Message }), exception2));
     }
     if (System.ServiceModel.Security.SecurityUtils.ShouldValidateSslCipherStrength())
     {
         System.ServiceModel.Security.SecurityUtils.ValidateSslCipherStrength(stream2.CipherStrength);
     }
     remoteSecurity = this.clientSecurity;
     if (this.IsChannelBindingSupportEnabled)
     {
         this.channelBindingToken = ChannelBindingUtility.GetToken(stream2);
     }
     return stream2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:SslStreamSecurityUpgradeAcceptor.cs

示例4: ServerSingletonConnectionReader

 public ServerSingletonConnectionReader(ServerSingletonPreambleConnectionReader preambleReader, IConnection upgradedConnection, ConnectionDemuxer connectionDemuxer) : base(upgradedConnection, preambleReader.BufferOffset, preambleReader.BufferSize, preambleReader.Security, preambleReader.TransportSettings, preambleReader.Via)
 {
     this.decoder = preambleReader.Decoder;
     this.contentType = this.decoder.ContentType;
     this.connectionDemuxer = connectionDemuxer;
     this.rawConnection = preambleReader.RawConnection;
     this.channelBindingToken = preambleReader.ChannelBinding;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ServerSingletonConnectionReader.cs

示例5: DuplicateToken

 public static ChannelBinding DuplicateToken(ChannelBinding source)
 {
     if (source == null)
     {
         return null;
     }
     return DuplicatedChannelBinding.CreateCopy(source);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ChannelBindingUtility.cs

示例6: TryAddToMessage

 public static void TryAddToMessage(ChannelBinding channelBindingToken, Message message, bool messagePropertyOwnsCleanup)
 {
     if (channelBindingToken != null)
     {
         ChannelBindingMessageProperty property = new ChannelBindingMessageProperty(channelBindingToken, messagePropertyOwnsCleanup);
         property.AddTo(message);
         property.Dispose(); //message.Properties.Add() creates a copy...
     }
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:9,代码来源:ChannelBindingUtility.cs

示例7: Dispose

 public static void Dispose(ref ChannelBinding channelBinding)
 {
     // Explicitly cast to IDisposable to avoid the SecurityException.
     IDisposable disposable = (IDisposable)channelBinding;
     channelBinding = null;
     if (disposable != null)
     {
         disposable.Dispose();
     }
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:10,代码来源:ChannelBindingUtility.cs

示例8: Authenticate

 public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
 {
     Authorization authorization;
     if (Logging.On)
     {
         Logging.Enter(Logging.Web, this, "Authenticate", (string) null);
     }
     try
     {
         lock (this.sessions)
         {
             NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication;
             if (clientContext == null)
             {
                 if (credential == null)
                 {
                     return null;
                 }
                 this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "Negotiate", credential, spn, ContextFlags.AcceptStream | ContextFlags.Connection, channelBindingToken);
             }
             string token = null;
             if (!clientContext.IsCompleted)
             {
                 SecurityStatus status;
                 byte[] incomingBlob = null;
                 if (challenge != null)
                 {
                     incomingBlob = Convert.FromBase64String(challenge);
                 }
                 byte[] inArray = clientContext.GetOutgoingBlob(incomingBlob, false, out status);
                 if (clientContext.IsCompleted && (inArray == null))
                 {
                     token = "\r\n";
                 }
                 if (inArray != null)
                 {
                     token = Convert.ToBase64String(inArray);
                 }
             }
             else
             {
                 token = this.GetSecurityLayerOutgoingBlob(challenge, clientContext);
             }
             authorization = new Authorization(token, clientContext.IsCompleted);
         }
     }
     finally
     {
         if (Logging.On)
         {
             Logging.Exit(Logging.Web, this, "Authenticate", (string) null);
         }
     }
     return authorization;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:55,代码来源:SmtpNegotiateAuthenticationModule.cs

示例9: ChannelBindingMessageProperty

 public ChannelBindingMessageProperty(System.Security.Authentication.ExtendedProtection.ChannelBinding channelBinding, bool ownsCleanup)
 {
     if (channelBinding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelBinding");
     }
     this.refCount = 1;
     this.thisLock = new object();
     this.channelBinding = channelBinding;
     this.ownsCleanup = ownsCleanup;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:ChannelBindingMessageProperty.cs

示例10: CheckChannelBinding

 public void CheckChannelBinding(ChannelBinding channelBinding)
 {
     if (channelBinding != null)
     {
         Assert.True(!channelBinding.IsInvalid, "Channel binding token should be marked as a valid SafeHandle.");
         Assert.True(channelBinding.Size > 0, "Number of bytes in a valid channel binding token should be greater than zero.");
         var bytes = new byte[channelBinding.Size];
         Marshal.Copy(channelBinding.DangerousGetHandle(), bytes, 0, channelBinding.Size);
         Assert.Equal(channelBinding.Size, bytes.Length);
     }
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:11,代码来源:TransportContextTest.cs

示例11: ValidateCreateContext

 internal void ValidateCreateContext(
                                     string package,
                                     bool isServer,
                                     NetworkCredential credential,
                                     string servicePrincipalName,
                                     ChannelBinding channelBinding,
                                     ProtectionLevel protectionLevel,
                                     TokenImpersonationLevel impersonationLevel
                                     )
 {
     throw new PlatformNotSupportedException();
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:12,代码来源:NegoState.Unix.cs

示例12: ChannelBindingMessageProperty

        public ChannelBindingMessageProperty(ChannelBinding channelBinding, bool ownsCleanup)
        {
            if (channelBinding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelBinding");
            }

            _refCount = 1;
            _thisLock = new object();
            _channelBinding = channelBinding;
            _ownsCleanup = ownsCleanup;
        }
开发者ID:weshaggard,项目名称:wcf,代码行数:12,代码来源:ChannelBindingMessageProperty.cs

示例13: ExtendedProtectionPolicy

        public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement,
                                        ChannelBinding customChannelBinding)
        {
            if (policyEnforcement == PolicyEnforcement.Never)
            {
                throw new ArgumentException(SR.GetString(SR.security_ExtendedProtectionPolicy_UseDifferentConstructorForNever), "policyEnforcement");
            }
            if (customChannelBinding == null)
            {
                throw new ArgumentNullException("customChannelBinding");
            }

            this.policyEnforcement = policyEnforcement;
            this.protectionScenario = ProtectionScenario.TransportSelected;
            this.customChannelBinding = customChannelBinding;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:16,代码来源:ExtendedProtectionPolicy.cs

示例14: ExtendedProtectionPolicyHelper

 public ExtendedProtectionPolicyHelper(System.Security.Authentication.ExtendedProtection.ChannelBinding channelBinding, ExtendedProtectionPolicy extendedProtectionPolicy)
 {
     this._channelBinding = channelBinding;
     this._serviceNameCollection = null;
     this._checkServiceBinding = true;
     if (extendedProtectionPolicy != null)
     {
         this._policyEnforcement = extendedProtectionPolicy.PolicyEnforcement;
         this._protectionScenario = extendedProtectionPolicy.ProtectionScenario;
         this._serviceNameCollection = extendedProtectionPolicy.CustomServiceNames;
     }
     if (this._policyEnforcement == System.Security.Authentication.ExtendedProtection.PolicyEnforcement.Never)
     {
         this._checkServiceBinding = false;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:ExtendedProtectionPolicyHelper.cs

示例15: ExtendedProtectionPolicy

        public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement,
                                        ChannelBinding customChannelBinding)
        {
            if (policyEnforcement == PolicyEnforcement.Never)
            {
                throw new ArgumentException(SR.security_ExtendedProtectionPolicy_UseDifferentConstructorForNever, nameof(policyEnforcement));
            }

            if (customChannelBinding == null)
            {
                throw new ArgumentNullException(nameof(customChannelBinding));
            }

            _policyEnforcement = policyEnforcement;
            _protectionScenario = ProtectionScenario.TransportSelected;
            _customChannelBinding = customChannelBinding;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:17,代码来源:ExtendedProtectionPolicy.cs


注:本文中的System.Security.Authentication.ExtendedProtection.ChannelBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。