/// <summary> /// Gets a configured authentication object for 'github.com'. /// </summary> /// <param name="targetUri">The uniform resource indicator of the resource which requires /// authentication.</param> /// <param name="tokenScope">The desired scope of any personal access tokens aqcuired.</param> /// <param name="personalAccessTokenStore">A secure secret store for any personal access /// tokens acquired.</param> /// <param name="authentication">(out) The authenitcation object if successful.</param> /// <returns>True if success; otherwise false.</returns> public static bool GetAuthentication( Uri targetUri, GithubTokenScope tokenScope, ICredentialStore personalAccessTokenStore, AcquireCredentialsDelegate acquireCredentialsCallback, AcquireAuthenticationCodeDelegate acquireAuthenticationCodeCallback, AuthenticationResultDelegate authenticationResultCallback, out BaseAuthentication authentication) { const string GitHubBaseUrlHost = "github.com"; BaseSecureStore.ValidateTargetUri(targetUri); if (personalAccessTokenStore == null) { throw new ArgumentNullException("personalAccessTokenStore", "The `personalAccessTokenStore` is null or invalid."); } Trace.WriteLine("GithubAuthentication::GetAuthentication"); if (targetUri.DnsSafeHost.EndsWith(GitHubBaseUrlHost, StringComparison.OrdinalIgnoreCase)) { authentication = new GithubAuthentication(tokenScope, personalAccessTokenStore, acquireCredentialsCallback, acquireAuthenticationCodeCallback, authenticationResultCallback); Trace.WriteLine(" authentication for GitHub created"); } else { authentication = null; Trace.WriteLine(" not github.com, authentication creation aborted"); } return(authentication != null); }
/// <summary> /// Gets a configured authentication object for 'github.com'. /// </summary> /// <param name="targetUri">The uniform resource indicator of the resource which requires /// authentication.</param> /// <param name="tokenScope">The desired scope of any personal access tokens aqcuired.</param> /// <param name="personalAccessTokenStore">A secure secret store for any personal access /// tokens acquired.</param> /// <param name="authentication">(out) The authenitcation object if successful.</param> /// <returns>True if success; otherwise false.</returns> public static bool GetAuthentication( Uri targetUri, GithubTokenScope tokenScope, ICredentialStore personalAccessTokenStore, AcquireCredentialsDelegate acquireCredentialsCallback, AcquireAuthenticationCodeDelegate acquireAuthenticationCodeCallback, AuthenticationResultDelegate authenticationResultCallback, out BaseAuthentication authentication) { const string GitHubBaseUrlHost = "github.com"; BaseSecureStore.ValidateTargetUri(targetUri); if (personalAccessTokenStore == null) throw new ArgumentNullException("personalAccessTokenStore", "The `personalAccessTokenStore` is null or invalid."); Trace.WriteLine("GithubAuthentication::GetAuthentication"); if (targetUri.DnsSafeHost.EndsWith(GitHubBaseUrlHost, StringComparison.OrdinalIgnoreCase)) { authentication = new GithubAuthentication(tokenScope, personalAccessTokenStore, acquireCredentialsCallback, acquireAuthenticationCodeCallback, authenticationResultCallback); Trace.WriteLine(" authentication for GitHub created"); } else { authentication = null; Trace.WriteLine(" not github.com, authentication creation aborted"); } return authentication != null; }