using System;
using System.Collections.Generic;
using System.Text;

namespace DFS.Core.Mvc.Jwt.Model
{
    /// <summary>
    /// 开放的授权Client
    /// </summary>
    public class OpenClient
    {
        /// <summary>
        /// 客户端id
        /// </summary>
        public string AppId { get; set; }

        /// <summary>
        /// 秘钥
        /// </summary>
        public string Sign { get; set; }

        /// <summary>
        /// 时间戳
        /// </summary>
        public string TimeSpan { get; set; }

        public OpenClient(string appId, string sign, string timeSpan)
        {
            AppId = appId;
            Sign = sign;
            TimeSpan = timeSpan;
        }

        /// <summary>
        /// 验证当前时间是否过期
        /// </summary>
        /// <returns></returns>
        public virtual bool AuthTimeSpan()
        {
            if (TimeSpan.IsNullOrWhiteSpace())
            {
                return false;
            }
            if (TimeSpan.ToUTCTime().AddMinutes(5) > DateTime.UtcNow)
            {
                return true;
            }
            return false;
        }
    }
}
