本文整理汇总了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();
}
示例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();
}
示例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();
}
}