示例#1
0
        public static void RequestAuthentication(Membership membership, string connectName, HttpContextBase httpContext, string returnUrl)
        {
            var client = GetAuthClient(membership, connectName);

            OpenAuthSecurityManager manager = new OpenAuthSecurityManager(httpContext, client.GetOpenAuthClient(), new MembershipOpenAuthDataProvider());
            manager.RequestAuthentication(returnUrl);
            //client.RequestAuthentication(httpContext, new Uri(returnUrl));
        }
示例#2
0
        private static IAuthClient GetAuthClient(Membership membership, string connectName)
        {
            var membershipConnect = new MembershipConnect() { Membership = membership, Name = connectName }.AsActual();

            if (membershipConnect == null)
            {
                throw new ArgumentException("Invalid membership connect.");
            }

            var authClient = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<IAuthClient>(membershipConnect.Name.ToLower());
            authClient.MembershipConnect = membershipConnect;

            return authClient;
        }
 public virtual string EncodePassword(Membership membership, string pass, string salt)
 {
     HashAlgorithm hashAlgorithm = this.GetHashAlgorithm(membership.HashAlgorithmType);
     if (hashAlgorithm == null)
     {
         return pass;
     }
     else
     {
         byte[] bytes = Encoding.Unicode.GetBytes(pass);
         byte[] src = Convert.FromBase64String(salt);
         byte[] inArray = null;
         if (hashAlgorithm is KeyedHashAlgorithm)
         {
             KeyedHashAlgorithm algorithm2 = (KeyedHashAlgorithm)hashAlgorithm;
             if (algorithm2.Key.Length == src.Length)
             {
                 algorithm2.Key = src;
             }
             else if (algorithm2.Key.Length < src.Length)
             {
                 byte[] dst = new byte[algorithm2.Key.Length];
                 Buffer.BlockCopy(src, 0, dst, 0, dst.Length);
                 algorithm2.Key = dst;
             }
             else
             {
                 int num2;
                 byte[] buffer5 = new byte[algorithm2.Key.Length];
                 for (int i = 0; i < buffer5.Length; i += num2)
                 {
                     num2 = Math.Min(src.Length, buffer5.Length - i);
                     Buffer.BlockCopy(src, 0, buffer5, i, num2);
                 }
                 algorithm2.Key = buffer5;
             }
             inArray = algorithm2.ComputeHash(bytes);
         }
         else
         {
             byte[] buffer6 = new byte[src.Length + bytes.Length];
             Buffer.BlockCopy(src, 0, buffer6, 0, src.Length);
             Buffer.BlockCopy(bytes, 0, buffer6, src.Length, bytes.Length);
             inArray = hashAlgorithm.ComputeHash(buffer6);
         }
         return Convert.ToBase64String(inArray);
     }
 }
示例#4
0
 internal static AuthResult VerifyAuthenticationCore(Membership membership, HttpContextBase context, string returnUrl)
 {
     IAuthClient client;
     string providerName = OpenAuthSecurityManager.GetProviderName(context);
     if (string.IsNullOrEmpty(providerName))
     {
         return AuthResult.Failed;
     }
     client = GetAuthClient(membership, providerName);
     if (client == null)
     {
         throw new InvalidOperationException("Invalid membership connect.");
     }
     OpenAuthSecurityManager manager = new OpenAuthSecurityManager(context, client.GetOpenAuthClient(), new MembershipOpenAuthDataProvider());
     var result = manager.VerifyAuthentication(returnUrl);
     return new AuthResult(result);
 }
示例#5
0
        public virtual ActionResult Edit(string membershipName)
        {
            var membership = new Kooboo.CMS.Member.Models.Membership() { Name = membershipName }.AsActual();

            return View(membership);
        }
 public IEnumerable<System.Web.Mvc.SelectListItem> GetSelectListItems(System.Web.Routing.RequestContext requestContext, string filter = null)
 {
     var membershipGroupManager = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<MembershipGroupManager>();
     var membership = new Kooboo.CMS.Member.Models.Membership(requestContext.GetRequestValue("membershipName"));
     return membershipGroupManager.All(membership, "").Select(it => new SelectListItem() { Text = it.Name, Value = it.Name });
 }
示例#7
0
 public static AuthResult VerifyAuthentication(Membership membership, HttpContextBase httpContext, string returnUrl)
 {
     return VerifyAuthenticationCore(membership, httpContext, returnUrl);
 }