コード例 #1
0
        /// <summary>
        /// Creates a new TailoredAuthClient class.
        /// </summary>
        /// <param name="authClient">The LiveAuthClient instance.</param>
        public TailoredAuthClient(LiveAuthClient authClient)
        {
            Debug.Assert(authClient != null, "authClient cannot be null.");

            this.authClient    = authClient;
            this.authenticator = new OnlineIdAuthenticator();
        }
コード例 #2
0
        public async Task <bool> EnsureUserIdentityAsync(
            CancellationToken cancelToken,
            string msaAuthPolicy)
        {
            OnlineIdServiceTicketRequest[] tickets = new OnlineIdServiceTicketRequest[]
            {
                new OnlineIdServiceTicketRequest(
                    LiveIdHostName,
                    msaAuthPolicy)
            };

            try
            {
                var onlineIdAuthenticator = new OnlineIdAuthenticator();
                m_userIdentity = await onlineIdAuthenticator.AuthenticateUserAsync(tickets, CredentialPromptType.PromptIfNeeded);

                return(true);
            }
            catch (TaskCanceledException) {
                throw;
            }
            catch (Exception)
            {
                return(false);;
            }
        }
コード例 #3
0
 public OnlineIdAuthenticationProvider(
     string[] scopes, PromptType promptType = PromptType.PromptIfNeeded)
     : base(null, null, scopes)
 {
     this.authenticator        = new OnlineIdAuthenticator();
     this.credentialPromptType = (CredentialPromptType)promptType;
 }
コード例 #4
0
 public MainPage()
 {
     this.InitializeComponent();
     Current          = this;
     _authenticator   = new OnlineIdAuthenticator();
     PromptType       = CredentialPromptType.PromptIfNeeded;
     AccessToken      = null;
     NeedsToGetTicket = true;
 }
        public Scenario01_DelegationToken()
        {
            this.InitializeComponent();

            _authenticator = new OnlineIdAuthenticator();

            PromptType = CredentialPromptType.PromptIfNeeded;
            SignInOptions.SelectedItem = PromptIfNeeded;
            AccessToken              = null;
            NeedsToGetTicket         = true;
            SignOutButton.Visibility = CanSignOut ? Visibility.Visible : Visibility.Collapsed;
        }
コード例 #6
0
        public async Task <AuthResult> AuthAsync(string startUrl, string endUrlPrefix)
        {
            AuthResult result = new AuthResult(WebAuthenticationStatus.UserCancel);
            Uri        start  = null;

            OnlineIdServiceTicketRequest[] tickets = new OnlineIdServiceTicketRequest[]
            {
                new OnlineIdServiceTicketRequest(
                    new Uri(startUrl).Host,
                    String.IsNullOrEmpty(LiveIdAuthPolicy)
                        ? ServiceDefinition.DefaultLiveIdAuthPolicy
                        : LiveIdAuthPolicy)
            };

            try
            {
                var          onlineIdAuthenticator = new OnlineIdAuthenticator();
                UserIdentity useridentity          =
                    await onlineIdAuthenticator.AuthenticateUserAsync(tickets, CredentialPromptType.PromptIfNeeded);

                if (useridentity != null && useridentity.Tickets != null && useridentity.Tickets.Count > 0)
                {
                    OnlineIdServiceTicket ticket = useridentity.Tickets.First();
                    start = new Uri(startUrl + WebUtility.UrlEncode("&" + ticket.Value) + "&mobile=true");
                }
            }
            catch (TaskCanceledException)
            {
                result.Status = WebAuthenticationStatus.UserCancel;
            }
            catch
            {
                start = new Uri(startUrl + "&mobile=true");
            }

            if (start != null)
            {
                WebAuthenticationResult webAuthResult = (await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, start, new Uri(endUrlPrefix)));
                result = new AuthResult(webAuthResult);
            }

            return(result);
        }
コード例 #7
0
 public OnlineIdAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
     this.authenticator = new OnlineIdAuthenticator();
 }
コード例 #8
0
 public OnlineIdService()
 {
     _authenticator = new OnlineIdAuthenticator();
 }