Пример #1
0
    public DesktopGUI(string intoken, string rootUrl, string authUrl)
    {
      WindowStartupLocation = WindowStartupLocation.CenterScreen;
      InitializeComponent();
      RootServerUrl = rootUrl;
      AuthServerUrl = authUrl;
      m_clientapi = new ClientAPI();

      Logger.LogWrite("Setting the root server url for desktop gui to " + RootServerUrl);
      m_clientapi.SetRootServer(RootServerUrl);
      Logger.LogWrite("Setting the auth server url for desktop gui to " + AuthServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      Logger.LogWrite("Configuring the client api");
      m_clientapi.ConfigClient();

      LoginToken = intoken;
      CurrentUserIsAdmin = m_clientapi.IsAdmin(LoginToken);
      if (CurrentUserIsAdmin)
      {
        Logger.LogWrite("User is admin");
        m_LblLevel.Visibility = System.Windows.Visibility.Visible;
        m_CmbUserPrivilege.Visibility = System.Windows.Visibility.Visible;
      }
      else
      {
        Logger.LogWrite("User logged in not as admin");
        m_LblLevel.Visibility = System.Windows.Visibility.Hidden;
        m_CmbUserPrivilege.Visibility = System.Windows.Visibility.Hidden;

      }
    }
Пример #2
0
 /// <summary>
 /// test 1 
 /// To authenticate the user 
 /// </summary>
 /// <returns></returns>
 private string Test1()
 {
   Message m1 = new Message();
   m1.TestID = 1;
   m_clientapi = new ClientAPI();
   m_clientapi.SetRootServer(RootServerUrl);
   m_clientapi.SetAuthHostAddress(AuthServerUrl);
   m_clientapi.ConfigClient();
   if (m_clientapi.AuthenticateUser("team2", "clientapi", out m_temptoken).valid)
   {
     m1.Passed = false;
     m1.Msg = "m_clientapi.AuthenticateUser() test1 fails";
   }
   else
   {
     m1.Passed = true;
     m1.Msg = "m_clientapi.AuthenticateUser() test1 succeeds";
   }
   return m1.ToString();
 }
Пример #3
0
    public static void Main(string[] args)
    {
      DependencyInjection di = DependencyInjection.GetInstance();
      di.SetConfig("config.xml");
      Console.WriteLine("test begins");

      ClientAPI m_TestObject = new ClientAPI();
      m_TestObject.SetRootServer("http://localhost:8080/root");
      m_TestObject.SetAuthHostAddress("http://localhost:8080/IComm");
      m_TestObject.ConfigClient();

      m_TestObject.ExecuteQuery("SELECT * FROM first_db.test_table", "mocktoken");
      if (m_TestObject.CheckIfRowsReturned())
      {
        List<string> string1 = m_TestObject.IterateDataSet();

        List<string> ColNames = m_TestObject.GetAllColumnNames();

        List<System.Type> ColTypes = m_TestObject.GetAllColumnTypes();
        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");
        Console.WriteLine(string1[1]);
        string1 = m_TestObject.IterateDataSet();

        if (string1 == null) Console.WriteLine("the end");

      }
      else
      {
        Console.WriteLine(" no row returned");

      }

    }
Пример #4
0
    /// <summary>
    /// test2 
    /// test to authenticate the user credentials 
    /// </summary>
    /// <returns></returns>
    private string Test2()
    {
      Message m2 = new Message();
      m2.TestID = 2;
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();
      if (m_clientapi.AuthenticateUser("team1", "rootserver", out m_temptoken).valid)
      {
        m2.Passed = false;
        m2.Msg = "m_clientapi.AuthenticateUser() test2 fails";
      }
      else
      {
        m2.Passed = true;
        m2.Msg = "m_clientapi.AuthenticateUser() test2 succeeds";
      }
      return m2.ToString();

    }
Пример #5
0
    /// <summary>
    /// test 8
    /// testing the execution of the query 
    /// </summary>
    /// <returns></returns>
    private string Test8()
    {
      Message m8 = new Message();
      m8.TestID = 8;
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();
      m_QueryObj = m_clientapi.ExecuteQuery("CREATE DB first_db", m_temptoken);
      if ((m_QueryObj.GetId() == 0) && (m_QueryObj.GetMessage() == "Database is not created"))
      {
        m8.Passed = false;
        m8.Msg = "m_clientapi.ExecuteQuery fails";
      }
      else
      {
        m8.Passed = true;
        m8.Msg = "m_clientapi.ExecuteQuery succeeds";
      }
      return m8.ToString();

    }
Пример #6
0
    /// <summary>
    /// test 7
    /// testing the username is admin
    /// </summary>
    /// <returns></returns>
    private string Test7()
    {
      Message m7 = new Message();
      m7.TestID = 7;
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();
      if (!(m_clientapi.IsAdmin("hshen")))
      {
        m7.Passed = true;
        m7.Msg = "m_clientapi.IsAdmin test2 succeeds";
      }
      else
      {
        m7.Passed = false;
        m7.Msg = "m_clientapi.IsAdmin test2 fails";
      }
      return m7.ToString();

    }
Пример #7
0
    /// <summary>
    /// test 6
    /// testing if the user is administrator by passing the current token 
    /// </summary>
    /// <returns></returns>
    private string Test6()
    {
      Message m6 = new Message();
      m6.TestID = 6;
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();
      if (!(m_clientapi.IsAdmin(m_admintoken)))
      {
        m6.Passed = false;
        m6.Msg = "m_clientapi.IsAdmin test1 fails";
      }
      else
      {
        m6.Passed = true;
        m6.Msg = "m_clientapi.IsAdmin  test1 succeeds";
      }
      return m6.ToString();


    }
Пример #8
0
    /// <summary>
    /// test 5
    /// testing creating of new user with other user credentials
    /// </summary>
    /// <returns></returns>
    private string Test5()
    {
      Message m5 = new Message();
      m5.TestID = 5;
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();
      if ((m_clientapi.CreateNewUser("hshen1", "ewewew", m_admintoken).valid))
      {
        m5.Passed = false;
        m5.Msg = "m_clientapi.CreateNewUser test2 fails";

      }
      else
      {
        m5.Passed = true;
        m5.Msg = "m_clientapi.CreateNewUser  test2 succeeds";
      }
      return m5.ToString();

    }
Пример #9
0
 /// <summary>
 /// test 4 
 /// test to create a new user 
 /// </summary>
 /// <returns></returns>
 private string Test4()
 {
   Message m4 = new Message();
   m4.TestID = 4;
   m_clientapi = new ClientAPI();
   m_clientapi.SetRootServer(RootServerUrl);
   m_clientapi.SetAuthHostAddress(AuthServerUrl);
   m_clientapi.ConfigClient();
   if (m_clientapi.CreateNewUser("hshen", "hshen", "hshen").valid)
   {
     m4.Passed = false;
     m4.Msg = "m_clientapi.CreateNewUser test1 fails";
   }
   else
   {
     m4.Passed = true;
     m4.Msg = "m_clientapi.CreateNewUser test1 succeeds";
   }
   return m4.ToString();
 }
Пример #10
0
    /// <summary>
    /// test 3 
    /// test to authenticate the user 
    /// </summary>
    /// <returns></returns>
    private string Test3()
    {

      Message m3 = new Message();
      m3.TestID = 3;
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();
      if (!(m_clientapi.AuthenticateUser("team1", "clientapi", out m_admintoken).valid))
      {
        m3.Passed = false;
        m3.Msg = "m_clientapi.AuthenticateUser() test3 fails";
      }
      else
      {
        m3.Passed = true;
        m3.Msg = "m_clientapi.AuthenticateUser() test3 succeeds";
      }
      return m3.ToString();

    }
Пример #11
0
    /// <summary>
    /// To execute the select statements , when the table name is selected in the tree view 
    /// </summary>
    /// <param name="m_TableName"></param>
    private void ExecuteSelectQuery(string m_TableName)
    {
      try
      {
        m_clientapi = new ClientAPI();
        m_clientapi.SetRootServer(RootServerUrl);
        m_clientapi.SetAuthHostAddress(AuthServerUrl);
        m_clientapi.ConfigClient();

        m_DgContentOfTables.ItemsSource = null;

        string m_Query = "SELECT * FROM " + this.GetKeyForValue(m_DBTableInfos, m_TableName) + "." + m_TableName;

        m_clientapi.ExecuteQuery(m_Query, LoginToken);

        if (m_clientapi.CheckIfRowsReturned())
        {
          DataTable DataGridDataTable = this.GenerateColumnNameAndTypes(m_clientapi);

          m_DgContentOfTables.ItemsSource = DataGridDataTable.DefaultView;
        }
        else
        {
          MessageBox.Show("No rows of Data Returned");
        }

      }
      catch (Exception ex)
      {

        MessageBox.Show(ex.Message);
      }
    }
Пример #12
0
    private void TreeView_Loaded(object sender, RoutedEventArgs e)
    {
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();

      m_DBTableInfos = m_clientapi.GetTableInfos(LoginToken);
      m_EskimoDbTree.Items.Clear();

      foreach (KeyValuePair<string, List<string>> m_kvps in m_DBTableInfos)
      {
        TreeViewItem m_Level1Item = new TreeViewItem();
        m_Level1Item.Header = m_kvps.Key;

        foreach (string m_Value in m_kvps.Value)
        {
          TreeViewItem m_Level2Item = new TreeViewItem();
          m_Level2Item.Header = m_Value;
          m_Level1Item.Items.Add(m_Level2Item);
        }

        m_EskimoDbTree.Items.Add(m_Level1Item);

      }
    }
Пример #13
0
    private void AccountMgmtTabLoad()
    {
      m_clientapi = new ClientAPI();
      m_clientapi.SetRootServer(RootServerUrl);
      m_clientapi.SetAuthHostAddress(AuthServerUrl);
      m_clientapi.ConfigClient();

      this.cb_UserAccountsLoad();

      bn_New.IsEnabled = true;
      bn_Save.IsEnabled = true;
    }
Пример #14
0
 private void m_btnLogIn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
   try
   {
     string temptoken;
     m_clientapi = new ClientAPI();
     m_clientapi.SetAuthHostAddress(m_TxtAuthURL.Text.ToString());
     m_clientapi.SetRootServer(m_TxtRootURL.Text.ToString());
     m_clientapi.ConfigClient();
     AuthResult m_AuthResult = m_clientapi.AuthenticateUser(m_txtUserName.Text, m_txtPassWord.Password, out temptoken);
     if (m_AuthResult.valid)
     {
       Logger.LogWrite("User: "******" is authenticated");
       MessageBox.Show(m_txtUserName.Text + " Authenticated!!!", "Eskimo DB");
       DesktopGUI m_UserMenuWindow = new DesktopGUI(temptoken, m_TxtRootURL.Text.ToString(), m_TxtAuthURL.Text.ToString());
       m_UserMenuWindow.Show();
       this.Close();
     }
     else
     {
       Logger.LogWrite("User: "******" is not authenticated");
       MessageBox.Show(m_AuthResult.msg);
       m_txtUserName.Text = string.Empty;
       m_txtPassWord.Password = string.Empty;
     }
   }
   catch (Exception ex)
   {
     MessageBox.Show("Please enter valid url. Error Message :" + ex.Message, "EskimoDB");
   }
 }