/// <summary> /// Constructor /// </summary> /// <param name="applicationToken">An application token to be used as the file name to store data as. Each /// consuming application should use a unique name in order to ensure that the user credentials are not /// overwritten by other applications.</param> /// <param name="encryptionKey">The encryption key, or salt, to be used for any encryption routines. This salt /// should be different for each user, and not the same for everyone consuming the same application. Only used /// for UI support.</param> /// <param name="encryptionRoutines">The encryption routines to use for encryption/decryption of data. Only used for UI support.</param> /// <param name="webServiceVersion">The version of the WSAPI API to use.</param> /// <param name="traceInfo">Controls diagnostic trace information being logged</param> public RestApiAuthMgrWinforms(string applicationToken, string encryptionKey, IEncryptionRoutines encryptionRoutines, string webServiceVersion = RallyRestApi.DEFAULT_WSAPI_VERSION, TraceFieldEnum traceInfo = RallyRestApi.DEFAULT_TRACE_FIELDS) : base(true, applicationToken, encryptionKey, encryptionRoutines, webServiceVersion, traceInfo) { }
/// <summary> /// Constructor /// </summary> /// <param name="webServiceVersion">The version of the WSAPI API to use.</param> /// <param name="traceInfo">Controls diagnostic trace information being logged</param> public ApiConsoleAuthManager(string webServiceVersion = RallyRestApi.DEFAULT_WSAPI_VERSION, TraceFieldEnum traceInfo = RallyRestApi.DEFAULT_TRACE_FIELDS) : base(false, null, null, null, webServiceVersion, traceInfo) { }
/// <summary> /// Construct a new RallyRestApi configured to work with the specified WSAPI version /// </summary> /// <param name="authManger">The authorization manager to use when authentication requires it. If no driver is /// provided a console authentication manager will be used which does not allow SSO authentication.</param> /// <param name="webServiceVersion">The WSAPI version to use (defaults to DEFAULT_WSAPI_VERSION)</param> /// <param name="maxRetries">Requests will be attempted a number of times (defaults to 3)</param> /// <param name="traceInfo">Controls diagnostic trace information being logged</param> /// <example> /// For a console application, no authentication manager is needed as shown in this example. /// <code language="C#"> /// RallyRestApi restApi = new RallyRestApi(); /// </code> /// For UI applications, an authentication manager must be provided. The authentication providers will /// configure the API and create the linkages as part of the constructor. Please see the documentation for /// the RestApiAuthMgrWpf and RestApiAuthMgrWinforms for more information. /// <code language="C#"> /// // 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(); /// /// // Instantiate authorization manager /// wpfAuthMgr = new RestApiAuthMgrWpf(applicationToken, encryptionKey, encryptionUtilities); /// </code> /// </example> public RallyRestApi(ApiAuthManager authManger = null, string webServiceVersion = DEFAULT_WSAPI_VERSION, int maxRetries = 3, TraceFieldEnum traceInfo = RallyRestApi.DEFAULT_TRACE_FIELDS) { // NOTE: The example for using the RestApiAuthMgrWpf is also shown there. Make sure you // update both if you change it. TraceHelper.TraceFields = traceInfo; if (authManger == null) authManger = new ApiConsoleAuthManager(webServiceVersion, traceInfo); this.authManger = authManger; WsapiVersion = webServiceVersion; if (String.IsNullOrWhiteSpace(WsapiVersion)) WsapiVersion = DEFAULT_WSAPI_VERSION; AuthenticationState = AuthenticationResult.NotAuthorized; this.maxRetries = maxRetries; }
/// <summary> /// Constructor /// </summary> /// <param name="isUiSupported">Does this authentication manager support a UI?</param> /// <param name="applicationToken">An application token to be used as the file name to store data as (no extension needed). Each /// consuming application should use a unique name in order to ensure that the user credentials are not /// overwritten by other applications. An exception will be thrown elsewhere if this is not a valid file name.</param> /// <param name="encryptionKey">The encryption key, or salt, to be used for any encryption routines. This salt /// should be different for each user, and not the same for everyone consuming the same application. Only used /// for UI support.</param> /// <param name="encryptionRoutines">The encryption routines to use for encryption/decryption of data. Only used for UI support.</param> /// <param name="webServiceVersion">The version of the WSAPI API to use.</param> /// <param name="traceInfo">Controls diagnostic trace information being logged</param> protected ApiAuthManager(bool isUiSupported, string applicationToken, string encryptionKey, IEncryptionRoutines encryptionRoutines, string webServiceVersion = RallyRestApi.DEFAULT_WSAPI_VERSION, TraceFieldEnum traceInfo = RallyRestApi.DEFAULT_TRACE_FIELDS) { if (isUiSupported) { if (String.IsNullOrWhiteSpace(applicationToken)) { throw new ArgumentNullException("applicationToken", "You must provide an application token."); } if (encryptionKey == null) { throw new ArgumentNullException("encryptionKey", "You must provide an encryption key that will be used to keep user data safe."); } if (encryptionRoutines == null) { throw new ArgumentNullException("encryptionRoutines", "You must provide encryption routines that will be used to keep user data safe."); } ApplicationToken = applicationToken; EncryptionKey = encryptionKey; EncryptionRoutines = encryptionRoutines; LoginDetails = new LoginDetails(this); LoginDetails.LoadFromDisk(); } IsUiSupported = isUiSupported; Api = new RallyRestApi(this, webServiceVersion: webServiceVersion, traceInfo: traceInfo); }