Provides a framework for developing custom SASL authentication mechanisms.
For a list of all members of this type, see SaslMethod Members.
System.Object
MailBee.SaslMethod
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
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.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.
[C#] // 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();
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code Imports MailBee Imports MailBee.Pop3Mail ' User-defined SASL LOGIN method implementation Public Class SaslLoginMethod Inherits SaslMethod Public Overloads Overrides Function GetSaslID() As String Return "LOGIN" End Function Public Overloads Overrides Sub CreateNextClientAnswer() Select Case Stage Case 0 ClientAnswer = ClientAnswerEncoding.GetBytes(AccountName) Stage += 1 Case 1 ClientAnswer = ClientAnswerEncoding.GetBytes(Password) Stage += 1 End Select End Sub Public Overloads Overrides Function IsSecure() As Boolean Return False End Function End Class ' User-defined SASL LOGIN method usage (put this code into an existing class of your application) Dim pop As New Pop3 pop.Connect("mail.domain.com") pop.Login("jdoe", "secret", AuthenticationMethods.SaslUserDefined, AuthenticationOptions.None, New SaslLoginMethod) pop.Disconnect()
Namespace: MailBee
Assembly: MailBee.NET (in MailBee.NET.dll)
SaslMethod Members | MailBee Namespace | AuthenticationOptions | Login | Login | AuthMethods