예제 #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 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();

    }
예제 #3
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();


    }