using System; namespace AsterNET.Manager.Action { /// /// The LoginAction authenticates the connection.
/// A successful login is the precondition for sending any other action except /// for the ChallengeAction.
/// An unsuccessful login results in an ManagerError being received from the /// server with a message set to "Authentication failed" and the socket being /// closed by Asterisk. ///
/// /// public class LoginAction : ManagerAction { private string username; private string secret; private string authType; private string key; private string events; /// /// Get the name of this action, i.e. "Login". /// override public string Action { get { return "Login"; } } /// /// Get/Set the username as configured in asterik's manager.conf. public string Username { get { return this.username; } set { this.username = value; } } /// /// Get/Set the secret to use when using cleartext login.
/// The secret contains the user's password as configured in Asterisk's manager.conf.
/// The secret and key properties are mutually exclusive. ///
public string Secret { get { return this.secret; } set { this.secret = value; } } /// /// Get/Set the digest alogrithm when using challenge/response.
/// The digest algorithm is used to create the key based on the challenge and /// the user's password.
/// Currently Asterisk supports only "MD5". ///
public string AuthType { get { return this.authType; } set { this.authType = value; } } /// /// Get/Set the key. /// public string Key { get { return this.key; } set { this.key = value; } } /// /// Get/Set the event mask.
/// Set to "on" if all events should be send, "off" if not events should be sent or a combination of /// "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. ///
public string Events { get { return this.events; } set { this.events = value; } } /// /// Creates a new empty LoginAction. /// public LoginAction() { } /// /// Creates a new LoginAction that performs a cleartext login.
/// You should not use cleartext login if you are concerned about security and login with a password hash instead. ///
/// the username as configured in Asterisk's manager.conf /// the user's password as configured in Asterisk's manager.conf /// public LoginAction(string username, string secret) { this.username = username; this.secret = secret; } /// /// Creates a new LoginAction that performs a login via challenge/response. /// /// the username as configured in Asterisk's manager.conf /// the digest alogrithm, must match the digest algorithm that was used with the corresponding ChallengeAction. /// the hash of the user's password and the challenge public LoginAction(string username, string authType, string key) { this.username = username; this.authType = authType; this.key = key; } /// /// Creates a new LoginAction that performs a login via challenge/response. /// /// the username as configured in Asterisk's manager.conf /// the digest alogrithm, must match the digest algorithm that was used with the corresponding ChallengeAction. /// the hash of the user's password and the challenge /// the event mask.
/// Set to "on" if all events should be send, "off" if not events should be sent /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. /// public LoginAction(string username, string authType, string key, string events) { this.username = username; this.authType = authType; this.key = key; this.events = events; } } }