当前位置: 首页>>代码示例>>C#>>正文


C# HttpContextWrapper.SetAuthenticationTicket方法代码示例

本文整理汇总了C#中System.Web.HttpContextWrapper.SetAuthenticationTicket方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContextWrapper.SetAuthenticationTicket方法的具体用法?C# HttpContextWrapper.SetAuthenticationTicket怎么用?C# HttpContextWrapper.SetAuthenticationTicket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpContextWrapper的用法示例。


在下文中一共展示了HttpContextWrapper.SetAuthenticationTicket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AuthenticateHostAdmin

        /// <summary>
        /// Authenticates the host admin.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="persist">if set to <c>true</c> [persist].</param>
        /// <returns></returns>
        public static bool AuthenticateHostAdmin(this HostInfo host, string username, string password, bool persist)
        {
            if (!host.ValidateHostAdminPassword(username, password))
            {
                return false;
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug("SetAuthenticationTicket-HostAdmins for " + username);
            }
            HttpContextBase httpContext = new HttpContextWrapper(HttpContext.Current);
            httpContext.SetAuthenticationTicket(null, username, persist, true, "HostAdmins");

            return true;
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:23,代码来源:SecurityHelper.cs

示例2: Authenticate

        /// <summary>
        /// Check to see if the supplied OpenID claim is valid for the current blog. If so, 
        /// Set the user's FormsAuthentication Ticket This method will handle passwords for 
        /// both hashed and non-hashed configurations
        /// We're comparing URI objects rather than using simple string compare because
        /// functionally equivalent URI's may not pass string comparaisons, e.g.
        /// such as http://example.myopenid.com/ and http://example.myopenid.com (trailing /)
        /// </summary>
        public static bool Authenticate(string claimedIdentifier, bool persist)
        {
            Blog currentBlog = Config.CurrentBlog;
            if (currentBlog == null)
            {
                return false;
            }

            //If the current blog doesn't have a valid OpenID URI, must fail
            if (!Uri.IsWellFormedUriString(currentBlog.OpenIdUrl, UriKind.Absolute))
            {
                return false;
            }

            //If the cliamed identifier isn't a valid OpenID URI, must fail
            if (!Uri.IsWellFormedUriString(claimedIdentifier, UriKind.Absolute))
            {
                return false;
            }

            var currentBlogClaimUri = new Uri(currentBlog.OpenIdUrl);
            var claimedUri = new Uri(claimedIdentifier);

            if (claimedUri.Host != currentBlogClaimUri.Host ||
               claimedUri.AbsolutePath != currentBlogClaimUri.AbsolutePath ||
               claimedUri.Query != currentBlogClaimUri.Query)
            {
                return false;
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug("SetAuthenticationTicket-Admins via OpenID for " + currentBlog.UserName);
            }
            HttpContextBase httpContext = new HttpContextWrapper(HttpContext.Current);
            httpContext.SetAuthenticationTicket(currentBlog, currentBlog.UserName, persist, "Admins");
            return true;
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:46,代码来源:SecurityHelper.cs

示例3: AuthenticateHostAdmin

        /// <summary>
        /// Authenticates the host admin.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="persist">if set to <c>true</c> [persist].</param>
        /// <returns></returns>
        public static bool AuthenticateHostAdmin(string username, string password, bool persist)
        {
            if(!String.Equals(username, HostInfo.Instance.HostUserName, StringComparison.InvariantCultureIgnoreCase))
            {
                return false;
            }

            if(Config.Settings.UseHashedPasswords)
            {
                password = HashPassword(password, HostInfo.Instance.Salt);
            }

            if(!String.Equals(HostInfo.Instance.Password, password, StringComparison.InvariantCultureIgnoreCase))
            {
                return false;
            }

            if(Log.IsDebugEnabled)
            {
                Log.Debug("SetAuthenticationTicket-HostAdmins for " + username);
            }
            HttpContextBase httpContext = new HttpContextWrapper(HttpContext.Current);
            httpContext.SetAuthenticationTicket(null, username, persist, true, "HostAdmins");

            return true;
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:33,代码来源:SecurityHelper.cs


注:本文中的System.Web.HttpContextWrapper.SetAuthenticationTicket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。