Esempio n. 1
0
 /// <remarks/>
 public void RequestMultipleSecurityTokensAsync(RequestMultipleSecurityTokensType RequestMultipleSecurityTokens1) {
     this.RequestMultipleSecurityTokensAsync(RequestMultipleSecurityTokens1, null);
 }
Esempio n. 2
0
 /// <remarks/>
 public void RequestMultipleSecurityTokensAsync(RequestMultipleSecurityTokensType RequestMultipleSecurityTokens1, object userState) {
     if ((this.RequestMultipleSecurityTokensOperationCompleted == null)) {
         this.RequestMultipleSecurityTokensOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRequestMultipleSecurityTokensOperationCompleted);
     }
     this.InvokeAsync("RequestMultipleSecurityTokens", new object[] {
                 RequestMultipleSecurityTokens1}, this.RequestMultipleSecurityTokensOperationCompleted, userState);
 }
Esempio n. 3
0
        private void Authenticate(SecurityTokenService securService, MSNTicket msnticket, EventHandler onSuccess, EventHandler<ExceptionEventArgs> onError)
        {
            if (user.Split('@').Length > 1)
            {
                if (user.Split('@')[1].ToLower(CultureInfo.InvariantCulture) == "msn.com")
                {
                    securService.Url = @"https://msnia.login.live.com/RST2.srf";
                }
            }
            else
            {
                AuthenticationException authenticationException = new AuthenticationException("Invalid account. The account must contain @ char");
                if (onError != null && onSuccess != null)
                    onError(this, new ExceptionEventArgs(authenticationException));
                else
                    throw authenticationException;
            }

            RequestMultipleSecurityTokensType mulToken = new RequestMultipleSecurityTokensType();
            mulToken.Id = "RSTS";
            mulToken.RequestSecurityToken = auths.ToArray();

            // ASYNC
            if (onSuccess != null && onError != null)
            {
                securService.RequestMultipleSecurityTokensCompleted += delegate(object sender, RequestMultipleSecurityTokensCompletedEventArgs e)
                {
                    if (!e.Cancelled)
                    {
                        if (e.Error != null)
                        {
                            SoapException sex = e.Error as SoapException;
                            if (sex != null && ProcessError(securService, sex, msnticket, onSuccess, onError))
                                return;

                            MSNPSharpException sexp = new MSNPSharpException(e.Error.Message + ". See innerexception for detail.", e.Error);
                            if (securService.pp != null)
                                sexp.Data["Code"] = securService.pp.reqstatus;  //Error code

                            onError(this, new ExceptionEventArgs(sexp));
                        }
                        else if (e.Result != null)
                        {
                            GetTickets(e.Result, securService, msnticket);

                            onSuccess(this, EventArgs.Empty);
                        }
                        else
                        {
                            // Is this possible? Answer: No.
                        }
                    }
                };
                securService.RequestMultipleSecurityTokensAsync(mulToken, new object());
            }
            else
            {
                try
                {
                    RequestSecurityTokenResponseType[] result = securService.RequestMultipleSecurityTokens(mulToken);

                    if (result != null)
                    {
                        GetTickets(result, securService, msnticket);
                    }
                }
                catch (SoapException sex)
                {
                    if (ProcessError(securService, sex, msnticket, onSuccess, onError))
                        return;

                    throw sex;
                }
                catch (Exception ex)
                {
                    MSNPSharpException sexp = new MSNPSharpException(ex.Message + ". See innerexception for detail.", ex);

                    if (securService.pp != null)
                        sexp.Data["Code"] = securService.pp.reqstatus;  //Error code

                    throw sexp;
                }
            }
        }