コード例 #1
0
        internal AdalAuthenticationProviderBase(
            string clientId,
            string returnUrl,
            AuthenticationContext authenticationContext)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ServiceException(
                          new Error
                {
                    Code    = OAuthConstants.ErrorCodes.AuthenticationFailure,
                    Message = "AdalAuthenticationProvider requires a client ID for authenticating users."
                });
            }

            this.clientId  = clientId;
            this.returnUrl = returnUrl;

            if (authenticationContext != null)
            {
                this.authenticationContextWrapper = new AuthenticationContextWrapper(authenticationContext);
            }
            else
            {
                this.authenticationContextWrapper = new AuthenticationContextWrapper(
                    new AuthenticationContext(OAuthConstants.ActiveDirectoryAuthenticationServiceUrl));
            }

            this.adalCredentialCache = new AdalCredentialCache(this.authenticationContextWrapper.TokenCache);
        }
コード例 #2
0
 /// <summary>
 /// Constructor for unit testing.
 /// </summary>
 /// <param name="clientId">The ID of the client.</param>
 /// <param name="returnUrl">The return URL for the client.</param>
 /// <param name="authenticationContextWrapper">The context for authenticating against AAD.</param>
 internal AdalAuthenticationProviderBase(
     string clientId,
     string returnUrl,
     IAuthenticationContextWrapper authenticationContextWrapper)
 {
     this.clientId                     = clientId;
     this.returnUrl                    = returnUrl;
     this.adalCredentialCache          = new AdalCredentialCache(authenticationContextWrapper.TokenCache);
     this.authenticationContextWrapper = authenticationContextWrapper;
 }