public void Setup()
        {
            this.appConfig = new AppConfig();
            this.authenticationProvider = new MockAuthenticationProvider();
            this.authenticationProvider.Setup(provider => provider.AuthenticateAsync()).Returns(Task.FromResult(new AccountSession()));
            this.authenticationProvider.Setup(provider => provider.AppendAuthHeaderAsync(It.IsAny<HttpRequestMessage>())).Returns(Task.FromResult(0));
            this.credentialCache = new MockCredentialCache();
            this.serializer = new MockSerializer();
            this.httpResponseMessage = new HttpResponseMessage();
            this.httpProvider = new MockHttpProvider(this.httpResponseMessage, this.serializer.Object);
            this.serviceInfo = new ServiceInfo
            {
                AuthenticationProvider = this.authenticationProvider.Object,
            };

            this.serviceInfoProvider = new MockServiceInfoProvider(this.serviceInfo);
            this.webUi = new MockWebAuthenticationUi();
            this.oneDriveClient = new OneDriveClient(
                this.appConfig,
                this.credentialCache.Object,
                this.httpProvider.Object,
                this.serviceInfoProvider.Object)
            {
                BaseUrl = string.Format(Constants.Authentication.OneDriveConsumerBaseUrlFormatString, "v1.0"),
                ServiceInfo = this.serviceInfo,
            };
        }
        /// <summary>
        /// Constructs an <see cref="AdalAuthenticationByCodeAuthenticationProvider"/> for use with web apps that perform their own initial login
        /// and already have a code for receiving an authentication token.
        /// </summary>
        /// <param name="serviceInfo">The information for authenticating against the service.</param>
        /// <param name="authenticationCode">The code for retrieving the authentication token.</param>
        public AdalAuthenticationByCodeAuthenticationProvider(
            ServiceInfo serviceInfo,
            string authenticationCode)
            : base(serviceInfo, currentAccountSession: null)
        {
            if (string.IsNullOrEmpty(authenticationCode))
            {
                throw new OneDriveException(
                    new Error
                    {
                        Code = OneDriveErrorCode.AuthenticationFailure.ToString(),
                        Message = "Authorization code is required for authentication by code.",
                    });
            }

            this.allowDiscoveryService = false;
            this.authenticationCode = authenticationCode;
        }
        public void Setup()
        {
            this.credentialCache = new MockCredentialCache();
            this.webAuthenticationUi = new MockWebAuthenticationUi();
            this.webAuthenticationUi.OnAuthenticateAsync = this.OnAuthenticateAsync;

            this.serviceInfo = new ServiceInfo
            {
                AppId = "12345",
                AuthenticationServiceUrl = "https://login.live.com/authenticate",
                CredentialCache = this.credentialCache,
                Scopes = new string[] { "scope1", "scope2" },
                SignOutUrl = "https://login.live.com/signout",
                TokenServiceUrl = "https://login.live.com/token",
                WebAuthenticationUi = this.webAuthenticationUi
            };

            this.authenticationProvider = new WebAuthenticationBrokerAuthenticationProvider(this.serviceInfo);
        }
        public void Setup()
        {
            this.credentialCache = new MockAdalCredentialCache();
            this.httpResponseMessage = new HttpResponseMessage();
            this.serializer = new Serializer();
            this.httpProvider = new MockHttpProvider(this.httpResponseMessage, this.serializer);

            this.serviceInfo = new ActiveDirectoryServiceInfo
            {
                AppId = "12345",
                AuthenticationServiceUrl = "https://login.live.com/authenticate",
                CredentialCache = this.credentialCache.Object,
                HttpProvider = this.httpProvider.Object,
                ReturnUrl = "https://login.live.com/return",
                SignOutUrl = "https://login.live.com/signout",
                TokenServiceUrl = "https://login.live.com/token"
            };

            this.authenticationProvider = new AdalAuthenticationProvider(this.serviceInfo);
        }
        public virtual void Setup()
        {
            this.httpResponseMessage = new HttpResponseMessage();
            this.credentialCache = new MockCredentialCache();
            this.serializer = new MockSerializer();
            this.httpProvider = new MockHttpProvider(this.httpResponseMessage, this.serializer.Object);
            this.webUi = new MockWebUi();

            this.serviceInfo = new ServiceInfo
            {
                AppId = "12345",
                AuthenticationServiceUrl = "https://login.live.com/authenticate",
                CredentialCache = this.credentialCache.Object,
                HttpProvider = this.httpProvider.Object,
                ReturnUrl = "https://login.live.com/return",
                Scopes = new string[] { "scope1", "scope2" },
                SignOutUrl = "https://login.live.com/signout",
                TokenServiceUrl = "https://login.live.com/token",
                WebAuthenticationUi = this.webUi.Object
            };
        }
        public void Setup()
        {
            this.serviceInfo = new ServiceInfo
            {
                AppId = "12345",
                AuthenticationServiceUrl = "https://login.live.com/authenticate",
                ReturnUrl = "https://login.live.com/return",
                Scopes = new string[] { "scope1", "scope2" },
                SignOutUrl = "https://login.live.com/signout",
                TokenServiceUrl = "https://login.live.com/token",
            };

            this.oAuthRequestStringBuilder = new OAuthRequestStringBuilder(this.serviceInfo);
        }
 public MicrosoftAccountAuthenticationProvider(ServiceInfo serviceInfo)
     : base (serviceInfo)
 {
     this.callbackUri = new Uri(serviceInfo.ReturnUrl);
 }
 /// <summary>
 /// Constructs an <see cref="AdalAuthenticationProviderBase"/>.
 /// </summary>
 /// <param name="serviceInfo">The information for authenticating against the service.</param>
 /// <param name="currentAccountSession">The current account session, used for initializing an already logged in user.</param>
 protected AdalAuthenticationProviderBase(ServiceInfo serviceInfo, AccountSession currentAccountSession = null)
 {
     this.CurrentAccountSession = currentAccountSession;
     this.ServiceInfo = serviceInfo;
 }
 /// <summary>
 /// Instantiates a new instance of <see cref="AdalRedeemRefreshTokenHelper"/>.
 /// </summary>
 /// <param name="serviceInfo">The information for authenticating against the service.</param>
 /// <param name="authenticationContextWrapper"></param>
 public AdalRedeemRefreshTokenHelper(ServiceInfo serviceInfo, IAuthenticationContextWrapper authenticationContextWrapper)
 {
     this.authenticationContextWrapper = authenticationContextWrapper;
     this.serviceInfo = serviceInfo;
 }
 /// <summary>
 /// Constructs an <see cref="AdalAuthenticationProvider"/>.
 /// </summary>
 /// <param name="serviceInfo">The information for authenticating against the service.</param>
 /// <param name="currentAccountSession">The current account session, used for initializing an already logged in user.</param>
 public AdalAuthenticationProvider(ServiceInfo serviceInfo, AccountSession currentAccountSession = null)
     : base(serviceInfo, currentAccountSession)
 {
 }
 /// <summary>
 /// Constructs an <see cref="AdalAuthenticationProvider"/>.
 /// </summary>
 /// <param name="serviceInfo">The information for authenticating against the service.</param>
 /// <param name="currentAccountSession">The current account session, used for initializing an already logged in user.</param>
 public AdalAuthenticationProvider(ServiceInfo serviceInfo, AccountSession currentAccountSession = null)
     : base(serviceInfo, currentAccountSession)
 {
 }
 /// <summary>
 /// Constructs an <see cref="AuthenticationProvider"/>.
 /// </summary>
 protected AuthenticationProvider(ServiceInfo serviceInfo)
 {
     this.ServiceInfo = serviceInfo;
 }
 public WebAuthenticationBrokerAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
 }
 public MicrosoftAccountAuthenticationProvider(ServiceInfo serviceInfo)
     : base (serviceInfo)
 {
 }
Example #15
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AdalRedeemRefreshTokenHelper"/>.
 /// </summary>
 /// <param name="serviceInfo">The information for authenticating against the service.</param>
 /// <param name="authenticationContextWrapper"></param>
 public AdalRedeemRefreshTokenHelper(ServiceInfo serviceInfo, IAuthenticationContextWrapper authenticationContextWrapper)
 {
     this.authenticationContextWrapper = authenticationContextWrapper;
     this.serviceInfo = serviceInfo;
 }
 public AndroidAuthenticationProvider(ServiceInfo serviceInfo) : base(serviceInfo)
 {
 }
 public MicrosoftAccountAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
 }
 public OnlineIdAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
     this.authenticator = new OnlineIdAuthenticator();
 }
Example #19
0
 /// <summary>
 /// Constructs an <see cref="AuthenticationProvider"/>.
 /// </summary>
 protected AuthenticationProvider(ServiceInfo serviceInfo)
 {
     this.ServiceInfo = serviceInfo;
 }
 /// <summary>
 /// Constructs an <see cref="AdalAuthenticationProviderBase"/>.
 /// </summary>
 /// <param name="serviceInfo">The information for authenticating against the service.</param>
 /// <param name="currentAccountSession">The current account session, used for initializing an already logged in user.</param>
 protected AdalAuthenticationProviderBase(ServiceInfo serviceInfo, AccountSession currentAccountSession = null)
 {
     this.CurrentAccountSession = currentAccountSession;
     this.ServiceInfo           = serviceInfo;
 }
 public WebAuthenticationBrokerAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
 }
 public OnlineIdAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
     this.authenticator = new OnlineIdAuthenticator();
 }
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        /// <returns>The current account session.</returns>
        public async Task<AccountSession> AuthenticateAsync()
        {
            if (this.ServiceInfo == null)
            {
                this.ServiceInfo = await this.serviceInfoProvider.GetServiceInfo(
                    this.appConfig,
                    this.credentialCache,
                    this.HttpProvider,
                    this.ClientType);
            }

            var authResult = await this.ServiceInfo.AuthenticationProvider.AuthenticateAsync();

            if (string.IsNullOrEmpty(this.BaseUrl))
            {
                this.BaseUrl = this.ServiceInfo.BaseUrl;
            }

            return authResult;
        }
 public OAuthRequestStringBuilder(ServiceInfo serviceInfo)
 {
     this.serviceInfo = serviceInfo;
 }
        public void ServiceInfo_Set()
        {
            var newServiceInfo = new ServiceInfo { AuthenticationServiceUrl = "https://login.live.com/authenticate" };
            this.authenticationProvider.authenticationContextWrapper = null;
            this.authenticationProvider.ServiceInfo = newServiceInfo;

            Assert.AreEqual(newServiceInfo, this.authenticationProvider.ServiceInfo, "Service info not correctly initialized.");
            Assert.IsNotNull(this.authenticationProvider.authenticationContextWrapper, "Authentication context wrapper not correctly initialized.");
        }
 public IosAuthenticationProvider(ServiceInfo serviceInfo) : base(serviceInfo) {
 }