• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ExtendedProtection.ChannelBinding类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Authenticate

        public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(this, "Authenticate");
            try
            {
                lock (_sessions)
                {
                    NTAuthentication clientContext;
                    if (!_sessions.TryGetValue(sessionCookie, out clientContext))
                    {
                        if (credential == null)
                        {
                            return null;
                        }

                        _sessions[sessionCookie] =
                            clientContext =
                            new NTAuthentication(false, "Ntlm", credential, spn, ContextFlagsPal.Connection, channelBindingToken);

                    }

                    string resp = clientContext.GetOutgoingBlob(challenge);

                    if (!clientContext.IsCompleted)
                    {
                        return new Authorization(resp, false);
                    }
                    else
                    {
                        _sessions.Remove(sessionCookie);
                        return new Authorization(resp, true);
                    }
                }
            }
            // From reflected type NTAuthentication in System.Net.Security.
            catch (NullReferenceException)
            {
                return null;
            }
            finally
            {
                if (NetEventSource.IsEnabled) NetEventSource.Exit(this, "Authenticate");
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:44,代码来源:SmtpNtlmAuthenticationModule.cs


示例17: Authenticate

        public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
        {
            if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(NetEventSource.ComponentType.Web, this, nameof(Authenticate), null);
            try
            {
                lock (_sessions)
                {
                    NetworkCredential cachedCredential;
                    if (!_sessions.TryGetValue(sessionCookie, out cachedCredential))
                    {
                        if (credential == null || ReferenceEquals(credential, CredentialCache.DefaultNetworkCredentials))
                        {
                            return null;
                        }

                        _sessions[sessionCookie] = credential;

                        string userName = credential.UserName;
                        string domain = credential.Domain;

                        if (domain != null && domain.Length > 0)
                        {
                            userName = domain + "\\" + userName;
                        }

                        return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(userName)), false);
                    }
                    else
                    {
                        _sessions.Remove(sessionCookie);

                        return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(cachedCredential.Password)), true);
                    }
                }
            }
            finally
            {
                if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(NetEventSource.ComponentType.Web, this, "Authenticate", null);
            }
        }
开发者ID:naamunds,项目名称:corefx,代码行数:40,代码来源:SmtpLoginAuthenticationModule.cs


示例18: 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)
         {
             NetworkCredential credential2 = this.sessions[sessionCookie] as NetworkCredential;
             if (credential2 == null)
             {
                 if ((credential == null) || (credential is SystemNetworkCredential))
                 {
                     return null;
                 }
                 this.sessions[sessionCookie] = credential;
                 string userName = credential.UserName;
                 string domain = credential.Domain;
                 if ((domain != null) && (domain.Length > 0))
                 {
                     userName = domain + @"\" + userName;
                 }
                 return new Authorization(Convert.ToBase64String(Encoding.UTF8.GetBytes(userName)), false);
             }
             this.sessions.Remove(sessionCookie);
             authorization = new Authorization(Convert.ToBase64String(Encoding.UTF8.GetBytes(credential2.Password)), true);
         }
     }
     finally
     {
         if (Logging.On)
         {
             Logging.Exit(Logging.Web, this, "Authenticate", (string) null);
         }
     }
     return authorization;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:SmtpLoginAuthenticationModule.cs


示例19: Authenticate

 public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
 {
     lock (this.sessions)
     {
         NTAuthentication authentication = this.sessions[sessionCookie] as NTAuthentication;
         if (authentication == null)
         {
             if (credential == null)
             {
                 return null;
             }
             this.sessions[sessionCookie] = authentication = new NTAuthentication(false, "WDigest", credential, spn, ContextFlags.Connection, channelBindingToken);
         }
         string outgoingBlob = authentication.GetOutgoingBlob(challenge);
         if (!authentication.IsCompleted)
         {
             return new Authorization(outgoingBlob, false);
         }
         this.sessions.Remove(sessionCookie);
         return new Authorization(outgoingBlob, true);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:SmtpDigestAuthenticationModule.cs


示例20: Authenticate

        public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
        {
            if(Logging.On)Logging.Enter(Logging.Web, this, "Authenticate", null);
            try {
                lock (this.sessions)
                {
                    NetworkCredential cachedCredential = sessions[sessionCookie] as NetworkCredential;
                    if (cachedCredential == null)
                    {
                        if (credential == null  || credential is SystemNetworkCredential)
                        {
                            return null;
                        }

                        sessions[sessionCookie] = credential;

                        string userName = credential.UserName;
                        string domain = credential.Domain;

                        if (domain!=null && domain.Length > 0) {
                            userName = domain + "\\" + userName;
                        }

                        // 
                        return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(userName)), false);
                    }
                    else
                    {
                        this.sessions.Remove(sessionCookie);

                        // 
                        return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(cachedCredential.Password)), true);
                    }
                }
            } finally {
                if(Logging.On)Logging.Exit(Logging.Web, this, "Authenticate", null);
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:38,代码来源:SmtpLoginAuthenticationModule.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ExtendedProtection.ExtendedProtectionPolicy类代码示例发布时间:2022-05-26
下一篇:
C# AccessControl.RawSecurityDescriptor类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap