using System;
using System.Collections.Generic;
using Renci.SshNet.Common;
namespace Renci.SshNet
{
    /// 
    /// Base class for all supported authentication methods
    /// 
    public abstract class AuthenticationMethod : IAuthenticationMethod
    {
        /// 
        /// Gets the name of the authentication method.
        /// 
        /// 
        /// The name of the authentication method.
        /// 
        public abstract string Name { get; }
        /// 
        /// Gets connection username.
        /// 
        public string Username { get; private set; }
        /// 
        /// Gets list of allowed authentications.
        /// 
        public IEnumerable AllowedAuthentications { get; protected set; }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The username.
        ///  is whitespace or null.
        protected AuthenticationMethod(string username)
        {
            if (username.IsNullOrWhiteSpace())
                throw new ArgumentException("username");
            this.Username = username;
        }
        /// 
        /// Authenticates the specified session.
        /// 
        /// The session to authenticate.
        /// 
        /// The result of the authentication process.
        /// 
        public abstract AuthenticationResult Authenticate(Session session);
        /// 
        /// Authenticates the specified session.
        /// 
        /// The session to authenticate.
        /// 
        /// The result of the authentication process.
        /// 
        AuthenticationResult IAuthenticationMethod.Authenticate(ISession session)
        {
            return Authenticate((Session) session);
        }
    }
}