Пример #1
0
        /// <summary>
        /// Create an application token provider that can retrieve tokens for the given application from the given context, using the given audience
        /// and certificate.
        /// See <see href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/">Active Directory Quickstart for .Net</see>
        /// for detailed instructions on creating an Azure Active Directory application.
        /// </summary>
        /// <param name="context">The authentication context to use when retrieving tokens.</param>
        /// <param name="tokenAudience">The token audience to use when retrieving tokens.</param>
        /// <param name="certificate">The certificate associated with Active Directory application.</param>
        /// <param name="authenticationResult">The token details provided when authenticating with the client credentials.</param>
        public ApplicationTokenProvider(AuthenticationContext context, string tokenAudience, ClientAssertionCertificate certificate, AuthenticationResult authenticationResult)
        {
            if (certificate == null)
            {
                throw new ArgumentNullException("certificate");
            }

            if (authenticationResult == null)
            {
                throw new ArgumentNullException("authenticationResult");
            }

            Initialize(context, tokenAudience, certificate.ClientId,
                       new CertificateAuthenticationProvider((clientId) => Task.FromResult(certificate)),
                       authenticationResult, authenticationResult.ExpiresOn);
        }
Пример #2
0
 /// <summary>
 /// Creates ServiceClientCredentials for authenticating requests as an active directory application using a certificate credential. Uses the default service settings
 /// for azure resource manager (authority, token audience) during authentication.
 /// See <see href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/">Active Directory Quickstart for .Net</see>
 /// for detailed instructions on creating an Azure Active Directory application.
 /// </summary>
 /// <param name="domain">The active directory domain or tenantId to authenticate with.</param>
 /// <param name="certificate">The certificate associated with Active Directory application.</param>
 /// <param name="cache">The token cache to target during authentication.</param>
 /// <returns>A ServiceClientCredentials object that can authenticate http requests as the given application.</returns>
 public static async Task <ServiceClientCredentials> LoginSilentWithCertificateAsync(string domain, ClientAssertionCertificate certificate, TokenCache cache)
 {
     return(await LoginSilentAsync(domain, certificate, ActiveDirectoryServiceSettings.Azure, cache));
 }
Пример #3
0
 /// <summary>
 /// Creates ServiceClientCredentials for authenticating requests as an active directory application using a certificate credential. Uses the default token cache for authentication.
 /// See <see href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/">Active Directory Quickstart for .Net</see>
 /// for detailed instructions on creating an Azure Active Directory application.
 /// </summary>
 /// <param name="domain">The active directory domain or tenantId to authenticate with.</param>
 /// <param name="certificate">The certificate associated with Active Directory application.</param>
 /// <param name="settings">The active directory service side settings, including authority and token audience.</param>
 /// <returns>A ServiceClientCredentials object that can authenticate http requests as the given application.</returns>
 public static async Task <ServiceClientCredentials> LoginSilentWithCertificateAsync(string domain, ClientAssertionCertificate certificate, ActiveDirectoryServiceSettings settings)
 {
     return(await LoginSilentAsync(domain, certificate, settings, TokenCache.DefaultShared));
 }
Пример #4
0
 /// <summary>
 /// Creates ServiceClientCredentials for authenticating requests as an active directory application using a certificate credential.
 /// See <see href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/">Active Directory Quickstart for .Net</see>
 /// for detailed instructions on creating an Azure Active Directory application.
 /// </summary>
 /// <param name="domain">The active directory domain or tenantId to authenticate with.</param>
 /// <param name="certificate">The certificate associated with Active Directory application.</param>
 /// <param name="settings">The active directory service side settings, including authority and token audience.</param>
 /// <param name="cache">The token cache to target during authentication.</param>
 /// <returns>A ServiceClientCredentials object that can authenticate http requests as the given application.</returns>
 public static async Task <ServiceClientCredentials> LoginSilentAsync(string domain, ClientAssertionCertificate certificate,
                                                                      ActiveDirectoryServiceSettings settings, TokenCache cache)
 {
     return(await LoginSilentAsync(domain, certificate.ClientId,
                                   new CertificateAuthenticationProvider((clientId) => Task.FromResult(certificate)), settings, cache));
 }