Esempio n. 1
0
 protected override string AuthenticateToken(UsernameToken token)
 {
     Hidistro.Membership.Core.Enums.LoginUserStatus loginUserStatus;
     try
     {
         Hidistro.Membership.Context.SiteManager siteManager = Hidistro.Membership.Context.Users.GetUser(0, token.Identity.Name, false, false) as Hidistro.Membership.Context.SiteManager;
         if (siteManager != null && siteManager.IsAdministrator)
         {
             Hidistro.Membership.Context.HiContext arg_29_0 = Hidistro.Membership.Context.HiContext.Current;
             siteManager.Password = HiCryptographer.Decrypt(token.Password);
             loginUserStatus      = Hidistro.Membership.Context.Users.ValidateUser(siteManager);
         }
         else
         {
             loginUserStatus = Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials;
         }
     }
     catch
     {
         loginUserStatus = Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials;
     }
     if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.Success)
     {
         return(token.Password);
     }
     return(HiCryptographer.CreateHash(token.Password));
 }
Esempio n. 2
0
        void Application_AuthorizeRequest(object source, EventArgs e)
        {
            if (currentApplicationType != ApplicationType.Installer)
            {
                HttpApplication application = (HttpApplication)source;

                HttpContext context = application.Context;

                HiContext current = HiContext.Current;

                if (context.Request.IsAuthenticated)
                {
                    string name = context.User.Identity.Name;

                    if (!string.IsNullOrEmpty(name))
                    {
                        string[] rolesForUser = Roles.GetRolesForUser(name);

                        if ((rolesForUser != null) && (rolesForUser.Length > 0))
                        {
                            current.RolesCacheKey = string.Join(",", rolesForUser);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public static bool UpdateUser(IUser user)
        {
            if (null == user)
            {
                return(false);
            }

            bool flag = UserHelper.UpdateUser(user.MembershipUser);

            if (flag)
            {
                flag = UserFactory.Create(user.UserRole).UpdateUser(user);

                HiContext current = HiContext.Current;

                if (current.User.UserId == user.UserId)
                {
                    current.User = user;
                }
            }

            ClearUserCache(user);

            return(flag);
        }
Esempio n. 4
0
        private void Application_BeginRequest(object source, EventArgs e)
        {
            this.currentApplicationType = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
            HttpApplication application = (HttpApplication)source;
            HttpContext     context     = application.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[] { '<', '>', '\'', '"' }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27").Replace("\"", "%22"), false);
            }
            else
            {
                this.CheckInstall(context);
                if (this.currentApplicationType != ApplicationType.Installer)
                {
                    CheckSSL(HiConfiguration.GetConfig().SSL, context);
                    HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.ReWriteUrl));
                    if (HiContext.Current.SiteSettings.IsDistributorSettings && !((!HiContext.Current.SiteSettings.Disabled || (this.currentApplicationType != ApplicationType.Common)) || urlReg.IsMatch(context.Request.Url.AbsolutePath)))
                    {
                        context.Response.Write("站点维护中,暂停访问!");
                        context.Response.End();
                    }
                }
            }
        }
        public static HiContext Create(HttpContext context, bool isReWritten)
        {
            HiContext context2 = new HiContext(context);

            context2.IsUrlReWritten = isReWritten;
            SaveContextToStore(context2);
            return(context2);
        }
Esempio n. 6
0
        public static HiContext Create(HttpContext context, bool isReWritten)
        {
            HiContext hiContext = new HiContext(context);

            hiContext.IsUrlReWritten = isReWritten;
            HiContext.smethod_0(hiContext);
            return(hiContext);
        }
Esempio n. 7
0
        public static HiContext Create(HttpContext context, UrlReWriterDelegate rewriter)
        {
            HiContext context2 = new HiContext(context);

            SaveContextToStore(context2);
            if (null != rewriter)
            {
                context2.IsUrlReWritten = rewriter(context);
            }
            return(context2);
        }
Esempio n. 8
0
        public static HiContext Create(HttpContext context, UrlReWriterDelegate rewriter)
        {
            HiContext hiContext = new HiContext(context);

            HiContext.smethod_0(hiContext);
            if (rewriter != null)
            {
                hiContext.IsUrlReWritten = rewriter(context);
            }
            return(hiContext);
        }
Esempio n. 9
0
        public static void Check(out bool isValid, out bool expired, out int siteQty)
        {
            siteQty = 0;
            isValid = false;
            expired = true;
            HiContext    current        = HiContext.Current;
            XmlDocument  xmlDocument    = HiCache.Get("FileCache_CommercialLicenser") as XmlDocument;
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

            if (xmlDocument == null)
            {
                string text = (current.Context != null) ? current.Context.Request.MapPath("~/config/Certificates.cer") : System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "config\\Certificates.cer");
                if (!System.IO.File.Exists(text))
                {
                    return;
                }
                xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(System.IO.File.ReadAllText(text));
                HiCache.Max("FileCache_CommercialLicenser", xmlDocument, new CacheDependency(text));
            }
            XmlNode xmlNode  = xmlDocument.DocumentElement.SelectSingleNode("//Host");
            XmlNode xmlNode2 = xmlDocument.DocumentElement.SelectSingleNode("//LicenseDate");
            XmlNode xmlNode3 = xmlDocument.DocumentElement.SelectSingleNode("//Expires");
            XmlNode xmlNode4 = xmlDocument.DocumentElement.SelectSingleNode("//SiteQty");
            XmlNode xmlNode5 = xmlDocument.DocumentElement.SelectSingleNode("//Signature");
            //if (string.Compare(xmlNode.InnerText, masterSettings.SiteUrl, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
            //{

            //}

            string s = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Host={0}&Expires={1}&SiteQty={2}&LicenseDate={3}", new object[]
            {
                masterSettings.SiteUrl,
                xmlNode3.InnerText,
                xmlNode4.InnerText,
                xmlNode2.InnerText
            });

            using (System.Security.Cryptography.RSACryptoServiceProvider rSACryptoServiceProvider = new System.Security.Cryptography.RSACryptoServiceProvider())
            {
                rSACryptoServiceProvider.FromXmlString(LicenseHelper.GetPublicKey());
                System.Security.Cryptography.RSAPKCS1SignatureDeformatter rSAPKCS1SignatureDeformatter = new System.Security.Cryptography.RSAPKCS1SignatureDeformatter(rSACryptoServiceProvider);
                rSAPKCS1SignatureDeformatter.SetHashAlgorithm("SHA1");
                byte[] rgbSignature = System.Convert.FromBase64String(xmlNode5.InnerText);
                byte[] rgbHash      = new System.Security.Cryptography.SHA1Managed().ComputeHash(System.Text.Encoding.UTF8.GetBytes(s));
                isValid = rSAPKCS1SignatureDeformatter.VerifySignature(rgbHash, rgbSignature);
                isValid = true;
            }
            expired = (System.DateTime.Now > System.DateTime.Parse(xmlNode3.InnerText));
            if (isValid && !expired)
            {
                int.TryParse(xmlNode4.InnerText, out siteQty);
            }
        }
Esempio n. 10
0
        public static bool CheckCopyright()
        {
            HiContext   current  = HiContext.Current;
            XmlDocument document = HiCache.Get("Hishop_SiteLicense") as XmlDocument;

            if (document == null)
            {
                string path = null;
                if (current.Context != null)
                {
                    path = current.Context.Request.MapPath("~/config/Hishop.lic");
                }
                else
                {
                    path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Hishop.lic");
                }
                if (!File.Exists(path))
                {
                    return(false);
                }
                document = new XmlDocument();
                document.LoadXml(File.ReadAllText(path));
                HiCache.Max("Hishop_SiteLicense", document, new CacheDependency(path));
            }
            XmlNode node  = document.DocumentElement.SelectSingleNode("//Host");
            XmlNode node2 = document.DocumentElement.SelectSingleNode("//LicenseDate");
            XmlNode node3 = document.DocumentElement.SelectSingleNode("//ExpiresDate");
            XmlNode node4 = document.DocumentElement.SelectSingleNode("//Signature");

            if (string.Compare(node.InnerText, current.SiteSettings.SiteUrl, true, CultureInfo.InvariantCulture) != 0)
            {
                return(false);
            }
            string s    = string.Format(CultureInfo.InvariantCulture, "Host={0}&LicenseDate={1}&ExpiresDate={2}&Key={3}", new object[] { current.SiteSettings.SiteUrl, node2.InnerText, node3.InnerText, Hidistro.Membership.Context.LicenseHelper.GetSiteHash() });
            bool   flag = false;

            using (RSACryptoServiceProvider provider = new RSACryptoServiceProvider())
            {
                provider.FromXmlString(Hidistro.Membership.Context.LicenseHelper.GetPublicKey());
                RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(provider);
                deformatter.SetHashAlgorithm("SHA1");
                byte[] rgbSignature = Convert.FromBase64String(node4.InnerText);
                byte[] rgbHash      = new SHA1Managed().ComputeHash(Encoding.UTF8.GetBytes(s));
                flag = deformatter.VerifySignature(rgbHash, rgbSignature);
            }
            return(flag && (DateTime.Now < DateTime.Parse(node3.InnerText)));
        }
Esempio n. 11
0
        /// <summary>
        /// 网站模块入口
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        void Application_BeginRequest(object source, EventArgs e)
        {
            currentApplicationType = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;

            HttpApplication application = (HttpApplication)source;

            HttpContext context = application.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[] { '<', '>', '\'', '"' }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27").Replace("\"", "%22"), false);
            }
            else
            {
                //检查是否已经安装了网站
                CheckInstall(context);

                if (currentApplicationType != ApplicationType.Installer)
                {
                    //后台域名验证
                    if (currentApplicationType == ApplicationType.Admin && string.Compare(Globals.DomainName, HiContext.Current.SiteSettings.SiteUrl, true) != 0)
                    {
                        context.Response.Redirect(Globals.GetSiteUrls().Home, true);
                    }
                    else
                    {
                        CheckSSL(HiConfiguration.GetConfig().SSL, context);

                        HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.ReWriteUrl));

                        if (HiContext.Current.SiteSettings.IsDistributorSettings)
                        {
                            if (!((!HiContext.Current.SiteSettings.Disabled || (currentApplicationType != ApplicationType.Common)) || urlReg.IsMatch(context.Request.Url.AbsolutePath)))
                            {
                                context.Response.Write("站点维护中,暂停访问!");
                                context.Response.End();
                            }
                            else if (currentApplicationType == ApplicationType.Admin)
                            {
                                context.Response.Redirect(Globals.GetSiteUrls().Home, false);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        private void method_1(object sender, System.EventArgs e)
        {
            this.applicationType_0 = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     context         = httpApplication.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[]
            {
                '<',
                '>',
                '\'',
                '"'
            }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27").Replace("\"", "%22"), false);
                return;
            }
            this.method_2(context);
            if (this.applicationType_0 != ApplicationType.Installer)
            {
                if (this.applicationType_0 == ApplicationType.Admin && string.Compare(Globals.DomainName, "localhost", true) != 0 && string.Compare(Globals.DomainName, HiContext.Current.SiteSettings.SiteUrl, true) != 0)
                {
                    context.Response.Redirect(Globals.GetSiteUrls().Home, true);
                    return;
                }
                HiHttpModule.smethod_0(HiConfiguration.GetConfig().SSL, context);
                HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.smethod_1));
                if (HiContext.Current.SiteSettings.IsDistributorSettings)
                {
                    if (HiContext.Current.SiteSettings.Disabled && this.applicationType_0 == ApplicationType.Common && !HiHttpModule.regex_0.IsMatch(context.Request.Url.AbsolutePath))
                    {
                        context.Response.Write("站点维护中,暂停访问!");
                        context.Response.End();
                        return;
                    }
                    if (this.applicationType_0 == ApplicationType.Admin)
                    {
                        context.Response.Redirect(Globals.GetSiteUrls().Home, false);
                    }
                }
            }
        }
Esempio n. 13
0
        private void Application_BeginRequest(object source, EventArgs e)
        {
            this.currentApplicationType = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
            HttpApplication application = (HttpApplication)source;
            HttpContext     context     = application.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[] { '<', '>', '\'', '"' }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27").Replace("\"", "%22"), false);
            }
            else
            {
                this.CheckInstall(context);
                if (this.currentApplicationType != ApplicationType.Installer)
                {
                    CheckSSL(HiConfiguration.GetConfig().SSL, context);
                    HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.ReWriteUrl));
                }
            }
        }
Esempio n. 14
0
        public static bool UpdateUser(IUser user)
        {
            if (user == null)
            {
                return(false);
            }
            bool result;

            if (result = UserHelper.UpdateUser(user.MembershipUser))
            {
                result = Class0.smethod_0(user.UserRole).vmethod_6(user);
                HiContext current = HiContext.Current;
                if (current.User.UserId == user.UserId)
                {
                    current.User = user;
                }
            }
            Users.ClearUserCache(user);
            return(result);
        }
Esempio n. 15
0
 private void method_0(object sender, System.EventArgs e)
 {
     if (this.applicationType_0 != ApplicationType.Installer)
     {
         HttpApplication httpApplication = (HttpApplication)sender;
         HttpContext     context         = httpApplication.Context;
         HiContext       current         = HiContext.Current;
         if (context.Request.IsAuthenticated)
         {
             string name = context.User.Identity.Name;
             if (!string.IsNullOrEmpty(name))
             {
                 string[] rolesForUser = Roles.GetRolesForUser(name);
                 if (rolesForUser != null && rolesForUser.Length > 0)
                 {
                     current.RolesCacheKey = string.Join(",", rolesForUser);
                 }
             }
         }
     }
 }
Esempio n. 16
0
 protected override void AttachChildControls()
 {
     Hidistro.Membership.Context.HiContext arg_05_0 = Hidistro.Membership.Context.HiContext.Current;
     if (this.Context.Request.IsAuthenticated)
     {
         System.Web.Security.FormsAuthentication.SignOut();
         System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(Hidistro.Membership.Context.HiContext.Current.User.Username, true);
         Hidistro.Membership.Core.IUserCookie userCookie = Hidistro.Membership.Context.HiContext.Current.User.GetUserCookie();
         if (userCookie != null)
         {
             userCookie.DeleteCookie(authCookie);
         }
         Hidistro.Membership.Core.RoleHelper.SignOut(Hidistro.Membership.Context.HiContext.Current.User.Username);
         this.Page.Response.Cookies["hishopLoginStatus"].Value = "";
     }
     this.txtUserName     = (System.Web.UI.WebControls.TextBox) this.FindControl("txtUserName");
     this.txtPassword     = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPassword");
     this.btnLogin        = (System.Web.UI.WebControls.Button) this.FindControl("btnLogin");
     this.txtCode         = (System.Web.UI.WebControls.TextBox) this.FindControl("txtCode");
     this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
 }
Esempio n. 17
0
 public static HiContext Create(HttpContext context)
 {
     return(HiContext.Create(context, false));
 }
Esempio n. 18
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            this.parameters.Add("CurrentOpenId", e.OpenId);
            Hidistro.Membership.Context.HiContext current = Hidistro.Membership.Context.HiContext.Current;
            string usernameWithOpenId = Hidistro.Membership.Core.UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType);

            if (!string.IsNullOrEmpty(usernameWithOpenId))
            {
                Hidistro.Membership.Context.Member member = Hidistro.Membership.Context.Users.GetUser(0, usernameWithOpenId, false, true) as Hidistro.Membership.Context.Member;
                if (member == null)
                {
                    base.Response.Write("登录失败,信任登录只能用于会员登录。");
                    return;
                }
                if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings)
                {
                    if (!member.ParentUserId.HasValue || member.ParentUserId.Value != Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId)
                    {
                        base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                        return;
                    }
                }
                else
                {
                    if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
                    {
                        base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                        return;
                    }
                }
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                Hidistro.Membership.Core.IUserCookie userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                Hidistro.Membership.Context.HiContext.Current.User = member;
                ShoppingCartInfo       shoppingCart           = ShoppingCartProcessor.GetShoppingCart();
                CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance();
                cookieShoppingProvider.ClearShoppingCart();
                current.User = member;
                bool flag = false;
                if (cookieShoppingProvider.GetShoppingCart() != null && cookieShoppingProvider.GetShoppingCart().GetQuantity() > 0)
                {
                    flag = true;
                    cookieShoppingProvider.ClearShoppingCart();
                }
                if (shoppingCart != null && flag)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + Hidistro.Membership.Context.HiContext.Current.User.UserId.ToString());
                    httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    httpCookie.Value   = this.parameters["token"];
                    System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
            }
            else
            {
                string a;
                if ((a = this.openIdType.ToLower()) != null)
                {
                    if (a == "hishop.plugins.openid.alipay.alipayservice")
                    {
                        this.SkipAlipayOpenId();
                        goto IL_288;
                    }
                    if (a == "hishop.plugins.openid.qq.qqservice")
                    {
                        this.SkipQQOpenId();
                        goto IL_288;
                    }
                    if (a == "hishop.plugins.openid.taobao.taobaoservice")
                    {
                        this.SkipTaoBaoOpenId();
                        goto IL_288;
                    }
                    if (a == "hishop.plugins.openid.sina.sinaservice")
                    {
                        this.SkipSinaOpenId();
                        goto IL_288;
                    }
                }
                this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }
IL_288:
            string a2 = this.parameters["HITO"];

            if (a2 == "1")
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder"));
                return;
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Esempio n. 19
0
 private static void SaveContextToStore(HiContext context)
 {
     context.Context.Items["Hishop_ContextStore"] = context;
 }
Esempio n. 20
0
        public static HiContext Create(HttpContext context, bool isReWritten)
        {
            HiContext hiContext = new HiContext(context);

            hiContext.IsUrlReWritten = isReWritten;

            SaveContextToStore(hiContext);

            return hiContext;
        }
Esempio n. 21
0
 protected override void AttachChildControls()
 {
     Hidistro.Membership.Context.HiContext current = Hidistro.Membership.Context.HiContext.Current;
     PageTitle.AddTitle(current.SiteSettings.SiteName + " - " + current.SiteSettings.SiteDescription, Hidistro.Membership.Context.HiContext.Current.Context);
 }
Esempio n. 22
0
 private static void smethod_0(HiContext hiContext_0)
 {
     hiContext_0.Context.Items["Hishop_ContextStore"] = hiContext_0;
 }
Esempio n. 23
0
 static void SaveContextToStore(HiContext context)
 {
     context.Context.Items["Hishop_ContextStore"] = context;
 }
Esempio n. 24
0
        public static HiContext Create(HttpContext context, UrlReWriterDelegate rewriter)
        {
            HiContext hiContext = new HiContext(context);

            SaveContextToStore(hiContext);

            if (null != rewriter)
            {
                hiContext.IsUrlReWritten = rewriter(context);
            }

            return hiContext;
        }