/// <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();
        }
Exemplo n.º 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);;
            }
        }
Exemplo n.º 3
0
 public OnlineIdAuthenticationProvider(
     string[] scopes, PromptType promptType = PromptType.PromptIfNeeded)
     : base(null, null, scopes)
 {
     this.authenticator        = new OnlineIdAuthenticator();
     this.credentialPromptType = (CredentialPromptType)promptType;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
 public OnlineIdAuthenticationProvider(ServiceInfo serviceInfo)
     : base(serviceInfo)
 {
     this.authenticator = new OnlineIdAuthenticator();
 }
Exemplo n.º 8
0
 public OnlineIdService()
 {
     _authenticator = new OnlineIdAuthenticator();
 }