示例#1
0
                protected override IEnumerator <IteratorTask <object> .TaskStep> GetTasks()
                {
                    yield return(base.CallTask(this.tokenRenewer.tokenProvider.GetTokenAsync(this.appliesTo, this.action, false, this.timeout), IteratorTask <TResult> .ExceptionPolicy.Transfer));

                    SimpleWebSecurityToken simpleWebSecurityToken = (SimpleWebSecurityToken)base.LastTaskResult <SecurityToken>();

                    this.tokenRenewer.CurrentToken = simpleWebSecurityToken;
                }
示例#2
0
        private string GetAudienceFromToken(string token)
        {
            string str;

            if (!SimpleWebSecurityToken.Decode(token, SimpleWebSecurityToken.Decoder, SimpleWebSecurityToken.Decoder, this.KeyValueSeparator, this.PairSeparator).TryGetValue(this.AudienceFieldName, out str))
            {
                throw new FormatException(SRClient.TokenAudience);
            }
            return(str);
        }
        private static void WriteBinaryCore(SecurityToken token, out string id, out byte[] rawData)
        {
            SimpleWebSecurityToken simpleWebSecurityToken = token as SimpleWebSecurityToken;

            if (simpleWebSecurityToken == null)
            {
                throw new ArgumentNullException("token");
            }
            id      = simpleWebSecurityToken.Id;
            rawData = Encoding.UTF8.GetBytes(simpleWebSecurityToken.Token);
        }
示例#4
0
        protected override IAsyncResult OnBeginGetToken(string appliesTo, string action, TimeSpan timeout, AsyncCallback callback, object state)
        {
            DateTime dateTime;
            string   str;
            string   windowsAccessTokenCore = TokenProviderHelper.GetWindowsAccessTokenCore(this.stsUris.GetEnumerator(), this.onBuildUri, this.BuildRequestToken(appliesTo), timeout, out dateTime, out str);
            SimpleWebSecurityToken simpleWebSecurityToken = new SimpleWebSecurityToken(windowsAccessTokenCore, dateTime, str);

            TokenProviderHelper.TokenResult <SecurityToken> tokenResult = new TokenProviderHelper.TokenResult <SecurityToken>()
            {
                CacheUntil = dateTime,
                Token      = simpleWebSecurityToken
            };
            return(new CompletedAsyncResult <TokenProviderHelper.TokenResult <SecurityToken> >(tokenResult, callback, state));
        }
        internal static TokenProviderHelper.TokenResult <SecurityToken> GetAccessTokenByAssertion(Uri requestUri, string appliesTo, string requestToken, string simpleAuthAssertionFormat, TimeSpan timeout)
        {
            string   str;
            string   str1;
            string   accessTokenCore = TokenProviderHelper.GetAccessTokenCore(requestUri, appliesTo, requestToken, simpleAuthAssertionFormat, timeout, out str, out str1);
            DateTime dateTime        = TokenProviderHelper.ConvertExpiry(str);
            SimpleWebSecurityToken simpleWebSecurityToken = new SimpleWebSecurityToken(accessTokenCore, dateTime, str1);

            return(new TokenProviderHelper.TokenResult <SecurityToken>()
            {
                CacheUntil = dateTime,
                Token = simpleWebSecurityToken
            });
        }
        internal static TokenProviderHelper.TokenResult <SecurityToken> EndGetAccessTokenByAssertion(IAsyncResult result)
        {
            string   str;
            string   str1;
            string   str2     = TokenProviderHelper.EndGetAccessTokenCore(result, out str, out str1);
            DateTime dateTime = TokenProviderHelper.ConvertExpiry(str);
            SimpleWebSecurityToken simpleWebSecurityToken = new SimpleWebSecurityToken(str2, dateTime, str1);

            return(new TokenProviderHelper.TokenResult <SecurityToken>()
            {
                CacheUntil = dateTime,
                Token = simpleWebSecurityToken
            });
        }
示例#7
0
        private void GetExpirationDateAndAudienceFromToken(string token, out DateTime expiresOn, out string audience)
        {
            string str;
            IDictionary <string, string> strs = SimpleWebSecurityToken.Decode(token, SimpleWebSecurityToken.Decoder, SimpleWebSecurityToken.Decoder, this.KeyValueSeparator, this.PairSeparator);

            if (!strs.TryGetValue(this.ExpiresOnFieldName, out str))
            {
                throw new FormatException(SRClient.TokenExpiresOn);
            }
            if (!strs.TryGetValue(this.AudienceFieldName, out audience))
            {
                throw new FormatException(SRClient.TokenAudience);
            }
            expiresOn = SimpleWebSecurityToken.EpochTime + TimeSpan.FromSeconds(double.Parse(str, CultureInfo.InvariantCulture));
        }
示例#8
0
 public ServiceBusAuthorizationHeader(SimpleWebSecurityToken token)
 {
     this.simpleWebSecurityToken = token;
 }