protected override void RefreshToken()
        {
            _traceSource.TraceInformation("\nStarted using BrowserBasedTokenRetriever using {0}.", AuthenticationEndpoint);

            try
            {
                string stsToken = null;
                string issuingAuthority = ConfigItems["v2.FcsaIssuingAuthority"];

                var securityContextRetreiver = new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    using (var t = new BrowserTokenRetriever(AuthenticationEndpoint, issuingAuthority))
                    {
                        stsToken = t.RetrieveToken();
                    }
                });
                securityContextRetreiver.SetApartmentState(ApartmentState.STA);
                securityContextRetreiver.Start();
                securityContextRetreiver.Join(DefaultTimeoutInMiliSeconds);
                
                _token = !string.IsNullOrEmpty(stsToken) ? CleanToken(stsToken) : stsToken;

                _traceSource.TraceInformation("\nCompleted retrieving token from BrowerBasedTokenRetriever.");
            }
            catch (Exception ex)
            {
                _traceSource.TraceEvent(TraceEventType.Error, 0, "\nException occured during TokenRetriever RetrieveToken.\n" + UnwrapException(ex).ToString());
            }

            SetExpireDateFromToken();
        }
Пример #2
0
        protected override void RefreshToken()
        {
            _traceSource.TraceInformation("\nStarted using BrowserBasedTokenRetriever using {0}.", AuthenticationEndpoint);

            try
            {
                string stsToken         = null;
                string issuingAuthority = ConfigItems["v2.FcsaIssuingAuthority"];

                var securityContextRetreiver = new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    using (var t = new BrowserTokenRetriever(AuthenticationEndpoint, issuingAuthority))
                    {
                        stsToken = t.RetrieveToken();
                    }
                });
                securityContextRetreiver.SetApartmentState(ApartmentState.STA);
                securityContextRetreiver.Start();
                securityContextRetreiver.Join(DefaultTimeoutInMiliSeconds);

                _token = !string.IsNullOrEmpty(stsToken) ? CleanToken(stsToken) : stsToken;

                _traceSource.TraceInformation("\nCompleted retrieving token from BrowerBasedTokenRetriever.");
            }
            catch (Exception ex)
            {
                _traceSource.TraceEvent(TraceEventType.Error, 0, "\nException occured during TokenRetriever RetrieveToken.\n" + UnwrapException(ex).ToString());
            }

            SetExpireDateFromToken();
        }