Example #1
0
        //private static X509Certificate2 CreateCertificate()
        //{
        //    TkDebug.ThrowIfNoAppSetting();
        //    string fileName = Path.Combine(BaseAppSetting.Current.XmlPath, "YJC.Toolkit2.pfx");
        //    X509Certificate2 cer = new X509Certificate2(fileName, "helloworld", (X509KeyStorageFlags)32); //, (X509KeyStorageFlags)32 | X509KeyStorageFlags.Exportable
        //    return cer;
        //}

        public static string CreateEncodingInfo(IUserInfo userInfo, string hostValue, int?port)
        {
            if (userInfo is JWTUserInfo jwtInfo)
            {
                return(EncodeToJwt(jwtInfo));
            }
            else
            {
                if (userInfo.IsSupportTenant())
                {
                    jwtInfo = new JWTTetantUserInfo(userInfo)
                    {
                        Host = hostValue,
                        Port = port
                    }
                }
                ;
                else
                {
                    jwtInfo = new JWTUserInfo(userInfo)
                    {
                        Host = hostValue,
                        Port = port
                    }
                };
                return(EncodeToJwt(jwtInfo));
            }
        }
Example #2
0
        public static JWTUserInfo DecodeFromJwt(string token)
        {
            string            json   = JWT.JWT.Decode(token, SecretKey); //fCertificate.GetRSAPrivateKey());
            JWTTetantUserInfo result = json.ReadJson <JWTTetantUserInfo>();

            if (string.IsNullOrEmpty(result.TenantId?.ToString()))
            {
                JWTUserInfo info = new JWTUserInfo(result);
                return(info);
            }
            else
            {
                return(result);
            }
        }