SaslMethod Class
Provides a framework for developing custom SASL authentication mechanisms.
Inheritance Hierarchy
SystemObject
  MailBeeSaslMethod

Namespace: MailBee
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public abstract class SaslMethod

The SaslMethod type exposes the following members.

Constructors
  NameDescription
Public methodSaslMethod
Initializes a new instance of the SaslMethod class
Top
Methods
  NameDescription
Public methodAccountDataIsPassword
Designates if only the password must be set (password-only method).
Public methodCode exampleCreateNextClientAnswer
When overridden in a derived class, generates client's next answer in the authentication protocol exchange series.
Public methodDispose
Disposes managed and unmananged resources used by the SASL mechanism.
Protected methodDispose(Boolean)
Actually disposes managed and unmananged resources used by the SASL mechanism.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetSaslID
When overridden in a derived class, returns uppercase name of a SASL method implemented by that class (such as "LOGIN", "NTLM", etc).
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsFipsCompliant
Denotes if this authentication method is FIPS-compliant.
Public methodIsSecure
When overridden in a derived class, designates whether the implemented SASL mechanism is secure or not.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRequiresCredentials
Designates whether or not the implemented SASL mechanism can operate without user credentials passed in AccountName and Password property values.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyAccountDomain
Reserved for future use.
Public propertyAccountName
Gets or sets a user account name on the mail server.
Public propertyClientAnswer
Gets or sets an array of bytes which represents a client answer to a server challenge.
Public propertyClientAnswerEncoding
Gets or sets an encoding of the client answer data.
Public propertyExpectBase64Challenge
Gets or sets the status of whether Base64-encoded data is expected in the pending response from the server.
Public propertyPassword
Gets or sets a user account password on the mail server.
Public propertyServerChallenge
Gets or sets an array of bytes which represents a server challenge.
Public propertyServerChallengeEncoding
Gets or sets an encoding of the server challenge data.
Public propertyServerName
Gets the domain name of the mail server.
Public propertyServiceName
Gets the upper-case name of the protocol being used.
Public propertyStage
Gets or sets the current stage of the authentication protocol exchange.
Public propertyTargetName
Gets the SPN (target name).
Top
Remarks

Instances of derived classes can be used with mailer classes such as Pop3, Imap or Smtp for employing non-standard login mechanisms.

Implementation of SASL authentication mechanism requires the developer to override the following methods:

Also, the developer can override RequiresCredentials method which returns true by default. This can be used for implementing an authentication method which can obtain user credentials itself and does not require AccountName and Password properties be set. For instance, MailBee implementation of NTLM method can obtain user credentials from the operating system when they are not supplied in AccountName and Password properties.
Examples
This sample shows the entire implementation of SASL LOGIN authentication method. Although SASL LOGIN method is already built into MailBee, you can use this sample for developing your own SASL authentication methods.
// To use the code below, import MailBee namespaces at the top of your code
using MailBee;
using MailBee.Pop3Mail;

// User-defined SASL LOGIN method implementation
public class SaslLoginMethod : SaslMethod
{
    public override string GetSaslID()
    {
        return "LOGIN";
    }

    public override void CreateNextClientAnswer() 
    {
        switch (Stage)
        {
            case 0:
                ClientAnswer = ClientAnswerEncoding.GetBytes(AccountName);
                Stage++;
                break;
            case 1:
                ClientAnswer = ClientAnswerEncoding.GetBytes(Password);
                Stage++;
                break;
        }
    }

    public override bool IsSecure() { return false; }
}

// User-defined SASL LOGIN method usage (put this code into an existing class of your application)
Pop3 pop = new Pop3();
pop.Connect("mail.domain.com");
pop.Login("jdoe", "secret", AuthenticationMethods.SaslUserDefined, AuthenticationOptions.None, new SaslLoginMethod());
pop.Disconnect();
See Also