コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdalAuthenticator"/> class.
        /// </summary>
        /// <param name="clientCredential">The client credential to use for token acquisition.</param>
        /// <param name="configurationOAuth">A configuration object for OAuth client credential authentication.</param>
        /// <param name="customHttpClient">A customized instance of the HttpClient class.</param>
        /// <param name="logger">The type used to perform logging.</param>
        public AdalAuthenticator(ClientCredential clientCredential, OAuthConfiguration configurationOAuth, HttpClient customHttpClient = null, ILogger logger = null)
        {
            this.authConfig       = configurationOAuth ?? throw new ArgumentNullException(nameof(configurationOAuth));
            this.clientCredential = clientCredential ?? throw new ArgumentNullException(nameof(clientCredential));
            this.logger           = logger;

            Initialize(configurationOAuth, customHttpClient);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdalAuthenticator"/> class.
        /// </summary>
        /// <param name="clientCertificate">A client credential that includes a X509Certificate.</param>
        /// <param name="sendX5c">Enables easy certificates roll-over in Azure AD. Setting it to true sends the public certficate to Azure AD along with token requests.</param>
        /// <param name="configurationOAuth">A configuration object for OAuth client credential authentication.</param>
        /// <param name="customHttpClient">A customized instance of the HttpClient class.</param>
        /// <param name="logger">The type used to perform logging.</param>
        public AdalAuthenticator(ClientAssertionCertificate clientCertificate, bool sendX5c, OAuthConfiguration configurationOAuth, HttpClient customHttpClient = null, ILogger logger = null)
        {
            this.authConfig        = configurationOAuth ?? throw new ArgumentNullException(nameof(configurationOAuth));
            this.clientCertificate = clientCertificate ?? throw new ArgumentNullException(nameof(clientCertificate));
            this.logger            = logger;
            this.clientCertSendX5c = sendX5c;

            Initialize(configurationOAuth, customHttpClient);
        }
コード例 #3
0
 private void Initialize(OAuthConfiguration configurationOAuth, HttpClient customHttpClient)
 {
     if (customHttpClient != null)
     {
         var httpClientFactory = new ConstantHttpClientFactory(customHttpClient);
         this.authContext = new AuthenticationContext(configurationOAuth.Authority, configurationOAuth.ValidateAuthority, new TokenCache(), httpClientFactory);
     }
     else
     {
         this.authContext = new AuthenticationContext(configurationOAuth.Authority, configurationOAuth.ValidateAuthority);
     }
 }
コード例 #4
0
ファイル: AdalAuthenticator.cs プロジェクト: DDEfromOR/se
        public AdalAuthenticator(ClientCredential clientCredential, OAuthConfiguration oAuthConfig, HttpClient customHttpClient = null)
        {
            this.oAuthConfig      = oAuthConfig ?? throw new ArgumentNullException(nameof(oAuthConfig));
            this.clientCredential = clientCredential ?? throw new ArgumentNullException(nameof(clientCredential));

            if (customHttpClient != null)
            {
                this.authContext = new AuthenticationContext(oAuthConfig.Authority, true, new TokenCache(), customHttpClient);
            }
            else
            {
                this.authContext = new AuthenticationContext(oAuthConfig.Authority);
            }
        }
コード例 #5
0
        public AdalAuthenticator(ClientCredential clientCredential, OAuthConfiguration configurationOAuth, HttpClient customHttpClient = null)
        {
            this._oAuthConfig     = configurationOAuth ?? throw new ArgumentNullException(nameof(configurationOAuth));
            this.clientCredential = clientCredential ?? throw new ArgumentNullException(nameof(clientCredential));

            if (customHttpClient != null)
            {
                var httpClientFactory = new ConstantHttpClientFactory(customHttpClient);
                this.authContext = new AuthenticationContext(configurationOAuth.Authority, true, new TokenCache(), httpClientFactory);
            }
            else
            {
                this.authContext = new AuthenticationContext(configurationOAuth.Authority);
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdalAuthenticator"/> class.
 /// </summary>
 /// <param name="clientCertificate">A client credential that includes a X509Certificate.</param>
 /// <param name="configurationOAuth">A configuration object for OAuth client credential authentication.</param>
 /// <param name="customHttpClient">A customized instance of the HttpClient class.</param>
 /// <param name="logger">The type used to perform logging.</param>
 public AdalAuthenticator(ClientAssertionCertificate clientCertificate, OAuthConfiguration configurationOAuth, HttpClient customHttpClient = null, ILogger logger = null)
     : this(clientCertificate, false, configurationOAuth, customHttpClient, logger)
 {
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdalAuthenticator"/> class.
 /// </summary>
 /// <param name="clientCredential">The client credential to use for token acquisition.</param>
 /// <param name="configurationOAuth">A configuration object for OAuth client credential authentication.</param>
 /// <param name="customHttpClient">A customized instance of the HttpClient class.</param>
 public AdalAuthenticator(ClientCredential clientCredential, OAuthConfiguration configurationOAuth, HttpClient customHttpClient = null)
     : this(clientCredential, configurationOAuth, customHttpClient, null)
 {
 }