Click or drag to resize
Rally.RestApi.UiForWinforms Namespace

This library provides a reusable UI for Winforms to provide common authentication.

NOTE: If you need IDP based SSO, you must use the UI for WPF instead as the IDP support was not implemented in the Winforms libraries.

This pseudo code example shows how to use the UI for Winforms. For a full working sample, please see the code in Test.Rally.RestApi.UiSample within the repository.

C#
                  public static RestApiAuthMgrWinforms winFormsAuthMgr { get; set; }

public static void PrimaryEntryMethod()
{
    // HELP: Define your encryption items prior to instantiating authorization managers
    // You must define your own private application token. This ensures that your login details are not overwritten by someone else.
    string applicationToken = "RallyRestAPISample";
    // You must set a user specific salt for encryption.
    string encryptionKey = "UserSpecificSaltForEncryption";
    // You must define your own encryption routines.
    IEncryptionRoutines encryptionUtilities = new EncryptionUtilities();

    // HELP: Instantiate authorization manager
    winFormsAuthMgr = new RestApiAuthMgrWinforms(applicationToken, encryptionKey, encryptionUtilities);

    // HELP: Configure labels for UI. These are global and used by the authentication manager to build their UI.
    // If this is not called, the default labels will be used. In this sample we are changing a label and the default server URL.
    ApiAuthManager.Configure(loginWindowServerLabelText: "My Updated Server Label", loginWindowDefaultServer: new Uri("http://onprem-url"));

    // HELP: Set the logo that is shown in the login window
    RestApiAuthMgrWinforms.SetLogo(ImageResources.RallyLogo40x40);

    // Help: You can auto-authenticate if you want. We do not have it enabled for this application.
    // winFormsAuthMgr.AutoAuthenticate(true);
}

// HELP: This method shows you how to open a login window.
private void openWinformsLogin_Click(object sender, RoutedEventArgs e)
{
    // HELP: Delegates are provided so we can be notified that authentication or SSO authentication has completed.
    winFormsAuthMgr.ShowUserLoginWindow(AuthenticationComplete, SsoAuthenticationComplete);
}

// HELP: This delegate notifies us that authentication has completed.
private void AuthenticationComplete(RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api)
{
    UpdateAuthenticationResults(authenticationResult, api);
}

// HELP: This delegate notifies us that SSO authentication has completed.
private void SsoAuthenticationComplete(RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api)
{
    UpdateAuthenticationResults(authenticationResult, api);
}

// HELP: This method handles the passthrough from the delegates.
// This is where you would need to update your application to show the logged in state.
private void UpdateAuthenticationResults(RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api)
{
    // Change your applications behavoir based upon the new AuthenticationResult
}
Classes
  Class Description
Public class RestApiAuthMgrWinforms
A Winforms based authentication manager.