public bool Login()
        {
            if (configuration.SecurityType != null)
            {
                if (sessionToken != null)
                {
                    Logout();
                }
                IAuthenticationMode authentication = ExtensionHelpers.RetrieveAuthenticationMode(configuration.SecurityType);
                authentication.Settings = configuration.SecuritySettings;

                var request = authentication.GenerateCredentials();
                if (manager.Login(request.Credentials))
                {
                    sessionToken = manager.SessionToken;
                }
                else
                {
                    sessionToken = null;
                }

                return(sessionToken != null);
            }
            else
            {
                return(true);
            }
        }
示例#2
0
        /// <summary>
        /// Attempt to login a user.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Login(string userName, string password)
        {
            // Generate the credentials
            var credentials = new List <NameValuePair>();

            if (!string.IsNullOrEmpty(userName))
            {
                credentials.Add(
                    new NameValuePair(
                        LoginRequest.UserNameCredential,
                        userName));
            }
            if (!string.IsNullOrEmpty(password))
            {
                credentials.Add(
                    new NameValuePair(
                        LoginRequest.PasswordCredential,
                        password));
            }

            // Send the login request
            try
            {
                var result = client.Login(credentials);
                if (result)
                {
                    FireLoginChanged();
                }
                return(result);
            }
            catch (Exception error)
            {
                throw new CommunicationsException("An unexpected error has occurred", error);
            }
        }
 public bool Login()
 {
     if (configuration.SecurityType != null)
     {
         Logout();
         IAuthenticationMode authentication = ExtensionHelpers.RetrieveAuthenticationMode(configuration.SecurityType);
         authentication.Settings = configuration.SecuritySettings;
         var isValid = manager.Login(authentication.GenerateCredentials().Credentials);
         return(isValid);
     }
     else
     {
         return(true);
     }
 }