Exemplo n.º 1
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);
        }
Exemplo n.º 2
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));
        }