Exemple #1
0
        public string getAuthToken()
        {
            if (otAuth == null)
            {
                return(null);
            }
            if (otAuth.AuthenticationToken == null)
            {
                return(null);
            }

            Authentication.AuthenticationClient authClient = new Authentication.AuthenticationClient();
            try
            {
                string authToken = authClient.RefreshToken(ref otAuth);
                otAuth.AuthenticationToken = authToken;
                return(authToken);
            }
            catch (Exception e)
            {
                log.Error(e, "Exception while proceeding authentication.", null);
            }
            finally
            {
                authClient.Close();
            }
            return(null);
        }
Exemple #2
0
        public bool auth()
        {
            string login    = settings.getLogin();
            string password = settings.getPassword();

            if (String.IsNullOrEmpty(login) || String.IsNullOrEmpty(password))
            {
                return(false);
            }
            Authentication.AuthenticationClient authClient = null;
            try
            {
                authClient = new Authentication.AuthenticationClient();
                string authToken = authClient.AuthenticateUser(login, password);
                otAuth = new Authentication.OTAuthentication();
                otAuth.AuthenticationToken = authToken;
            }
            catch (Exception e)
            {
                log.Error(e, "Exception while proceeding authentication for user: "******".", null);
                return(false);
            }
            finally
            {
                if (authClient != null)
                {
                    authClient.Close();
                }
            }
            return(true);
        }