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


C# ICredentials.ToBytes方法代码示例

本文整理汇总了C#中ICredentials.ToBytes方法的典型用法代码示例。如果您正苦于以下问题:C# ICredentials.ToBytes方法的具体用法?C# ICredentials.ToBytes怎么用?C# ICredentials.ToBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICredentials的用法示例。


在下文中一共展示了ICredentials.ToBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Authenticate

        /// <summary>
        /// Request authentication.
        ///
        /// The server calls this to authenticate new sessions, and when a client requests the session principal is
        /// changed.
        ///
        /// For each call to Authenticate, the authentication handler should respond by calling one of the methods of
        /// the provided callback. The handler may return immediately and process the authentication request
        /// asynchronously. The client session will be blocked until a callback method is called.
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="credentials"></param>
        /// <param name="sessionDetails"></param>
        /// <param name="callback"></param>
        public void Authenticate( string principal, ICredentials credentials, ISessionDetails sessionDetails,
            IAuthenticationHandlerCallback callback )
        {
            var output = string.Format( "ExampleControlAuthenticationHandler asked to authenticate: Principal {0}," +
                "Credentials {1} -> {2}, SessionDetails {3}: ", principal, credentials,
                System.Text.Encoding.UTF8.GetString( credentials.ToBytes() ), sessionDetails );

            Console.WriteLine( output );

            callback.Abstain();
        }
开发者ID:pushtechnology,项目名称:diffusion-examples,代码行数:25,代码来源:ExampleControlAuthenticationHandler.cs

示例2: Authenticate

        /// <summary>
        /// Request authentication.
        ///
        /// The server calls this to authenticate new sessions, and when a client requests the session principal is
        /// changed.
        ///
        /// For each call to Authenticate, the authentication handler should respond by calling one of the methods of
        /// the provided callback. The handler may return immediately and process the authentication request
        /// asynchronously. The client session will be blocked until a callback method is called.
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="credentials"></param>
        /// <param name="sessionDetails"></param>
        /// <param name="callback"></param>
        public void Authenticate( string principal, ICredentials credentials, ISessionDetails sessionDetails,
            IAuthenticationHandlerCallback callback )
        {
            if ( credentials.Type == CredentialsType.PLAIN_PASSWORD ) {
                if ( AuthUser.Equals( principal ) ) {
                    if ( AuthPassword.Equals( System.Text.Encoding.UTF8.GetString( credentials.ToBytes() ) ) ) {
                        callback.Allow();

                        return;
                    }

                    callback.Deny();

                    return;
                }
            }

            callback.Abstain();
        }
开发者ID:pushtechnology,项目名称:diffusion-examples,代码行数:33,代码来源:ControlAuthenticationEnabler.cs

示例3: Authenticate

            /// <summary>
            /// Request authentication.
            ///
            /// The server calls this to authenticate new sessions, and when a client requests the session principal is
            /// changed.
            ///
            /// For each call to Authenticate, the authentication handler should respond by calling one of the methods
            /// of the provided callback. The handler may return immediately and process the authentication request
            /// asynchronously. The client session will be blocked until a callback method is called.
            /// </summary>
            /// <param name="principal"></param>
            /// <param name="credentials"></param>
            /// <param name="sessionDetails"></param>
            /// <param name="callback"></param>
            public void Authenticate( string principal, ICredentials credentials, ISessionDetails sessionDetails,
                IAuthenticationHandlerCallback callback )
            {
                var passwordBytes = Encoding.UTF8.GetBytes( "password" );

                if ( "admin".Equals( principal ) &&
                    credentials.Type == CredentialsType.PLAIN_PASSWORD &&
                    credentials.ToBytes().Equals( passwordBytes ) ) {
                    callback.Allow();
                } else {
                    callback.Deny();
                }
            }
开发者ID:pushtechnology,项目名称:diffusion-examples,代码行数:27,代码来源:ControlClientIdentityChecks.cs


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