Example #1
0
 /// <summary>
 /// 尝试绑定SNS账号信息
 /// </summary>
 /// <returns></returns>
 public string TryBindSnsRelation(string openid, long uid)
 {
     if (string.IsNullOrEmpty(Appkey))
     {
         return("未设置Appkey信息");
     }
     if (string.IsNullOrEmpty(Appsecret))
     {
         return("未设置Appsecret信息");
     }
     if (string.IsNullOrEmpty(SsoBaseUrl))
     {
         return("未设置SsoBaseUrl信息");
     }
     if (string.IsNullOrEmpty(openid))
     {
         return("未设置SNS账号Openid");
     }
     AppToken = EncryptMD5(Appkey + Appsecret);
     if (!SsoBaseUrl.EndsWith("/"))
     {
         SsoBaseUrl += "/";
     }
     JsonStr = HttpUtils.PostUrl(string.Format("{0}Authorize/TryBindSnsRelation", SsoBaseUrl), string.Format("Appkey={0}&token={1}&openid={2}&uid={3}", Appkey, AppToken, openid, uid));
     return(JsonStr);
 }
Example #2
0
 /// <summary>
 /// 校验SSO-server返回的身份信息
 /// </summary>
 /// <returns></returns>
 public string ValidateHylId()
 {
     if (string.IsNullOrEmpty(Hylid))
     {
         return("未设置Hylid信息");
     }
     if (string.IsNullOrEmpty(Appkey))
     {
         return("未设置Appkey信息");
     }
     if (string.IsNullOrEmpty(Appsecret))
     {
         return("未设置Appsecret信息");
     }
     if (string.IsNullOrEmpty(SsoBaseUrl))
     {
         return("未设置SsoBaseUrl信息");
     }
     AppToken = EncryptMD5(Appkey + Appsecret);
     if (!SsoBaseUrl.EndsWith("/"))
     {
         SsoBaseUrl += "/";
     }
     JsonStr = HttpUtils.PostUrl(string.Format("{0}Authorize/validate", SsoBaseUrl), string.Format("hylid={0}&Appkey={1}&token={2}", Hylid, Appkey, AppToken));
     return(JsonStr);
 }
Example #3
0
 /// <summary>
 /// 获取SSO-server的当前登录信息
 /// </summary>
 /// <returns></returns>
 public void TryGetUserInfo(string returnUrl, string openid, string unionid)
 {
     AppToken = EncryptMD5(Appkey + Appsecret);
     if (!SsoBaseUrl.EndsWith("/"))
     {
         SsoBaseUrl += "/";
     }
     HttpContext.Current.Response.Redirect(string.Format("{0}Authorize/TryGetUserInfo?Appkey={1}&token={2}&returnurl={3}&openid={4}&unionid={5}", SsoBaseUrl, Appkey, AppToken, returnUrl, openid, unionid));
 }
Example #4
0
        /// <summary>
        /// 自动登录
        /// </summary>
        /// <returns></returns>
        public void AutoLogin(string registerName, string registerpassword, string returnurl)
        {
            AppToken = EncryptMD5(Appkey + Appsecret);
            if (!SsoBaseUrl.EndsWith("/"))
            {
                SsoBaseUrl += "/";
            }
            string url = string.Empty;

            if (!string.IsNullOrEmpty(CompanyId))
            {
                url = string.Format("{0}Authorize/AutoLogin?Appkey={1}&token={2}&username={3}&Password={4}&returnUrl={5}&CompanyId={6}",
                                    SsoBaseUrl, Appkey, AppToken, registerName, registerpassword, returnurl, CompanyId);
            }
            else
            {
                url = string.Format("{0}Authorize/AutoLogin?Appkey={1}&token={2}&username={3}&Password={4}&returnUrl={5}",
                                    SsoBaseUrl, Appkey, AppToken, registerName, registerpassword, returnurl);
            }
            HttpContext.Current.Response.Redirect(url);
        }
Example #5
0
        /// <summary>
        /// 尝试注册新账户,如果没有则新注册
        /// </summary>
        /// <returns></returns>
        public string TryRegiste(string registerName, string registerpassword)
        {
            if (string.IsNullOrEmpty(Appkey))
            {
                return("未设置Appkey信息");
            }
            if (string.IsNullOrEmpty(Appsecret))
            {
                return("未设置Appsecret信息");
            }
            if (string.IsNullOrEmpty(SsoBaseUrl))
            {
                return("未设置SsoBaseUrl信息");
            }
            if (string.IsNullOrEmpty(registerName))
            {
                return("未设置注册用户名信息");
            }
            AppToken = EncryptMD5(Appkey + Appsecret);
            if (!SsoBaseUrl.EndsWith("/"))
            {
                SsoBaseUrl += "/";
            }
            string parameter = string.Empty;

            if (!string.IsNullOrEmpty(CompanyId))
            {
                parameter = string.Format("Appkey={0}&token={1}&username={2}&Password={3}&CompanyId={4}", Appkey, AppToken, registerName, registerpassword, CompanyId);
            }
            else
            {
                parameter = string.Format("Appkey={0}&token={1}&username={2}&Password={3}", Appkey, AppToken, registerName, registerpassword);
            }
            JsonStr = HttpUtils.PostUrl(string.Format("{0}Authorize/TryRegister", SsoBaseUrl), parameter);
            return(JsonStr);
        }